Skip to content

Commit a73131c

Browse files
authored
Merge pull request #268 from laserg/issue-267
Provide ability to publish and consume binary data directly
2 parents bffa8a7 + 99a7b49 commit a73131c

File tree

3 files changed

+33
-4
lines changed

3 files changed

+33
-4
lines changed

src/main/kotlin/com/viartemev/thewhiterabbit/channel/TxChannel.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ open class TxChannel internal constructor(private val channel: Channel) : Channe
3434

3535
fun publish(message: OutboundMessage) {
3636
message.apply {
37-
this@TxChannel.channel.basicPublish(exchange, routingKey, properties, msg.toByteArray())
37+
this@TxChannel.channel.basicPublish(exchange, routingKey, properties, msg)
3838
}
3939
}
4040

src/main/kotlin/com/viartemev/thewhiterabbit/publisher/ConfirmPublisher.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class ConfirmPublisher internal constructor(private val channel: Channel) {
3535
continuations[messageSequenceNumber] = continuation
3636
continuation.invokeOnCancellation { continuations.remove(messageSequenceNumber) }
3737
cancelOnIOException(continuation) {
38-
message.run { channel.basicPublish(exchange, routingKey, properties, msg.toByteArray()) }
38+
message.run { channel.basicPublish(exchange, routingKey, properties, msg) }
3939
}
4040
}
4141
}

src/main/kotlin/com/viartemev/thewhiterabbit/publisher/OutboundMessage.kt

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,34 @@ data class OutboundMessage(
66
val exchange: String,
77
val routingKey: String,
88
val properties: BasicProperties,
9-
val msg: String
10-
)
9+
val msg: ByteArray
10+
) {
11+
constructor(
12+
exchange: String,
13+
routingKey: String,
14+
properties: BasicProperties,
15+
msg: String
16+
) : this(exchange, routingKey, properties, msg.toByteArray())
17+
18+
override fun equals(other: Any?): Boolean {
19+
if (this === other) return true
20+
if (javaClass != other?.javaClass) return false
21+
22+
other as OutboundMessage
23+
24+
if (exchange != other.exchange) return false
25+
if (routingKey != other.routingKey) return false
26+
if (properties != other.properties) return false
27+
if (!msg.contentEquals(other.msg)) return false
28+
29+
return true
30+
}
31+
32+
override fun hashCode(): Int {
33+
var result = exchange.hashCode()
34+
result = 31 * result + routingKey.hashCode()
35+
result = 31 * result + properties.hashCode()
36+
result = 31 * result + msg.contentHashCode()
37+
return result
38+
}
39+
}

0 commit comments

Comments
 (0)