spring-amqp

Spring AMQP: Creating multiple queues dynamically

青春壹個敷衍的年華 提交于 2020-12-15 07:29:21
问题 I have a Spring @Configuration class that creates and registers RabbitMQ queues as follows: @Amqp @Configuration public class AmqpConfiguration { @Bean ConnectionFactory connectionFactory() { CachingConnectionFactory connectionFactory = new CachingConnectionFactory(HOST); connectionFactory.setUsername(USERNAME); connectionFactory.setPassword(PASSWORD); connectionFactory.addConnectionListener(brokerListener); return connectionFactory; } @Bean SimpleMessageListenerContainer

Spring AMQP - RabbitMQ connection is not created on application startup

懵懂的女人 提交于 2020-12-13 05:58:21
问题 I have a Spring Boot application and my goal is to declare queues, exchanges, and bindings on application startup. The application will produce messages to various queues there will be no consumers on the application. I have included those dependencies on my pom.xml <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> <version>2.3.5.RELEASE</version> </dependency> <dependency> <groupId>org.springframework.amqp</groupId> <artifactId>spring

RabbitMQ: Dynamic addition of queues to a listener at runtime

有些话、适合烂在心里 提交于 2020-08-10 21:08:11
问题 I have a use case where I need to consume messages from queues which are discovered at runtime. Here I have a config class and the listener class. I have defined a consumer for the two existing queues and want to consume messages from new queues which may be discovered at runtime and follow the same naming convention i.e. queue.animals.* Also, I have another service which will send me the newly discovered queue name on a queue named "newQueues". This approach can be changed if not needed and

Send message to arbitrary vhost / exchange with RabbitMQ / Spring AMQP

假如想象 提交于 2020-06-16 09:55:23
问题 I use RabbitMQ and Spring AMQP to send messages. I have this snippet: rabbitTemplate.convertAndSend(exchange, key, object); This works when I operate on a single VHOST . I have to receive messages from 1 queue and resend them to N exchanges (on many different VHOST s). How can I do it in Spring AMQP (ver 1.2) ? Is there anything better than manually defined <rabbit:connection-factory> (for each VHOST) and related elements in my xml context? 回答1: We added support for that in 1.3. See Routing

Send message to arbitrary vhost / exchange with RabbitMQ / Spring AMQP

我怕爱的太早我们不能终老 提交于 2020-06-16 09:49:06
问题 I use RabbitMQ and Spring AMQP to send messages. I have this snippet: rabbitTemplate.convertAndSend(exchange, key, object); This works when I operate on a single VHOST . I have to receive messages from 1 queue and resend them to N exchanges (on many different VHOST s). How can I do it in Spring AMQP (ver 1.2) ? Is there anything better than manually defined <rabbit:connection-factory> (for each VHOST) and related elements in my xml context? 回答1: We added support for that in 1.3. See Routing

multiple Rabbitmq queues with spring boot

陌路散爱 提交于 2020-02-18 10:25:38
问题 From spring boot tutorial: https://spring.io/guides/gs/messaging-rabbitmq/ They give an example of creating 1 queue and 1 queue only, but, what if I want to be able to create more then 1 queue? how would it be possible? Obviously, I can't just create the same bean twice: @Bean Queue queue() { return new Queue(queueNameAAA, false); } @Bean Queue queue() { return new Queue(queueNameBBB, false); } You can't create the same bean twice, it will make ambiguous. 回答1: Give the bean definition factory

multiple Rabbitmq queues with spring boot

不羁岁月 提交于 2020-02-18 10:22:40
问题 From spring boot tutorial: https://spring.io/guides/gs/messaging-rabbitmq/ They give an example of creating 1 queue and 1 queue only, but, what if I want to be able to create more then 1 queue? how would it be possible? Obviously, I can't just create the same bean twice: @Bean Queue queue() { return new Queue(queueNameAAA, false); } @Bean Queue queue() { return new Queue(queueNameBBB, false); } You can't create the same bean twice, it will make ambiguous. 回答1: Give the bean definition factory

Spring RabbitTemplate- How to get hold of the published message for NACKs in Publisher confirm mode

自闭症网瘾萝莉.ら 提交于 2020-02-04 02:34:22
问题 I have a web-app that posts messages on RabbitQueue using spring. I have turned on Publisher confirms and returns enabled and I'm using spring rabbit:template. This is my configuration: <rabbit:template id="amqpTemplate" connection-factory="amqpConnectionFactory" retry-template="retryTemplate" confirm-callback="messagesConfirmCallback" return-callback="messagesReturnCallback" exchange="${rabbitmq.rest.exchange}" routing-key="key.listener" mandatory="true" /> <rabbit:connection-factory id=