spring-rabbit

Spring RabbitTemplate - How to create queues automatically upon send

孤街醉人 提交于 2020-01-03 10:54:40
问题 I am using RabbitMQ together with Spring's RabbitTemplate. When sending messages to queues using the template send methods, I want the queue to automatically be created/declared if it is not already exists. It is very important since according to our business logic queue names are generated on run-time and I cannot declare them in advance. Previously we have used JmsTemplate and any call to send or receive automatically created the queue. 回答1: Yes, you can use a RabbitAdmin and admin

Spring RabbitTemplate - How to create queues automatically upon send

只愿长相守 提交于 2020-01-03 10:52:47
问题 I am using RabbitMQ together with Spring's RabbitTemplate. When sending messages to queues using the template send methods, I want the queue to automatically be created/declared if it is not already exists. It is very important since according to our business logic queue names are generated on run-time and I cannot declare them in advance. Previously we have used JmsTemplate and any call to send or receive automatically created the queue. 回答1: Yes, you can use a RabbitAdmin and admin

SpringBoot Disable rabbitTemplate retry policy for rabbit health check

你。 提交于 2020-01-01 19:37:33
问题 My SpringBoot configuration contains very strong retry policy for rabbitTemplate retries spring: rabbitmq: template: retry: enabled: true initial-interval: 500 max-attempts: 10 multiplier: 5 max-interval: 60000 The problem with this configuration is when health endpoint is called and rabbitMQ is down, the connections hangs for really long time. Adding properties like spring.rabbitmq.connection-timeout=500 or spring.rabbitmq.template.receive-timeout=500 or spring.rabbitmq.template.reply

Sending acknowledgment to rabbitmq server in depends on converter and listener

这一生的挚爱 提交于 2019-12-31 05:57:31
问题 First of all, I present context of my case: I am using spring-boot and spring-rabbitmq . It is working for me, you should know that I must have implemented custom converter for received messages. (1) From this converter can be thrown exception, for instance in case of inproper message and so on. (2) After successfull converting (no exception) listener is invoked. Then, in the listener it can also be thrown exception. Now, I would like to force two things: (1') Don't requeue message in case of

Spring Amqp has NoClassDefFoundError in springframework RetryCallback class

一笑奈何 提交于 2019-12-31 03:54:06
问题 I have been working on a distributed web project and I want to utilize Spring amqp using RabbitMq in it. I use springFramework version 4.1.6 in my project. To do this, I have added the following dependencies to the file pom.xml. <dependency> <groupId>com.rabbitmq</groupId> <artifactId>amqp-client</artifactId> <version>3.5.7</version> </dependency> <dependency> <groupId>org.springframework.amqp</groupId> <artifactId>spring-amqp</artifactId> <version>1.5.3.RELEASE</version> </dependency>

How do we hook into before/After message processing using @RabbitListener

只愿长相守 提交于 2019-12-30 06:32:30
问题 Problem: I am migrating from MessageListener interface impl to @RabbitListener. I had logic like this where I was doing "pre" and "post" message processing on a MessageListener that was inherited by several classes example: public AbstractMessageListener implements MessageListener { @Override public void onMessage(Message message) { //do some pre message processing process(Message message); // do some post message processing } protected abstract void process(Message message); } Question: Is

Dynamic SendTo annotation

回眸只為那壹抹淺笑 提交于 2019-12-25 05:37:05
问题 I have Java code as following to receive messages form a queue, process it and write processed message to another queue. @RabbitListener(queues = "rawFusion") @SendTo("Fusion") public String receiverFusion(Object _message) { String message = getMessage(_message); return messageParser.parse(message); } Here i always get messages from "rawFusion" queue and write it into "Fusion" queue. The thing I want to do is, writing messages different queues depending on some conditions. So i would like

rabbitmq-consistent-hash-exchange with java-client / spring-rabbit

試著忘記壹切 提交于 2019-12-24 13:27:40
问题 I would like to use the capabilities of rabbitmq-consistent-hash-exchange from java client or preferably by using the spring abstraction spring-amqp. Unfortunately I failed to found an example that explain the java usage and reference a jar dependency to include, please advice. 回答1: There is no specific tag for "x-" exchanges. Use CustomExchange for it: <bean id="requestHashExchangeTest" class="org.springframework.amqp.core.CustomExchange"> <constructor-arg name="name" value="test.hash

Spring RabbitTemplate is not creating dead letter queue with TTL

不羁的心 提交于 2019-12-24 03:31:44
问题 I am using spring-rabbit1.1 and RabbitMQ 3.3.1 , My spring configuration will create any queue with the help of RabbitTemplate on Rabbit MQ but if the queue has been configured with x-dead-letter-exchange and x-message-ttl , it just creates the queue with out the TTL and dead letter exchange. For Eg : the below queue will create the queue but TTL and dead letter exhange is not getting created . <rabbit:queue name="hello.queue.dead"> <rabbit:queue-arguments> <entry key="x-dead-letter-exchange"

How to send correlation id, into message, from sender and retrieval from receive into message header with Rabbit MQ by java

六眼飞鱼酱① 提交于 2019-12-24 00:39:46
问题 I have used Rabbit MQ to send and receive a JSON message. I have implemented an application using the RabbitTemplate instance with convertAndSend method to send a message to the exchange as below: rabbitTemplate.convertAndSend(exchangeNameOut, message.getString(PERSISTENCE_MESSAGE_ROUTING_KEY), message.getString(PERSISTENCE_MESSAGE_BODY), new CorrelationData(""+analyticRuntime.getId())); While to retrieval a message, side receiver, I have implemented the followed method: @RabbitListener