Created
July 5, 2021 12:06
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data class SendEvent(val id: String, val message: String) | |
val event = SendEvent(UUID.randomUUID().toString(), "Hi!") | |
val mapper = ObjectMapper() | |
val factory = ConnectionFactory() | |
factory.newConnection().use { | |
it.createChannel().use { ch -> | |
ch.basicPublish("", "send-queue", null, mapper.writeValueAsBytes(event)) | |
} | |
} | |
ch.basicConsume("send-queue", { tag, delivery -> | |
log.info { mapper.readValue(delivery.body, SendEvent::class.java) } | |
}, { _ -> }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment