Page 1 of 2 12 LastLast
Results 1 to 10 of 14

Thread: Exception is not propogated to the error channel from header enricher

  1. #1
    Join Date
    Nov 2011
    Posts
    9

    Default Exception is not propogated to the error channel from header enricher

    Hi,

    I am using Spring Integration in my project.

    Below is the part of the configuration that i am using in my project whenever there is an exception in the header enricher it is not propogated to the error channel

    Code:
    <header-enricher>
      			<header name="Information" method="extractInformation" ref="infoExtractor" />
      			<error-channel ref="InfoErrorChannel"/>
      		</header-enricher>
      		
    		<transformer input-channel="InfoErrorChannel">
    			<beans:bean class="com.test.integration.ErrorBuilder">
    				<beans:property name="description" value="Error in info extractor" />
    			</beans:bean>
    		</transformer>

    Kindly throw some light on this

    Thanks,
    Shekar
    Last edited by shekar; Nov 4th, 2011 at 07:56 AM. Reason: spelling mistake

  2. #2
    Join Date
    Oct 2005
    Location
    Boston, MA
    Posts
    2,844

    Default

    The "error-channel" sub-element of header-enricher is simply setting that header value on the Message. So, if an error occurs in the header-enricher itself, it occurs before the error-channel header has been set on the resulting Message.

  3. #3
    Join Date
    Nov 2011
    Posts
    9

    Default

    Thanks for your reply Mark what would be the correct way to do it, i want to propogate the error to the error channel when something goes wrong while enriching the header

    Thanks
    Shekar

  4. #4
    Join Date
    Oct 2011
    Location
    Mumbai, India
    Posts
    213

    Default

    Unless you use a DirectChannel (where the send and receive happens in the same thread and hence the exception thrown by the header enricher will be caught by the thread calling send) all exceptions thrown by header enricher will be send to the channel "errorChannel"
    Have a MessageHandler for this channel and you will get an ErrorMessage with the exception.

  5. #5
    Join Date
    Nov 2011
    Posts
    9

    Default

    Somehow i was able to get the error to be propagetd to the error channel now i get the following exception and the error is not shown in the front end



    2011-11-08 09:38:31,791 WARN [org.springframework.integration.channel.MessagePub lishingErrorHandler] - Error message was not delivered.
    org.springframework.integration.support.channel.Ch annelResolutionException: no output-channel or replyChannel header available
    at org.springframework.integration.handler.AbstractRe plyProducingMessageHandler.sendReplyMessage(Abstra ctReplyProducingMessageHandler.java:166)
    at org.springframework.integration.handler.AbstractRe plyProducingMessageHandler.produceReply(AbstractRe plyProducingMessageHandler.java:125)
    at org.springframework.integration.handler.AbstractRe plyProducingMessageHandler.handleResult(AbstractRe plyProducingMessageHandler.java:119)
    at org.springframework.integration.handler.AbstractRe plyProducingMessageHandler.handleMessageInternal(A bstractReplyProducingMessageHandler.java:101)
    at org.springframework.integration.handler.AbstractMe ssageHandler.handleMessage(AbstractMessageHandler. java:78)
    at org.springframework.integration.dispatcher.Unicast ingDispatcher.doDispatch(UnicastingDispatcher.java :110)
    at org.springframework.integration.dispatcher.Unicast ingDispatcher.dispatch(UnicastingDispatcher.java:9 7)
    at org.springframework.integration.channel.AbstractSu bscribableChannel.doSend(AbstractSubscribableChann el.java:61)
    at org.springframework.integration.channel.AbstractMe ssageChannel.send(AbstractMessageChannel.java:157)
    at org.springframework.integration.channel.MessagePub lishingErrorHandler.handleError(MessagePublishingE rrorHandler.java:83)
    at org.springframework.integration.util.ErrorHandling TaskExecutor$1.run(ErrorHandlingTaskExecutor.java: 55)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run Task(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:619)


    What is the reason for this and how can i resolve it?

  6. #6
    Join Date
    Nov 2011
    Posts
    9

    Default

    <header-enricher>
    <error-channel ref="InfoErrorChannel overwrite="true"/>
    </header-enricher>
    Have added this for adding the error channel to header enricher

  7. #7
    Join Date
    Nov 2011
    Posts
    9

    Default

    Thanks Amol.


    <transformer input-channel="InfoErrorChannel">
    <beans:bean class="com.test.integration.ErrorBuilder">
    <beansroperty name="description" value="Error in info extractor" />
    </beans:bean>
    </transformer>
    The above is the handler when the error occurs after writing the error channel separately. While debugging the call goes to thw transformer i have written but i dont get any o/p in the ui

  8. #8
    Join Date
    Nov 2011
    Posts
    9

    Default

    The same error channel works in fine when defined in gateway

    the logs in gateway is as follows

    Code:
    ERROR [org.springframework.integration.handler.LoggingHandler] - [Payload=org.springframework.integration.transformer.MessageTransformationException: org.springframework.integration.MessageHandlingException: org.milyn.validation.ValidationException: Error in transformation.
    ][Headers={timestamp=1320756798972, id=aa68b0c9-4e95-4ce1-9d1b-e61ad31410da, history=transform-error,errorlogger,errorlogger.adapter, errorChannel=org.springframework.integration.core.MessagingTemplate$TemporaryReplyChannel@18cdeb2, replyChannel=org.springframework.integration.core.MessagingTemplate$TemporaryReplyChannel@18cdeb2}]
    but when the same is defined in header enricher it doesnt work and gives the following log

    Code:
    2011-11-08 13:56:16,321 ERROR [org.springframework.integration.handler.LoggingHandler] - [Payload=org.springframework.integration.transformer.MessageTransformationException: org.springframework.integration.MessagingException: failed to transform message headers][Headers={timestamp=1320756976321, id=b7160d60-e5ed-4b41-97e2-0546d7364dc9, history=transform-error,errorlogger,errorlogger.adapter}]

    I can see that here we dont find the default error channel and reply channel i guess this is the reason for it not working.

    How can i set it.

    Thanks
    Shekar

  9. #9
    Join Date
    Jan 2008
    Location
    Mohnton, PA USA (that's near Philadelphia)
    Posts
    2,148

    Default

    Could you please explain your use case. What are you trying to accomplish?

  10. #10
    Join Date
    Oct 2011
    Location
    Mumbai, India
    Posts
    213

    Default

    Yes, your detailed use case will help people answer in a better way.

    However, since you mentioned UI, please give some details about that too.
    Unless you use DirectChannel, your send of the message to the channel on the server side and the processing of the subsequent components will happen in separate threads. That is, the send to the channel will happen and that thread will return immediately. Hence, just in case any error occurs and you receive an ErrorMessage from the error channel, you will need some kind of push mechanism to send the error back to the right client.

Tags for this Thread

Posting Permissions

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