I'm implementing RPC-style communication using RabbitMQ with the idea of creating asynchronous pipeline architecture. I'm working with Java Spring and AMQP.
I will perform a chain of RPC-style communication - a communication with one server will trigger another one, and another one will trigger another, until finally arriving at the end of the chain and the server starting the chain receiving the final answer. I have found two techniques which seem to suit my need:
asyncRabbitTemplate
'sconvertSendAndReceive(...)
: push using this method, once a consumer receives, trigger anotherconvertSendAndReceive(...)
and so on... a chain, until final result ends up at the server which initiated the entire process.use push/subscribe pattern, where one producer will push using
convertAndSend(...)
, a consumer will listen via@RabbitListen
and push to another which is listening and so on; in this setup, the server with the initialconvertAndSend(...)
call will receive the final response.
I'm not sure what is the difference between these approaches? When to go for one or the other? Is there a performance tradeoff? Is one requiring more programming effort than the other?