简体   繁体   中英

Broker Acknowledgement Rabbit MQ in Micronaut 2.2.1 not woking

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM