Results 1 to 5 of 5

Thread: errorChannel header ignored ?

  1. #1
    Join Date
    Aug 2008
    Posts
    11

    Default 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. #2
    Join Date
    Mar 2010
    Location
    Gtr Philadelphia, PA
    Posts
    2,015

    Default

    Instead of enriching the message with an errorChannel, simply add 'myErrorChannel' as the 'error-channel' attribute on the message-driven adapter.
    Gary P. Russell
    Spring Integration Team
    SpringSource, a division of VMware

  3. #3
    Join Date
    Aug 2008
    Posts
    11

    Default

    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 ?

  4. #4
    Join Date
    Mar 2010
    Location
    Gtr Philadelphia, PA
    Posts
    2,015

    Default

    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" .../>
    Gary P. Russell
    Spring Integration Team
    SpringSource, a division of VMware

  5. #5
    Join Date
    Aug 2008
    Posts
    11

    Default

    Thanks Gary, I'll give it a try !

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •