3
votes

We have a requirement where the external client are calling one of our spring integration inbound webservice gateway and we need to acknowledge them right away with a generic OK status. Meanwhile, the payload will be submitted to a channel for asynchronous processing and we don't need the response(email will be sent based on some business validation).

We tried using asynchronous gateway and executor channel(with task executor), but can't figure out how to make the gateway respond immediately. Both the cases it is working as a one way webservice with no response.

Configuration:

<context:component-scan base-package="com.myapp.springintegration" />



<channel id="helloWorldRequestChannel">
    <dispatcher task-executor="taskExecutor"/>
</channel>
<channel id="helloWorldReplyChannel"/>

<task:executor id="taskExecutor" pool-size="2"/>

<gateway id="helloServiceGateway" 
 service-interface="com.myapp.springintegration.HelloService"
 default-request-channel="helloWorldRequestChannel" default-reply-channel="helloWorldReplyChannel"/>

 <service-activator input-channel="helloWorldRequestChannel" ref="helloServiceImpl" method="hello" />
1

1 Answers

2
votes

I don't see any <int-ws:inbound-gateway> but the requirements may be implemented like this:

<int-ws:inbound-gateway request-channel="requestChannel"/>

<int:recipient-list-router input-channel="requestChannel">
    <int:recipient channel="response" />
    <int:recipient channel="process" />
</int:recipient-list-router>

<int:transformer input-channel="response" expression="'OK'"/>

<int:channel id="process">
   <int:dispatcher task-executor="testExecutor"/>
</int:channel>

You send request to the recipient-list-router, that distributes your message to two other channels. The first one (response) just returns simple reply to the WS immediately. The second (process) shifts the message to the separate Thread, so the subscriber to that channel will do its work not blocking the WS Thread.

Hope I am clear.