Question

I'm struggling a lot with following scenario:

WS |============| JMS ~~~ async future processing ~~~

The idea is following. Incoming WS request is stored to JMS and once it is stored (correctly sent) the WS client is responded with OK.

I'm able to achieve that via spring jmsTemplate, something like

<chain>
  <service-activator> 
      ... calling jmsTemplate send ...
  </service-activator>
  <OK response>
</chain>

I don't want to use the jmsTemplate, however if I use the jms:outbound-channel-adapter, no reply message is generated and it gets stuck. Other constructions leads to synchronous processing, means that the WS response was delayed until the JMS request is fully processed.

I believe there is an easy solution, but I was't able to find it for hours. Thanks!


EDIT: Suggested solution works, thanks a lot! Friend of mine recommended me another one - using wire-tap, it looks nice IMHO.

<int:gateway service-interface="MyService" default-request-channel="in"/>
     <channel id="in">
      <interceptors>
          <wire-tap channel="inJms"/>
      </interceptors>
 </channel>

 <channel id="inJms"/>

 <transformer expression="'OK'" input-channel="in" order="1"/>      

 <jms:outbound-channel-adapter channel="inJms" destination="requestQueue"/>
Was it helpful?

Solution

The <publish-subscribe-channel/> helps you:

<publish-subscribe-channel id="storeMessageChannel"/>

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

<int-jms:outbound-channel-adapter channel="storeMessageChannel"/>

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

Well, in this case the message from WS will be sent to the storeMessageChannel with two sequential subscribers: 1. JMS - to place message to the queue; 2. Simple transformer - to return to the WS response 'OK'.

Transformer will apply the message only after jms outbound adapter has done its work.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top