Reputation: 726
I'm using publisher confirms with Amqp.outboundAdapter, and I want to manage exception cases correctly.
According to the following adapter;
// code
IntegrationFlows
.from("inputChannel")
.handle(Amqp.outboundAdapter(rabbitTemplate)
.confirmAckChannel(ackChannel())
.confirmNackChannel(nackChannel())
);
Thanks.
Upvotes: 0
Views: 96
Reputation: 121542
How can I catch network/connection failures
For that purpose you can add a Request Handler Advice, e.g. an ExpressionEvaluatingRequestHandlerAdvice
or RequestHandlerRetryAdvice
: https://docs.spring.io/spring-integration/reference/html/#message-handler-advice-chain
Or that one is just going to be thrown to the caller thread upstream, where you can handle it with the plain try..catch
or an errorChannel
if that is applicable for your flow.
How can I catch exceptions which are thrown in ack, and nack channels?
These channels are starters for their specific flows. To avoid throwing exceptions into the ConfirmCallback
, you should consider to make then as QueueChannel
or an ExecutorChannel
. This way you will do a thread shifting and those flows should have their own error handling. It could be the same way with a request handler advice chain or an errorChannel
.
How the timeout be configured for confirms?
Looks like there is no such an option like timeout for confirms to configure.
However you can expire them using RabbitTemplate
API:
/**
* Gets unconfirmed correlation data older than age and removes them.
* @param age in milliseconds
* @return the collection of correlation data for which confirms have
* not been received or null if no such confirms exist.
*/
@Nullable
public Collection<CorrelationData> getUnconfirmed(long age) {
Upvotes: 1