Broker Acknowledgement Rabbit MQ in Micronaut 2.2.1 not woking

180 Views Asked by At

I am trying to get the Broker Acknowledgement using RabbitMQ in Micronaut.

Listener

@RabbitListener
public class ProductListener {

    @Queue(ProductTopicConstants.GET_PRODUCTS)
    public String find(String text) {
        return text.toUpperCase();
    }
}

Controller

@Get(value = "/{text}", single = true)
    public Maybe<String> Find(String text) {
        iproductProducer.find(text).subscribe(item ->{
            System.out.println(item);
        });
        return null;
    }

Producer

@RabbitClient(ProductTopicConstants.FETE_BIRD_EXCHANGE)
public interface IProductProducer {
    @Binding(ProductTopicConstants.GET_PRODUCTS)
    Maybe<String> find(String text);
}

UPDATE - #1

@RabbitClient(ProductTopicConstants.FETE_BIRD_EXCHANGE)
    public interface IProductProducer {
        @Binding(ProductTopicConstants.GET_PRODUCTS)
        Completable find(String text);
    }

As per the documentation

Client methods support two return types, void and a reactive type. If the method returns void, the message will be published and the method will return without acknowledgement. If a reactive type is the return type, a "cold" publisher will be returned that can be subscribed to.

But in the controller System.out.println(item); the acknowledgment never gets.

1

There are 1 best solutions below

2
On

You aren't looking for broker acknowledgement. You are describing RPC. The documentation clearly states how to set this up. From what I can tell, it seems you are missing @RabbitProperty(name = "replyTo", value = "amq.rabbitmq.reply-to") on the client.