spring-rabbitmq

RabbitMQ - Send message to a particular consumer in a queue

南笙酒味 提交于 2019-12-06 08:16:01
问题 This is the scenario - There are multiple app servers. Browser can connect via websocket to any app server. The app servers (consumers) are all listening on a particular queue. As soon as a web socket connection is received, the particular app server binds the queue with a routing key {userId} to a direct exchange. I want a message sent to the direct exchange with the routing key {userId} to be received by only the particular app server where the binding has occured. Is a direct exchange the

SpringAMQP RabbitMQ how to send directly to Queue without Exchange

折月煮酒 提交于 2019-12-06 03:48:08
I'm using SpringAMQP with Rabbit template. How to send messages directly to Queues omitting Exchange? How can i do it? How can i do it? You can't; publishers don't know about queues; just exchanges and routing keys. However, all queues are bound to the default exchange ( "" ) with the queue name as its routing key. If you are using Spring AMQP's RabbitTemplate , it is configured to publish to the default exchange by default, so you can use convertAndSend("myQueue", "foo")` Or even... template.setDefaultRoutingKey("myQueue"); then template.convertAndSend("foo"); or template.send(aMessage); 来源:

Automatic retry connection to broker by spring-rabbitmq

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-05 11:48:46
I have read this fragment of docs: RabbitMQ Automatic Connection/Topology recovery Since the first version of Spring AMQP, the framework has provided its own connection and channel recovery in the event of a broker failure. Also, as discussed in Section 3.1.10, “Configuring the broker”, the RabbitAdmin will re-declare any infrastructure beans (queues etc) when the connection is re-established. It therefore does not rely on the Auto Recovery that is now provided by the amqp-client library. Spring AMQP now uses the 4.0.x version of amqp-client, which has auto recovery enabled by default. Spring

Spring AMQP - Message re queuing using dead letter mechanism with TTL

淺唱寂寞╮ 提交于 2019-12-04 20:49:17
Its like " Houston we have a problem here " where I need to schedule/delay a message for 5 minutes after it fails on the first attempt to process an event. I have implemented dead letter exchange in this scenario. The messages on failing, route to the DLX --> Retry Queue and comes back to work queue after a TTL of 5 minutes for another attempt. Here is the configuration I am using: public class RabbitMQConfig { @Bean(name = "work") @Primary Queue workQueue() { return new Queue(WORK_QUEUE, true, false, false, null); } @Bean(name = "workExchange") @Primary TopicExchange workExchange() { return

SpringBoot Disable rabbitTemplate retry policy for rabbit health check

非 Y 不嫁゛ 提交于 2019-12-04 18:15:18
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-timeout=500 or spring.rabbitmq.requested-heartbeat=1 does not help, since the retry.multiplier=5 , so it will

RabbitMQ - Send message to a particular consumer in a queue

我的梦境 提交于 2019-12-04 12:19:49
This is the scenario - There are multiple app servers. Browser can connect via websocket to any app server. The app servers (consumers) are all listening on a particular queue. As soon as a web socket connection is received, the particular app server binds the queue with a routing key {userId} to a direct exchange. I want a message sent to the direct exchange with the routing key {userId} to be received by only the particular app server where the binding has occured. Is a direct exchange the right exchange to use in this case? Or should some other type of exchange be used? I'm using spring

DLX in rabbitmq and spring-rabbitmq - some considerations of rejecting messages

喜你入骨 提交于 2019-12-02 09:54:51
I did read this reference: https://www.rabbitmq.com/dlx.html , however it doesn't resolve my doubts, namely: In case of accepting message there is no problem - spring-rabbitmq send ack and everthing is fine, DLX doesn't know about acked message. The problem is in case rejecting answer, namely what about throwing MessageConverterException ? This message is removed or moved to DLX ? And what about in case other exception ? For example Exception ? It is removed/requeued/moved to DLX ? Edit after answer of @Gary I think, that after answer's @Gary I should add more details about my case and some

How can @MessagingGateway be configured with Spring Cloud Stream MessageChannels?

妖精的绣舞 提交于 2019-11-29 10:52:00
I have developed asynchronous Spring Cloud Stream services, and I am trying to develop an edge service that uses @MessagingGateway to provide synchronous access to services that are async by nature. I am currently getting the following stack trace: Caused by: org.springframework.messaging.core.DestinationResolutionException: no output-channel or replyChannel header available at org.springframework.integration.handler.AbstractMessageProducingHandler.sendOutput(AbstractMessageProducingHandler.java:355) at org.springframework.integration.handler.AbstractMessageProducingHandler.produceOutput

Spring RabbitMQ - using manual channel acknowledgement on a service with @RabbitListener configuration

允我心安 提交于 2019-11-27 19:30:38
How to acknowledge the messages manually without using auto acknowledgement. Is there a way to use this along with the @RabbitListener and @EnableRabbit style of configuration. Most of the documentation tells us to use SimpleMessageListenerContainer along with ChannelAwareMessageListener . However using that we lose the flexibility that is provided with the annotations. I have configured my service as below : @Service public class EventReceiver { @Autowired private MessageSender messageSender; @RabbitListener(queues = "${eventqueue}") public void receiveMessage(Order order) throws Exception {

Spring RabbitMQ - using manual channel acknowledgement on a service with @RabbitListener configuration

一曲冷凌霜 提交于 2019-11-26 19:38:21
问题 How to acknowledge the messages manually without using auto acknowledgement. Is there a way to use this along with the @RabbitListener and @EnableRabbit style of configuration. Most of the documentation tells us to use SimpleMessageListenerContainer along with ChannelAwareMessageListener . However using that we lose the flexibility that is provided with the annotations. I have configured my service as below : @Service public class EventReceiver { @Autowired private MessageSender messageSender