I would like to use micronaut-rabbitmq to send messages between services via topics. Therefore I've created an exchange, queues and bindings in the ChannelInitializer like this:
channel.exchangeDeclare("registration", BuiltinExchangeType.TOPIC, true)
channel.queueDeclare("user_new", true, false, false, null)
channel.queueBind("user_new", "registration", "user.new.#")
channel.queueDeclare("user_all", true, false, false, null)
channel.queueBind("user_all", "registration", "user.#")
When I try to send a message to the routingkey "user.new" it is not send to any of the queues.
@Binding("user.new")
override fun userCreated(event: UserCreatedEvent)
I would expect, that it is send to both of the queues because of the topics routingkeys.
If I rename the "user_new" queue to "user.new" the message is send to this queue. But as I want to have the message in both queues this is no option.
Any help would be appreciated!
Thank you
My Problem was, that I didn't declare the exchange on the @RabbitClient
After changing @RabbitClient
to @RabbitClient("registration")
everything works perfectly.