spring-amqp

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

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

Queue Size in Spring AMQP Java client

瘦欲@ 提交于 2019-12-04 19:09:26
问题 I am using Spring amqp 1.1 version as my java client. I have a queue which has around 2000 messages. I want to have a service which checks this queue size and and if it is empty it will send out a message saying " All items processed". I dont know how to get current queue size ? Please help I googled and found a class "RabbitBrokerAdmin" that was present in earlier version 1.0. I think it is not present in 1.1 now. Any pointers in getting current queue size? 回答1: So I know this is a little

when does an AMQP/RabbitMQ channel with no connections die?

馋奶兔 提交于 2019-12-04 18:54:18
问题 I have a simple RabbitMQ test program randomly enqueuing messages, and another reading them, all using Spring-AMQP. If the consumer dies (for example killing a process without having a chance to close its connection or channel), any messages that it had not acknowledged appear to remain unacknowledged forever. I have seen a number of references (for example this question) that say that the channel dies when it has no connections, and that remaining unack'd messages will be redelivered. That's

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 concurrent consumers in Spring boot

让人想犯罪 __ 提交于 2019-12-04 16:26:18
I'm using @RabbitListener annotation and SimpleRabbitListenerContainerFactory bean for parallel execution of rabbitmq messages and setting the min and max concurrent consumers in the following way : @Bean public SimpleRabbitListenerContainerFactory rabbitListenerContainerFactory() { SimpleRabbitListenerContainerFactory factory = new SimpleRabbitListenerContainerFactory(); factory.setConnectionFactory(connectionFactory()); factory.setConcurrentConsumers(MIN_RABBIT_CONCURRENT_CONSUMERS); factory.setMaxConcurrentConsumers(MAX_RABBIT_CONCURRENT_CONSUMERS); factory.setConsecutiveActiveTrigger(1);

RabbitMQ SSL Connection with spring-amqp 1.4.3

不问归期 提交于 2019-12-04 16:04:26
I am trying to connect to RabbitMQ over SSL. I have followed the RabbitMQ SSL documentation linked here https://www.rabbitmq.com/ssl.html As per RabbitMQ SSL documentation connecting using SSLv3 and TLSv1 is not recommeded due to known vulnerabilities. Due to this I have disabled these protocols on RabbitMQ as per instructions. I am using spring-amqp 1.4.3 to connect to RabbitMQ. Plese find below code snippet ApplicationContext context = new GenericXmlApplicationContext("classpath:/testConfig/testrabbit-context.xml"); RabbitTemplate template = context.getBean(RabbitTemplate.class);

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

Adding multiple listeners which will listen to different RabbitMQ queue not working

时光毁灭记忆、已成空白 提交于 2019-12-04 13:39:54
I hava following spring xml configuration <bean id="connectionFactory" class="org.springframework.amqp.rabbit.connection.CachingConnectionFactory"> <constructor-arg value="xxxxxxxx"/> <property name="username" value="xxxxx"/> <property name="password" value="xxxxx"/> <property name="channelCacheSize" value="25"/> <property name="virtualHost" value="/"/> <property name="port" value="3453"/> </bean> <rabbit:template id="tutorialTemplate" connection-factory="connectionFactory"/> <!-- 1st queue --> <rabbit:queue id="veliteQueue" name="ES_queue" durable="true" auto-delete="false" exclusive="false"/

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