'Timeout of the producer confirmation mechanism

I have a question, that is, how to set the time of the producer's message acknowledgement mechanism?
The rabbitMQ producer creates the good news and sends it successfully. My question is: does the producer validation mechanism have a timeout to prove that it has failed?



Solution 1:[1]

See the documentation https://docs.spring.io/spring-amqp/docs/current/reference/html/#template-confirms

You can wait on the future in the correlation data with a timeout...

...

Starting with version 2.1, the CorrelationData object has a ListenableFuture that you can use to get the result, instead of using a ConfirmCallback on the template. The following example shows how to configure a CorrelationData instance:

CorrelationData cd1 = new CorrelationData();
this.templateWithConfirmsEnabled.convertAndSend("exchange", queue.getName(), "foo", cd1);
assertTrue(cd1.getFuture().get(10, TimeUnit.SECONDS).isAck());

...

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Gary Russell