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

  • Question about errorChannel

    Hi, I have a my own implementation of <router>. It has a method that returns a String. I know that that String is the name of the channel it will put the message to. If the channel does not exist, it will throw a org.springframework.integration.core.MessagingExce ption.

    Is there a way that instead of throwing an Exception, the message will be put in the default errorChannel?

    I tried to create a class that handles error from the errorChannel but it is not called when an Exception occur.

    Code:
    <si:service-activator input-channel="errorChannel" ref="errorHandlerBean" method="errorCaught"/>
    
    public class ErrorHandler {
    	
    	public void errorCaught(Object message) {
    		System.out.println("error caught!");
    	}
    
    }

  • #2
    Can you try setting the "ignore-channel-name-resolution-failures" attribute on your <router> to TRUE?

    Comment


    • #3
      I tried the "ignore-channel-name-resolution-failures" attribute set to TRUE and the Exception did not show up. But still, the ErrorHandler.errorCaught() did not execute.

      Are my configurations correct?

      Code:
      <!-- ROUTER -->
      <si:channel id="toBeRouted"/>
      <si:router 
          id="requestRouter" 
          ref="routerBean" 
          input-channel="toBeRouted" 
          method="route" 
          ignore-channel-name-resolution-failures="true"
      />
      
      <!-- ERROR HANDLER -->
      <si:service-activator 
          input-channel="errorChannel" 
          ref="errorHandlerBean" 
          method="errorCaught"
      />
      Please do note that I did not create an errorChannel. I used the default.

      Comment


      • #4
        You should also specify default-output-channel pointing to an 'errorChannel'
        Here is the example:
        Code:
        <int:router input-channel="inputChannel" default-output-channel="errorChannel" ignore-channel-name-resolution-failures="true" >
        		<bean class="org.springframework.integration.router.config.ErrorChannelRoutingTests.SampleRouter"/>
        </int:router>
        Now your subscriber to 'errorChannel' will be triggered.

        Comment


        • #5
          That did the job! Thanks a lot! It seems that I always need to put the default-output-channel and ignore-channel-name-resolution-failures when I need to use the errorChannel

          Thanks again!

          Comment

          Working...
          X