Is there a way to intercept messages once template.convertAndSend is called, before the message is delivered to RabbitMQ.
Also any way to intercept the message before reaching the handler?
I can handle the message using PostProcessor for publisher, but prefer to use interceptor.
public class TestPostProcessor implements MessagePostProcessor {
@Autowired
Tracer defaultTracer;
@Override
public Message postProcessMessage(Message message) throws AmqpException {
//.....
//....
return message;
}
}
Any suggestions?
Group: SpringFramework AMQP It provides high-level abstractions for sending and receiving messages. Last Release on Sep 19, 2022.
Helper class that simplifies synchronous RabbitMQ access (sending and receiving messages). The default settings are for non-transactional messaging, which reduces the amount of data exchanged with the broker. To use a new transaction for every send or receive set the channelTransacted flag.
AMQP stands for Advances Messaging Queing Protocol. The AMQP listener can be used to read from an AMQP destination. This destination can be a queue or topic in an AMQP environment. The connection factory determines which AMQP environment will be used.
@EnableRabbit enables detection of RabbitListener annotations on any Spring-managed bean in the container.
MessagePostProcessor
is a form of interceptor.
There are two ways to invoke one - use one of the overloaded convertAndSend()
methods that take an MPP as an argument, or add one or more to the RabbitTemplate
using setBeforePublishPostProcessors()
.
You can also intercept received messages using the setAfterReceivePostProcessors()
which is invoked before the received message is returned from a receive()
method.
The listener container also supports MPPs after receiving and before delivery to the listener via its setAfterReceivePostProcessors()
method.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With