I have a stand-alone process (no J2EE container) listening on a queue and sending response messages to the destination in the ReplyTo header. The application is configured to use spring's MessageListenerAdapter and DefaultMessageListenerContainer.
Everything works fine until a message is received that has an invalid destination in the ReplyTo header. In my use case, the requester has disconnected (timeout) and the temporary destination created for a reply has been closed by the broker (SwiftMQ).
When this happens, the MessageListenerAdapter throws the JMSException back to the DefaultMessageListenerContainer which attempts to redeliver the problem message again -- this continues indefinitely.
This seems like a common use case. What is the best way to handle this condition?
I have a work-around but it is certainly not pretty. My work around involves sub-classing the MessageListenerAdapter and overriding the sendResponse() method to check for certain JMSExceptions. Unfortunately it looks like I have to check the exception's message string to see if it's an exception that should be ignored.
Thanks for any helpCode:protected void sendResponse( Session session, Destination destination, Message response ) throws JMSException { try { super.sendResponse( session, destination, response ); } catch( JMSException e ) { if( e.getMessage().matches( "com.swiftmq.swiftlet.queue.UnknownQueueException: queue 'tmp\\$[^']+' is unknown" ) ) { logger.warn( "Discarding response message - " + e.getMessage() ); return; } throw e; } }
-Bryan


Reply With Quote
