I am trying to perform Request/Response Pattern with Micronaut AMQP, with below diagram
Producer
@RabbitClient(ProductTopicConstants.FETE_BIRD_EXCHANGE)
@RabbitProperty(name = "replyTo", value = "amq.rabbitmq.reply-to")
public interface IProductProducer {
@Binding(ProductTopicConstants.GET_FREE_TEXT_SEARCH)
Flowable<Product> findFreeText(String text);
}
Listener
@RabbitListener
public class ProductListener {
@Queue(ProductTopicConstants.GET_FREE_TEXT_SEARCH)
public Flowable<Product> findByFreeText(String text) {
LOG.info(String.format("Listener --> Listening value = %s", text));
return Flowable.fromPublisher(repository.getCollection("product", Product.class)
.find(new Document("$text",
new Document("$search", text)
.append("$caseSensitive", false)
.append("$diacriticSensitive", false)
)));
}}
For the request it is working, find how do I perform the response back to the controller and how to implement this pattern asynchronously with a message broker using the AMQP protocol and micronaut.