reactor / reactor-rabbitmq

Reactor RabbitMQ
Apache License 2.0
157 stars 55 forks source link

Improve documentation of how to recover from Acknowledgement timeout #186

Open matsev opened 2 weeks ago

matsev commented 2 weeks ago

Documentation issue

Improve documentation of how to recover from Acknowledgement timeout

Motivation

It is currently unclear for me how an application can recover from an Acknowledgement timeout.

We are using the Reactor RabbitMQ client library configured with consumeManualAck. Occasionally, we observe the following error in our logs:

c.r.c.ShutdownSignalException: channel error; protocol method: #method(reply-code=406, reply-text=PRECONDITION_FAILED - delivery acknowledgement on channel 5 timed out. Timeout value used: 1800000 ms. This timeout value can be configured, see consumers doc guide to learn m...

After this statement (presumably logged by this statement), the channel is promptly shut down, the Reactive Flux is terminated and message processing stops consequently.

The client has been configured with a retry ack exception handler in an attempt to mitigate connection failures:

    Receiver receiver = RabbitFlux.createReceiver();

    ConsumeOptions consumeOptions = new ConsumeOptions()
        .exceptionHandler(new ExceptionHandlers.RetryAcknowledgmentExceptionHandler(
            Duration.ofSeconds(10), 
            Duration.ofMillis(200),
            ExceptionHandlers.CONNECTION_RECOVERY_PREDICATE
        ));

    receiver.consumeManualAck("queue_name", consumeOptions)
        .subscribe(delivery -> {
            // message processing omitted
            // acknowledge message
            delivery.ack();
        });

However, we must have overlooked something as the problem is still observed from time to time.

Desired solution

A documented way for the Receiver or Flux to recover from Acknowledgement timeouts similar to the one described above.

Considered alternatives