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

  • Http Service

    Hello,

    I am just starting to use spring-integration so forgive me if the question is too obvious. I read the reference manual however did not find the details I was after.

    What I would like to do is to receive a payload over HTTP Post, process a service and return a replay. The replay should not wait to the service call to complete.

    In the the following configuration, the view is not being executed therefore the replay is empty:
    Code:
        <bean id="inboundGateway" class="org.springframework.integration.http.HttpInboundEndpoint"
           p:requestChannel-ref="textServiceChannel" p:replyChannel-ref="httpResponse" />
    
        <integration:channel id="httpResponse"/>
        <http:inbound-channel-adapter id="httpResponseAdapter" channel="httpResponse"  view="simpleView" supported-methods="POST"  />
    
        <integration:channel id="textServiceChannel" />
    	<integration:service-activator  input-channel="textServiceChannel"  ref="textService" output-channel="streamOutput"/>
        
        <stream:stdout-channel-adapter id="streamOutput"/>
    
        <bean id="textService" class="test.TextService"/>
         <bean id="simpleView" class="views.SimpleView"/>
    However when I changed the gateway to the following, the view is executed but only after the service is being called:

    Code:
       <bean id="inboundGateway" class="org.springframework.integration.http.HttpInboundEndpoint"
           p:requestChannel-ref="textServiceChannel" p:replyChannel-ref="httpResponse" p:view-ref="simpleView" />
    what am I doing wrong ?

    Thank you in advance
    /Lior.

  • #2
    If I understand your use-case correctly, I think you want something like this:
    Code:
    <http:inbound-channel-adapter channel="textServiceChannel" view="simpleView" supported-methods="POST"/>
    
    <integration:channel id="textServiceChannel">
        <integration:queue capacity="10"/>
    </integration:channel>
    
    <integration:service-activator  input-channel="textServiceChannel"  ref="textService" output-channel="streamOutput">
        <integration:poller>
            <integration:interval-trigger interval="1000"/>
        </integration:poller>
    </integration:service-activator>
        
    <stream:stdout-channel-adapter id="streamOutput"/>
    
    <bean id="textService" class="test.TextService"/>
    
    <bean id="simpleView" class="views.SimpleView"/>
    The key point is that the "textServiceChannel" is asynchronous because of the queue. If it were not asynchronous, then when the channel adapter sends its Message to that channel, the invocation of your textService would still be invoked in the same thread.

    You can change the poller settings and you can configure a task-executor on that poller as well.

    I hope that makes sense. If you have more questions, let me know.

    -Mark

    Comment


    • #3
      Hi Lior,

      How are you? It's been too long since we met. Excellent to see you are using Spring Integration now!

      If this is not clear from the documentation, please create a JIRA issue for that. A bug in documentation is just as problematic as a bug in the code, as you have experienced.

      http://jira.springframework.org/browse/INT

      Comment


      • #4
        Mark, Iwein,

        Thank you very much for your swift replay.
        Mark, the configuration you suggested makes perfect sense and did the job, all is good and the application does exactly what I want.

        Thank you again for your help
        /Lior.

        Comment


        • #5
          Glad to hear that it worked for you!

          As Iwein mentioned, please don't hesitate to open an issue if there is something in particular missing (or confusing) in the documentation.

          Comment

          Working...
          X