Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide ability to publish and consume binary data directly #268

Merged
merged 1 commit into from
Aug 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ open class TxChannel internal constructor(private val channel: Channel) : Channe

fun publish(message: OutboundMessage) {
message.apply {
[email protected](exchange, routingKey, properties, msg.toByteArray())
[email protected](exchange, routingKey, properties, msg)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class ConfirmPublisher internal constructor(private val channel: Channel) {
continuations[messageSequenceNumber] = continuation
continuation.invokeOnCancellation { continuations.remove(messageSequenceNumber) }
cancelOnIOException(continuation) {
message.run { channel.basicPublish(exchange, routingKey, properties, msg.toByteArray()) }
message.run { channel.basicPublish(exchange, routingKey, properties, msg) }
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,34 @@ data class OutboundMessage(
val exchange: String,
val routingKey: String,
val properties: BasicProperties,
val msg: String
)
val msg: ByteArray
) {
constructor(
exchange: String,
routingKey: String,
properties: BasicProperties,
msg: String
) : this(exchange, routingKey, properties, msg.toByteArray())

override fun equals(other: Any?): Boolean {
if (this === other) return true
if (javaClass != other?.javaClass) return false

other as OutboundMessage

if (exchange != other.exchange) return false
if (routingKey != other.routingKey) return false
if (properties != other.properties) return false
if (!msg.contentEquals(other.msg)) return false

return true
}

override fun hashCode(): Int {
var result = exchange.hashCode()
result = 31 * result + routingKey.hashCode()
result = 31 * result + properties.hashCode()
result = 31 * result + msg.contentHashCode()
return result
}
}