Announcement Announcement Module
Collapse
No announcement yet.
Handling Null return value from service activator Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Handling Null return value from service activator

    hi everyone,


    I want to handle the null return value from service activator .Let me elaborate

    Below is the snippet of conf

    Code:
    <int:service-activator id="importFileSA" input-channel="startInterfaceChannel" ref="httpChannel" method="read" output-channel="importFileChannel"></int:service-activator>
    
    
    
    <int:router id="importFileRouter" input-channel="importFileChannel" ref="CheckImportFile" method="checkForFile"></int:router>
    The method read can either return a Inputstream or a inputstream which is null .


    My router code is

    Code:
    public String checkForFile(Inputstream check)
    	{
    		if(check!=null)
    		{
    			System.out.println("In router not equal to null");
    			return "importFileChannel";
    		}
    		else
    		{
    			System.out.println("In the router ret sta");
    			return "retriveStatusChangeChannel";
    		}
    	}
    When the read method return inputstream its fine its calling the method in the router but when it returns a inputstream with null its not calling the router method .Please help

  • #2
    You don't need to do that since we don't allow Messages with NULL payloads so if any endpoint returns null it simply means that no message will be generated therefore the code you pasted above is unnecessary. In other words the framework handles it for you.

    Comment


    • #3
      but i want to send a message to retriveStatusChangeChannel when the return value from read method is null .How do i handle this

      Comment


      • #4
        well, then simply return something from the service activator (e.g., String "Could not obtain input stream") and than you can use payload-type-router where you can route based on InputStream and String

        Comment


        • #5
          which is the namespace that i have to add to use mapping element inside the payload type router coz its giving an error ""cvc-complex-type.2.4.a: Invalid content was found starting with element 'mapping'. One of '{"http://
          www.springframework.org/schema/integration"poller, "http://www.springframework.org/schema/
          integration":mapping}' is expected.

          Comment


          • #6
            Its the core namespace. Please read this section http://static.springsource.org/sprin...mplementations

            Comment


            • #7
              Thanks a lot

              Comment

              Working...
              X