|
|
error-channel on JMS adaptor
Hi Guys,
I am using error-channel attribute on message driven endpoint. The flow is like
MDEndPoint--gt;SA1--gt;SA2--gt;SI Channel--gt utMessageOnResponseQueue(Topic).
If error occurs anywhere in the chain above then message goes to error-channel. The SA connected to error-channel constructs custom response and put on SI channel, which puts ultimately on responseQueue(Topic).
Behavior when acknowledge attribute is set as below on the message adaptor
if acknowledge= AUTO then original message on requestQueue gets deleted, which is what I want -- I mean the message should be removed from queue.
if acknowledge= transacted/client then original message on requestQueue DO NOT gets deleted, which is what I don't want. As, I would not like to keep the failed message there on input request queue or would like to route the message to some ERROR queue.
For all above cases, log entries are below.Code:
[org..jms.listener.DefaultMessageListenerContainer#1-4][org..jms.listener.DefaultMessageListenerContainer] Execution of JMS message listener failed, and no ErrorHandler has been set.
org..integration.MessagingException: failed to send message
at org..integration.gateway.MessagingGatewaySupport.send(MessagingGatewaySupport.java:193)
Code:
lt;jms:message-driven-channel-adapter id=quot;jmsRequestInquot; destination=quot;requestQueuequot; channel=quot;priorityMessageChannelInquot; max-concurrent-consumers=quot;5quot;
acknowledge=quot;transactedquot; connection-factory=quot;jmsQueueConnectionFactoryquot; extract-payload=quot;truequot; header-mapper=quot;customHeaderMapperquot; max-messages-per-task=quot;5quot; error-channel=quot;busErrorChannelquot;/gt;
Please let me know what I need to set or I am missing so that I get the original message deleted/consumed from the requestQueue once error-channel activator has done the job. And, I do not want to use AUTO acknowledge mode as I want message to be removed after listener execution.
Thanks
Can you clarify what you mean by the two #1 items you've listed there?
Thanks,
Mark
Mark, I edited the two points in my first message. please let me know if it is clear now. Sorry for the ambiguity.
If you are specifying acknowledge=transacted, it should only rollback if an Exception is propagated. Otherwise, the transaction should commit and the message should be removed from the Queue at that point. If you are seeing different behavior, can you provide a bit more detail, perhaps some configuration excerpts?
Thanks,
Mark
Hi Mark,
Please see the config below. I am throwing an exception from messageUnMarshallingTransformer and that ultimately comes to
Code:
jms:message-driven-channel-adapter id=quot;jmsPriorityQueueMessagesInquot;
,
which has error-channel defined and hence should have removed the message from queue. But does not seem to be the behavior.
Please let me know if you need more details. Hope I am not missing something.
Thanks
Code:
lt;!--Error channel --gt;
lt;si:channel id=quot;busErrorChannelquot;gt; lt;si:interceptorsgt;
lt;si:ref bean=quot;channelMessageInterceptorquot;/gt;
lt;/si:interceptorsgt;lt;/si:channelgt;
lt;!-- SA for handling messaages arriving on Error channel --gt;
lt;si:service-activator ref = quot;errorMessageHandlerquot; method=quot;messageHandlerquot;
input-channel=quot;busErrorChannelquot; output-channel=quot;responseOutputChannelquot;/gt;
lt;!-- custom erro handler bean which transforms the message and sends respons back on the
responseOutputChannel --gt;
lt;bean id=quot;errorMessageHandlerquot; class=quot;com.abc.exception.ErrorMessageHandlerquot;/gt;
lt;!--
channel adaptor to send the response message on the Topic
--gt;
lt;jms utbound-channel-adapter id=quot;jmsResponsOutquot; destination=quot;responseTopicquot;
channel=quot;responseOutputChannelquot; connection-factory=quot;jmsTopicConnectionFactoryquot;gt;
lt;/jms utbound-channel-adaptergt;
lt;!-- Incoming messsage request queue --gt;
lt;jms:message-driven-channel-adapter id=quot;jmsPriorityQueueMessagesInquot; destination=quot;priorityQueuequot;
channel=quot;unmarshallRequestMessageChannelquot; max-concurrent-consumers=quot;1quot; acknowledge=quot;transactedquot;
connection-factory=quot;jmsQueueConnectionFactoryquot; extract-payload=quot;truequot; header-mapper=quot;headerMapperquot;
max-messages-per-task=quot;5quot; error-channel=quot;busErrorChannelquot;/gt;lt;!-- Unmarshaller definition for requests --gt;
lt;si:transformer id=quot;messageUnmarshallerquot; input-channel=quot;unmarshallRequestMessageChannelquot;
output-channel=quot;controllerInChannelquot; ref=quot;messageUnMarshallingTransformerquot; gt;lt;/si:transformergt;If i understand correctly the errors should be delegated to ErrorMessageHandler which is subscribed to the 'busErrorChannel'. There the ErrorMessage is transformed to what?
So, what i do on ErrorMessageHandler is:
1) Extract the failed message usingCode:
MessagingException exception = (MessagingException) messageInput
.getPayload();
failedMessage= exception.getFailedMessage();
Response response = ressponseBuilder.createSpbResponse(failedMessage, exceptionMessage);
String responseMessage = (String)messageMarshallingTransformer.doTransform(response, messageTypeStr);
return MessageBuilder.withPayload(responseMessage).setHeader(quot;statusquot;,
response.getResponseStatus().toString()).
copyHeadersIfAbsent(failedMessage.getHeaders()).build();
2) And, then construct a custom String XML response and put on the responseOutputChannel, which has a outbound channel adaptor subscriber putting message on the Topic. I created a consumer/listener on Topic and I see the message reaching the response Topic but the request message remains on request queue.
Well, i just took your configuration and tried to simulate your scenario with ActiveMq and it behaves as I expected where the error-channel and handler attached to it essentially intercepts the error which if you handle it properly (you do) will not be propagated to JMS. In other words JMS has no idea that exception has happened downstream so I am a bit surprised. Could you verify that what you showing us is all it is there and that your error handling logic itself does not result in exception?
I would have thought so. But that would mean the message would not have travelled to response Topic, no?
May be something to do with Tibco EMS servers? ActiveMq seems to be nice but Tib world has always made me unhappy
P.S:
Oleg, you still in London or back to USA? I am near London Bridge, can catch up for a quick one in evening.
I am still surprised regardless of Tibco or ActiveMq. The main point is how does Tibco knows that there is an exception. The error-channel pattern should essentially suppress the exception thus making Tibco completely unaware of it.
P.S. I am still in London. Let me see how my time is and i'll let you know through the email. |
|