[英]Rabbit listener method is not getting invoked with the incoming message
I have a method to consume messages in similar line as shown below:我有一种方法可以在类似的行中使用消息,如下所示:
@RabbitListener(queues = "${com.rabbimq.myQueue}")
public void receive(String msg, Channel channel, @Header(AmqpHeaders.DELIVERY_TAG) long tag)
throws IOException {
log.info("Received msg: {}",msg);
channel.basicAck(tag, false);
}
This works fine when I execute it as a SpringBoot project.当我将它作为 SpringBoot 项目执行时,这可以正常工作。 But when I build this project and put it as a dependency in my other project, it no longer consumes the message.但是当我构建这个项目并将其作为依赖项放在我的另一个项目中时,它不再使用该消息。 I want this to be a generic project which can be leveraged by my other projects.我希望这是一个可以被我的其他项目利用的通用项目。 I have put some loggers in this "message consumption" project and I can see that all the beans are getting created.我在这个“消息消费”项目中放了一些记录器,我可以看到所有的 bean 都被创建了。 But it's not invoking this particular method.但它没有调用这个特定的方法。 Any pointers here is really appreciated.这里的任何指针都非常感谢。
The class that this method is in must be declared as a @Bean or, if it is a @Component, it must be in a package that is scanned for component scanning.此方法所在的 class 必须声明为 @Bean,或者,如果它是 @Component,则必须在为组件扫描而扫描的 package 中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.