0

I have a Spring JMS project and I need to catch certain types of Exceptions, convert them to an Error object, and then send them to a custom destination. I could use a try/catch as shown below and this should work, but I would like to know if there is a Spring class out there that I can use where I can put this kind of code, so that it is out of the way. I was looking at the ErrorHandler Interface which looks promising, but I need some of the headers that come in from the inbound request, which is not suitable for the handleError(Throwable t) method. Any suggestions, or thoughts are very much appreciated!

    ...
    public void onMessage(Message<AnObject> inboundMsg, Map<String,Object> headers){
        try{
            someServiceCall(inboundMsg);
        }catch(SomeException se){
            AnError error = convertToError(se);
            jmsMessagingTemplate.convertAndSend("error-destination",error,headers);
        }
    }
    ...

Thank you very much in advance,

Juan

JCB
  • 341
  • 5
  • 18

1 Answers1

0

It looks like I should be going with the approach that I laid out above. The answer is in the following thread.

spring jms error handler access to message.

JCB
  • 341
  • 5
  • 18