rmqcpp icon indicating copy to clipboard operation
rmqcpp copied to clipboard

How to disable noAck while utilizing direct reply-to functionality?

Open Pasick opened this issue 1 year ago • 1 comments

I'm trying to implement the Direct Reply-to feature:

class ReplyToMessageConsumer {
  private:
    bool processMessage(const rmqt::Message& message)
    {
        std::string payload((const char *)message.payload(), message.payloadSize());
        std::cout << "Message was consumed: " << payload << std::endl;
        return true;
    }

  public:
    ReplyToMessageConsumer() {}
    void operator()(rmqp::MessageGuard& messageGuard)
    {
        if (processMessage(messageGuard.message())) {
            messageGuard.ack();
        }
        else {
            messageGuard.nack();
        }
    }
};
...
rmqt::QueueHandle replyToQueue = topology.addPassiveQueue("amq.rabbitmq.reply-to");
rmqt::Result<rmqa::Consumer> replyToConsumerResult =
    vhost->createConsumer(
        topology,
        replyToQueue,
        ReplyToMessageConsumer(),
        replyToConsumerConfig
    );

However RMQ broker reports an error:

2024-02-06 12:01:03.888100+00:00 [error] <0.1343.0> operation basic.consume caused a channel exception precondition_failed: reply consumer cannot acknowledge

How do I set noAck = false?

Pasick avatar Feb 06 '24 12:02 Pasick

II think we'd need to support this use case better since I believe: 'The RPC client must consume in the automatic acknowledgement mode.' excerpt from https://www.rabbitmq.com/docs/direct-reply-to#limitations

Because auto-ack isn't what we consider "reliable message delivery" this would be an extension to the scope of this library.

willhoy avatar Jul 17 '24 13:07 willhoy