Handling connectivity issues in web service outbound gateway (retry)
Currently, we have a requirement to attempt a WS request, and in the case that the remote endpoint is down, queue the request for retry. This queue should also be backed by a database, so that if the application goes down, the requests will be retried once it is restarted.
I am hoping that I can achieve this purely with Spring Integration. My thought was that I could use a WS Outbound Gateway, with a message-store-backed queue channel set as the error channel. The error channel would be polled, and the message would be sent to a retry gateway (via Service Activator) which would also hook up to the WS Outbound Gateway, and basically form a processing loop.
The idea of the Service Activator and retry Gateway was taken from one of Oleg's SpringOne 2GX examples. The polling is happening properly, but I can't figure out how to "complete the loop" and actually get the retry to happen. Oddly, the poller seems to stop after the retry gateway is invoked.
Here is what I have currently:
<!-- Will replace this with a JDBC store later -->
<bean id="testMessageStore" class="org.springframework.integration.store.SimpleMessageStore" />
<int:channel id="wsRequestChannel" />
<int:channel id="wsReplyChannel" />
<int:queue message-store="testMessageStore" />
<int:channel id="testChannel" />
<int:chain input-channel="wsErrorChannel" auto-startup="true">
<int:transactional transaction-manager="transactionManager" />
<int:transformer expression="payload.getFailedMessage().getPayload() + ' '" />
<!-- Everything seems to work fine up to here, but how do I get it to retry the WS? -->
<int:service-activator ref="retryGateway" />
<int:chain input-channel="wsRequestChannel" output-channel="wsReplyChannel">
<int-ws:soap-action value="theTargetSoapAction" />
<int-ws:outbound-gateway id="testWsGateway" uri="https://someSOAPService" interceptor="wsSecurityInterceptor" />
<int:gateway id="mainGateway" default-request-channel="wsRequestChannel" default-reply-channel="wsReplyChannel" error-channel="wsErrorChannel" service-interface="com.mypackage.IntegrationTestService">
<int:method name="sendMessage" />
<int:gateway id="retryGateway" default-request-channel="wsRequestChannel" default-reply-channel="wsReplyChannel" error-channel="wsErrorChannel" />
Can anyone help with this, or offer up suggestions for alternative approaches?