spring-amqp

Spring AMQP StatefulRetryOperationsInterceptor not used

我的梦境 提交于 2019-12-04 09:34:01
I am trying configure spring amqp to only retry a message a defined amount of times. Currently a message that fails e.g. because of a DataIntegrityViolationException is redelivered indefinitely. According to the documentation here I came up with the following configuration @Bean public StatefulRetryOperationsInterceptor statefulRetryOperationsInterceptor() { return RetryInterceptorBuilder.stateful() .backOffOptions(1000, 2.0, 10000) // initialInterval, multiplier, maxInterval .maxAttempts(3) .messageKeyGenerator(message -> UUID.randomUUID().toString()) .build(); } This does not seem to be

How do I convert from a Json Byte Array for AMQP in Spring Boot?

牧云@^-^@ 提交于 2019-12-04 06:04:12
问题 Following this, I have this code @Bean open fun messageConverter(om: ObjectMapper): MessageConverter { return Jackson2JsonMessageConverter(om) } @Bean open fun rabbitListenerContainerFactory(cf: ConnectionFactory, mc: MessageConverter ): SimpleRabbitListenerContainerFactory { val factory = SimpleRabbitListenerContainerFactory() factory.setConnectionFactory(cf) factory.setMessageConverter(mc) return factory } @Bean open fun builder(): Jackson2ObjectMapperBuilderCustomizer { return

Single Queue, multiple @RabbitListener but different services

前提是你 提交于 2019-12-04 04:16:47
问题 Is it possible to have a single @RabbitListener, e.g: @RabbitListener(queues = STORAGE_REQUEST_QUEUE_NAME) public FindApplicationByIdResponse findApplicationById(FindApplicationByIdRequest request) { return repository.findByUuid(request.getId()) .map(e -> new FindApplicationByIdResponse(conversionService.convert(e, Application.class))) .orElse(new FindApplicationByIdResponse(null)); } @RabbitListener(queues = STORAGE_REQUEST_QUEUE_NAME) public PingResponse ping(PingRequest request) { return

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 integration with Rabbit AMQP for “Client Sends Message -> Server Receives & returns msg on return queue --> Client get correlated msg”

与世无争的帅哥 提交于 2019-12-04 02:30:03
问题 I am able to write a java program using Rabbit Java API's doing the following: Client sends message over Rabbit MQ exchange/queue with correlation Id (Say UUID - "348a07f5-8342-45ed-b40b-d44bfd9c4dde"). Server receives the message. Server sends response message over Rabbit MQ exchange/queue with the same correlation Id - "348a07f5-8342-45ed-b40b-d44bfd9c4dde". Client received the correlated message only in the same thread as 1. Below is the Send.java and Recv.java using Rabbit APIs. I need

spring amqp rabbitmq MessageListener not working

自古美人都是妖i 提交于 2019-12-03 21:25:18
I am trying to use rabbitmq using spring amqp, below is my configuration. <rabbit:connection-factory id="rabbitConnectionFactory" port="${rabbitmq.port}" host="${rabbitmq.host}" /> <rabbit:admin connection-factory="rabbitConnectionFactory" /> <rabbit:queue name="${rabbitmq.import.queue}" /> <rabbit:template id="importAmqpTemplate" connection-factory="rabbitConnectionFactory" queue="${rabbitmq.import.queue}" /> <beans:bean id="importExchangeMessageListener" class="com.stockopedia.batch.foundation.ImportMessageListener" /> <rabbit:listener-container connection-factory="rabbitConnectionFactory"

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

喜欢而已 提交于 2019-12-03 13:16:10
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 not the behaviour I see - instead I get a growing list of channels marked IDLE and a growing list of

How can I transmit via MQTT and Receive on AMQP with RabbitMQ and Spring-AMQP

五迷三道 提交于 2019-12-02 21:20:54
问题 So I've gotten MQTT -> MQTT and AMQP -> AMQP to work; the translation of MQTT -> AMQP doesn't seem to be working somewhere though. Here's my test, it passes if my "listener" is also in MQTT using paho, but this rabbitmq implementation doesn't. @SpringBootTest @SpringJUnitConfig internal open class ProvisioningTest @Autowired constructor( private val mqtt: IMqttAsyncClient, private val mapper: ObjectMapper ) { @Test fun provision() { val entity = Foley( rfid = UUID.randomUUID().toString(), )

spring amqp enable retry by configuration and prevent it according to a specified exception

大兔子大兔子 提交于 2019-12-02 17:53:01
问题 I have the following two cases In case of ExceptionA : retrying for finite number of times and finally when number of retrials exhausted, message is written in a dead letter queue In case of ExceptionB : simply, message should be written to dead letter queue I want to support the two cases on the same listener container factory and the same queue. I already have the following configuration to support case 1 successfully: @Bean public RetryOperationsInterceptor workMessagesRetryInterceptor() {

How do I convert from a Json Byte Array for AMQP in Spring Boot?

痴心易碎 提交于 2019-12-02 11:31:04
Following this , I have this code @Bean open fun messageConverter(om: ObjectMapper): MessageConverter { return Jackson2JsonMessageConverter(om) } @Bean open fun rabbitListenerContainerFactory(cf: ConnectionFactory, mc: MessageConverter ): SimpleRabbitListenerContainerFactory { val factory = SimpleRabbitListenerContainerFactory() factory.setConnectionFactory(cf) factory.setMessageConverter(mc) return factory } @Bean open fun builder(): Jackson2ObjectMapperBuilderCustomizer { return Jackson2ObjectMapperBuilderCustomizer { it.modules(JavaTimeModule(), KotlinModule()) it.featuresToDisable