Announcement Announcement Module
Collapse
No announcement yet.
Error Handling Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Error Handling

    Hi,

    In my application,

    Gateway has a publisher subscribe channel as an input channel.
    This gateway is connected to a bridge which sends message to executor channel which is received by a service activator . Now this can probably through exceptions which would be in separate threads.

    Ques : If any error occurs in the service activator, errorchannel (of spring) will catch this error?
    Ques : If I define a service activator with errorchannel as input channel and output channel same as of reply-channel of gateway, is this correct way of handling the error? If not, please suggest.


    Many Thanks,
    Jubin

  • #2
    When asking questions like this, it's better to include the config rather than describing it in text.

    When using a taskExecutor (asynch handoff), you can provide an ErrorHandler; the default ErrorHandler is a MessagePublishingErrorHandler which will send the ErrorMessage to the default 'errorChannel'.

    The ErrorMessage has a MessagingException as its payload; this object has the failedMessage (in the 'failedMessage' property) and the original exception in the 'cause'. You can't just send the ErrorMessage to the gateway, you would need to extract the failedMessage and use that as the basis of your reply.

    Comment


    • #3
      Thanks for your help and suggestion Gary.

      Below is my configuration :
      Code:
       <gateway id="searchGateway" 
              service-interface="abc.xyz.SearchGateway" 
              default-reply-channel="returnChannel"
              default-request-timeout="${searchGateway.timeout}"
          />
      
      	<bridge input-channel="searchChannel" output-channel="methodASearch"/>
      	<bridge input-channel="searchChannel" output-channel="methodBSearch"/>
      	
          <service-activator 
             input-channel="methodASearch"
             output-channel="outputChannel"
             ref="aEndpoint" 
             method="processMessage" />
          
          <service-activator 
             input-channel="methodBSearch" 
             output-channel="outputChannel"
             ref="bEndpoint" 
             method="processMessage" />
          
      <publish-subscribe-channel id="searchChannel" apply-sequence="true"/>
          	
      <channel id="methodASearch" >
              <dispatcher task-executor="methodASearchExecutor"/>
          </channel>
          <channel id="methodBSearch" >
              <dispatcher task-executor="methodBSearchExecutor"/>
          </channel>
      If any error occurs in the 2 service activators mentioned above, still the error will be sent to default 'errorChannel' ? Sorry for asking again, but as you rightly said, I must have had mentioned my config to be exact.

      I understood the later half where you mentioned that Gateway bit.

      Many Thanks,
      Jubin
      Last edited by Gary Russell; Feb 13th, 2013, 11:24 AM.

      Comment


      • #4
        Right; your two search channels have a task executor with default configuration - this means that a default MessagePublishingErrorHandler will be assigned to each (the supplied task executors get wrapped in a ErrorHandlingTaskExecutor). This will cause ErrorMessages to be sent to the default errorChannel.

        By default, the errorChannel is a <publish-subscribe-channel/> with an (ERROR) LoggingHandler subscribed to it. If you subscribe to the default errorChannel both your service, and the logging adapter will get the error. You can override this behavior by explicitly defining an 'errorChannel'.

        You can also wrap your task executor in your own ErrorHandlingTaskExecutor, with a MessagePublishingErrorHandler that sends the error to a channel with some other name.

        Comment


        • #5
          Thanks a lot Gary. I have got my answer. Thanks for explaining.

          My concepts have gone stronger now. I have gone through Spring Integration Ref 2.2 . Its really wonderful and explained in a very simple language. Thanks for it and you help.

          Regards,
          Jubin

          Comment

          Working...
          X