Announcement Announcement Module
Collapse
No announcement yet.
Exception is not propogated to the error channel from header enricher Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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, 08:56 AM. Reason: spelling mistake

  • #2
    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.

    Comment


    • #3
      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

      Comment


      • #4
        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.

        Comment


        • #5
          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?

          Comment


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

            Comment


            • #7
              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

              Comment


              • #8
                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

                Comment


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

                  Comment


                  • #10
                    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.

                    Comment


                    • #11
                      OK here is what i am trying to do i have created a web service which gets the xml request and than using spring integration some processing is done over that request and the response is sent back to the client Here i am using soap ui(a tool to test services) to send the xml request to the service and the response is also shown in the same.

                      Now in the service i do some processing with the request to validate whether the request is valid (i have t check whether the identities that are used in the request are valid one).

                      In one of the processing step what i want to do is get the data from the request validate it and if data is valid than put it in the header and if the validation fails send a error response(i am doing this processing in header enricher, if the validation fails i throw a validation exception which is propagated to the error channel and the error response is shown in the soap ui).
                      My problem is the flow goes to the error channel and the error response is also generated but the error is not shown in the soap i get a exception like there is no response shown in the soap ui

                      The following is the exception


                      Code:
                      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)

                      Hope now the issue is clear please let me know if u need more explanation....

                      Thanks for your help. Please throw some light on this

                      Thanks
                      Shekar

                      Comment


                      • #12
                        So I am assuming you are using <int:ws-inbound-gateway>, right?

                        If so that all you need is specify an error-channel on this gateway and add a subscriber to such error-channel to receive the ErrorMessage and construct whatever response you want to send (error, soap fault etc.)

                        But by default you don't even need to do anything since the exception wil be converted to soap fault and sent bac to the caller

                        Comment


                        • #13
                          Yes i am using <int:ws-inbound-gateway>.

                          Will try it out thanks for your reply...

                          I had one more query like if i use more than one gateway inside a chain and each gateway has a error channel for it and if i get an error in one gateway will the execution stop at that point or will it got to the subsequent gateways in the chain.

                          As i see that the execution doesnt stop and it goes to the next gateway and than so on.

                          I am generating a Domsource xml in the errorhandler for errochannel in the gateways.


                          Thanks
                          Shekar

                          Comment


                          • #14
                            When you have multiple gateways in the flow you essentially segmenting (scoping) the flow, thus allowing errors to be handled within a particular segment (scope). This is a very interesting technique which I've demonstrated few weeks ago at SpringOne. Here is the code you might want to look at: https://github.com/olegz/s12gx.2011/...n/segmentation

                            Comment

                            Working...
                            X