May 30th, 2012, 08:20 AM
how to handle MessageConversionException in amqp inbound gateway(consumer)
Hi I have configured an amqp gate way with my own custom message converter.
When ever a messageconversion exception is thrown, I am seeing that the gateway is not sending a NACK or ACK to the broker and
the message is kept in the queue assuming that other consumers might pick this message up. Other consumers also does the same and these message which caused message conversion exception or neither processed nor removed from the Queue.
What would be a good way of gracefully handling these message at the consumer side. I don want to handle this at broker by configuring x-message-ttl or dead-letter-exchange or an alternate-exchange.
I would like to send a error message with a error code to the producer in such scenario.
My initial thought was to configure a error handler as well through the message listener container and send an error message to the producer, but unfortunately the error handler will not have enough context to know where it should dispatch the message (this is because the error handler interface is void handleError(Throwable t)).
I would not be able to pass context information like reply queue name, exchange name etc to my custom error handler which can produce a error message for the message producer.
Since the messageListenerContainer in AmqpInboundGateway is private final, i cannot even extend AmqpInboundGateway and set my own implementation of MessageListener instead of the ananymous messageListener implementation.
Would it be possible to make the messageListenerContainer protected in the future release of spring-integration-amqp?
Or can you suggest me any other way of gracefully handled MessageconversionException in the consumer end?
P.S configuring errorChannel will be of no help because the MessageconversionException happens at the listener container level and the message is not even handed over to SI completely.
Tags for this Thread