如何使用带有 BuiltinExchangeType 主题的 micronaut rabbitmq 客户端
How to use micronaut rabbitmq client with BuiltinExchangeType TOPIC
我想使用 micronaut-rabbitmq 通过主题在服务之间发送消息。
因此,我在 ChannelInitializer 中创建了一个交换、队列和绑定,如下所示:
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.#")
当我尝试将消息发送到路由键“user.new”时,它没有发送到任何队列。
@Binding("user.new")
override fun userCreated(event: UserCreatedEvent)
我预计,由于主题路由键,它被发送到两个队列。
如果我将“user_new”队列重命名为“user.new”,消息将发送到此队列。但是因为我想在两个队列中都有消息,所以这是不可能的。
如有任何帮助,我们将不胜感激!
谢谢
我的问题是,我没有在 @RabbitClient
上申报兑换
将 @RabbitClient
更改为 @RabbitClient("registration")
后一切正常。
我想使用 micronaut-rabbitmq 通过主题在服务之间发送消息。 因此,我在 ChannelInitializer 中创建了一个交换、队列和绑定,如下所示:
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.#")
当我尝试将消息发送到路由键“user.new”时,它没有发送到任何队列。
@Binding("user.new")
override fun userCreated(event: UserCreatedEvent)
我预计,由于主题路由键,它被发送到两个队列。
如果我将“user_new”队列重命名为“user.new”,消息将发送到此队列。但是因为我想在两个队列中都有消息,所以这是不可能的。
如有任何帮助,我们将不胜感激!
谢谢
我的问题是,我没有在 @RabbitClient
将 @RabbitClient
更改为 @RabbitClient("registration")
后一切正常。