Announcement Announcement Module
Collapse
No announcement yet.
null objects in channels Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • null objects in channels

    How can I send null objects down a channel?

    In the following example MyServiceActivator.myMethod returns null. I want this null object to be sent down the 'output' channel and to my outbound-channel-adapter but currently it doesn't get published at all.

    Code:
    <channel id="input"/>
    <channel id="output"/>
    <service-activator ref="MyServiceActivator"
    	method="myMethod" input-channel="input" output-channel="output"/>
    
    class MyServiceActivator
    {
      // this method can return an object or a null value
      Object myMethod(Object obj) {
         return null;
      }
    }
    
    <outbound-channel-adapter ref="OutboundAdapter" channel="output" method="publish"/>
    
    class OutboundAdapter
    {
      void publish(Object obj) {
          // want to receive 'null's
      }
    }
    How can I get around this integration restriction?

  • #2
    Why do you need this?

    Comment


    • #3
      We are using messaging between the GUI and the server. The GUI sends a message to the server to perform an action, in a number of scenarios the response from the action does not have any data with it, but the GUI needs to know it has succeeded - hence the null value.

      The server and GUI code already exists and currently uses a non-intrusive homegrown framework built on top of RV. I want to replace the homegrown framework with spring integration but without any significant modifications to the server/gui code. The ability to send empty messages is one feature required from spring integration. The other is for a gateway to take 0 parameters.

      What was the rationale behind not sending null values down channels? Seems like an unnecessary restriction.

      Comment


      • #4
        The restriction was needed to enable filtering of messages within a handler. We could work around this obviously, but to me it doesn't seem right to pass empty messages around.

        If you're not interested in the result, why would you wait for it?

        Would you mind logging two issues for this and present a (simplified) use case within the description of them? I'm not completely set on keeping things the way they are, and perhaps a good example might change things.

        Comment

        Working...
        X