在 JMS 队列中插入消息,然后使用 Spring 集成发回确认

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

我有一项服务通过 http 入站适配器接收 xml 消息,然后将它们转换为文本,成为发送出去的电子邮件的内容。 我现在需要先将这些消息插入 JMS 队列,并在消息插入 Q 后将确认作为 200 ok 发回,然后继续进行其余处理。

  <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>

服务激活器负责将 xml 转换为电子邮件的处理。

在此之前,我需要合并一个 JMS 队列,将接收到的消息插入其中,然后将确认发回。这是为了保留消息并在服务失败时重试。 我想将其设置为以 JMS 队列为端点的事务。 我该如何处理?

如果您正在寻找类似 in-process persistence storage 的内容,请查看 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".