Results 1 to 7 of 7

Thread: Handling Null return value from service activator

Hybrid View

  1. #1

    Default 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. #2
    Join Date
    Jan 2008
    Location
    Mohnton, PA USA (that's near Philadelphia)
    Posts
    2,148

    Default

    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.

  3. #3

    Default

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

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

    Default

    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

  5. #5

    Default

    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.

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

    Default

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

Posting Permissions

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