How to correctly receive all queue messages from RabbitMQ in Spring?

I use Spring, Spring -Websocket, STOMP for my application and RabbitMQ as a broker. I need to record all messages going through RabbitMQ tables in Postgresql. I know that I can write @MessageMapping in Spring and write there, but my problem is that some clients talk to RabbitMQ directly through the MQTT protocol, and Spring does not yet support it ( https://jira.spring.io/browse/ SPR-12581 ). In addition, browser clients discuss Spring using RabbitMQ using the STOMP protocol.

RabbitMQ allows you to track all messages using the Firehose tracer. How to listen to amq.rabbitmq.trace theme from Spring? Or do I need to write a separate Java application as a consumer?

+6
source share
1 answer

Spring AMQP is for you!

Using the appropriate template (for example, publish.# ), You bind some user queue to this amq.rabbitmq.trace and configure SimpleMessageListenerContainer to receive messages from this queue.

This can be done even with a fairly simple configuration: @EnableRabbit and @RabbitListener for some POJO method. Anyway, Binding @Bean should be there to bind your turn to this exchange.

+1
source

Source: https://habr.com/ru/post/987653/


All Articles