user5758361
user5758361

Reputation: 125

Inserting messages in a JMS queue and then sending back the acknowledgement using Spring Integration

I have a service which receives xml messages via an http inbound adapter and then transforms them into text that becomes the content of an email that gets sent out. I now need to first insert these messages into a JMS queue and send the acknowledgement back as a 200 ok after the message is inserted into the Q and then carry-on with the rest of the processing.

  <int-http:inbound-channel-adapter channel="inputChannel" 
    id="httpInbound"  
    auto-startup="true" 
    request-payload-type="java.lang.String"
    path="/message"  
    supported-methods="POST" 
    error-channel="logger" >
    <int-http:request-mapping consumes="application/xml" />
</int-http:inbound-channel-adapter>


<int:chain id="chain" input-channel="inputChannel" >
 <int:service-activator ref="mailTransformerBean" method="transform" />
</int:chain>

The service-activator takes care of the processing to convert the xml into an email.

Before that I need to incorporate a JMS Queue into which the received messsages will be inserted and then the acknowledgement is sent back. This is so as to retain the messages and retry in case of a failure of the service. I would like to set this up as a Transaction with the JMS queue as a endpoint. How do i approach this?

Upvotes: 2

Views: 514

Answers (1)

Artem Bilan
Artem Bilan

Reputation: 121177

If you are seeking something like a in-process persistence storage, take a look, please, into the SubscribableJmsChannel :

The channel in the above example will behave much like a normal <channel/> element from the main Spring Integration namespace. It can be referenced by both "input-channel" and "output-channel" attributes of any endpoint. The difference is that this channel is backed by a JMS Queue instance named "exampleQueue".

Upvotes: 1

Related Questions