Announcement Announcement Module
Collapse
No announcement yet.
errorChannel header ignored ? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • errorChannel header ignored ?

    Hello,

    I'm trying to let SI send the message to an errorChannel when an Exception occurs in my synchronous flow.
    I use

    Code:
    <int:channel id="myErrorChannel" />
    <int:header-enricher input-channel="testQueueInChannel" output-channel="testQueueInChannel2">
            <int:error-channel value="myErrorChannel" />
        </int:header-enricher>
    to enrich the header with the errorChannel attribute.

    I have a serviceActivator called exceptiomSimulator which will throw an Exception. My expectation is that the exceptionService is called when this Exception occurs.

    Code:
    <int:service-activator id="exceptionSimulator" input-channel="testQueueInChannel2" ref="daoTest" method="addSystemRecord"/>
    
        <jms:message-driven-channel-adapter id="testQueueAdapter" container="testQueueListener"
                                            channel="testQueueInChannel" />
    
    
        <int:service-activator id="exceptionService" input-channel="myErrorChannel"
                               ref="exceptionHandler" method="handleException"/>
    However, this is not the case, the errorChannel header seems to be ignored. When debugging, I see that the errorChannel header attribute is there and correct.
    Can somebody please explain me why ?

    thnx
    IvanJoe

  • #2
    Instead of enriching the message with an errorChannel, simply add 'myErrorChannel' as the 'error-channel' attribute on the message-driven adapter.

    Comment


    • #3
      Gary, thanks for your reply.

      I understand the use of the error-channel attribute on the message-driven-adapter. However, when I use this, the exception is wrapped in the message and sent to the error-channel.
      How can I have the original message on the error-channel in case of an exception ?

      Comment


      • #4
        The original message is available as the 'failedMessage' property of the MessagingException (which is the payload of the ErrorMessage). The exception also has the exception in its cause property.

        To get back to the failedMessage, simply add a transformer on the errorChannel...

        Code:
        <int:transformer ... expression="payload.failedMessage" .../>

        Comment


        • #5
          Thanks Gary, I'll give it a try !

          Comment

          Working...
          X