spring-rabbit

Spring rabbitlistner stop listening to queue using annotation syntax

浪尽此生 提交于 2019-12-06 10:04:24
A colleague and I are working on an application using Spring which needs to get a message from a RabbitMQ queue. The idea is to do this using (the usually excellent) spring annotation system to make the code easy to understand. We have the system working using the @RabbitListner annotation but we want to get a message on demand. The @RabbitListner annotation does not do this, it just receives messages when they are available. The demand is determined by the "readiness" of the client i.e. a client should "get" a message from te queue stop listing and process the message. Then determine if it is

How to implement a round-robin queue consumer in Spring boot

时光毁灭记忆、已成空白 提交于 2019-12-06 07:59:16
I am building a message driven service in spring which will run in a cluster and needs to pull messages from a RabbitMQ queue in a round robin manner. The implementation is currently pulling messages off the queue in a first come basis leading to some servers getting backed up while others are idle. The current QueueConsumerConfiguration.java looks like : @Configuration public class QueueConsumerConfiguration extends RabbitMqConfiguration { private Logger LOG = LoggerFactory.getLogger(QueueConsumerConfiguration.class); private static final int DEFAULT_CONSUMERS=2; @Value("${eventservice

OAuth2 authorization with Spring Security and Rabbitmq

£可爱£侵袭症+ 提交于 2019-12-05 02:16:51
问题 We currently have a number of Spring microservices that are communicating with REST endpoints and RabbitMQ queues. We have just implemented OAuth2 security on all of the services, and the REST endpoints are appropriately secured. We have a library that we wrote which creates the RabbitTemplate and AmqpAdmin beans so that the boilerplate code doesn't have to be done in every service. We are connecting to the RabbitMQ server in Spring with a specific user for regular clients, and another for

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

spring rabbit amqp @RabbitListener configure min and max number of consumers

本小妞迷上赌 提交于 2019-12-04 14:40:18
问题 I am using spring amqp rabbit @RabbitListener annotation from : artifact spring-rabbit-1.7.1.RELEASE I wonder if there is a way to configure for each queue the number of consumers ? I have been digging in the documentation and found nothing yet , is there a way to configure in the related container for each queue the number of consumers ? Thanks in advance. 回答1: Configure the concurrency via the container factory bean as shown in the documentation. @Bean public

Send files through RabbitMQ

Deadly 提交于 2019-12-04 03:30:16
问题 Is it a good idea to send files with size about 1Mb through RabbitMQ? I want to send message in json format with binary fields corresponding to the files. And how to do it properly using spring-amqp? Just by publishing object with next class? class Message { String field1; byte[] fileField1; byte[] fileField2; } 回答1: I would suggest not only reading those links that were posted but also, doing some of your own experimentation. The thing I would be concerned about is performance at the service

Spring Amqp has NoClassDefFoundError in springframework RetryCallback class

二次信任 提交于 2019-12-02 07:02:53
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> <dependency> <groupId>org.springframework.amqp</groupId> <artifactId>spring-rabbit</artifactId> <version>1.5

RabbitMQ basic.get and acknowledgement

梦想与她 提交于 2019-12-01 13:23:18
问题 I'm invoking: GetResponse response = channel.basicGet("some.queue", false); // no auto-ack .... channel.basicAck(deliveryTag, ...); However, when I invoke basicGet , the messages in the queue stay in "Ready", rather than in "Unacknowledged". I want them to be in unacknowledged, so that I can either basic.ack them (thus discarding them from the queue), or basic.nack them 回答1: I'm doing the following to mimic Delaying the ack : At consumption time Get(consume) the message form the initial Queue

What is the difference between prefetch count vs no ack in rabbitmq

笑着哭i 提交于 2019-12-01 10:11:09
I need to know what is the difference between prefetch count vs no ack in rabbitmq ? Also What is the difference between following statements :- if i set prefetch count say 10 does 10 consumer threads are created ? Or -- if i register 10 cosumers will it create 10 threads ? Which of the above is more efficient Pre-fetch count: How many messages the consumer should read from queue and kept internally rather than picking one message at a time. No-Ack: Do not acknowledge back that the consumer is done consuming the message. Those both are used to fine tune your set-up To address your second part

What is the difference between prefetch count vs no ack in rabbitmq

自闭症网瘾萝莉.ら 提交于 2019-12-01 09:45:38
问题 I need to know what is the difference between prefetch count vs no ack in rabbitmq ? Also What is the difference between following statements :- if i set prefetch count say 10 does 10 consumer threads are created ? Or -- if i register 10 cosumers will it create 10 threads ? Which of the above is more efficient 回答1: Pre-fetch count: How many messages the consumer should read from queue and kept internally rather than picking one message at a time. No-Ack: Do not acknowledge back that the