Warm tip: This article is reproduced from serverfault.com, please click

Jms message-driven-channel-adapter with concurrent consumers avoid losing messages during crash

发布于 2020-12-08 12:00:31

I am trying to figure out how to use a message-driven-channel-adapter with concurrent consumers and be able to withstand a system failure without losing any messages. In my current implementation I use Spring Integration and reading from an ArtemisMQ server and I need to be able to rollback any messages that fail to reach the end of the flow.

I do use the following implementation to receive messages

  <int-jms:message-driven-channel-adapter
            connection-factory="connectionFactory"
            destination="myQueue"
            message-converter="messageConverter"
            channel="inputChannel"
            concurrent-consumers="5"
            error-channel="errorChannel"
            acknowledge="transacted"
    />

but since multiple concurrent consumers are now involved transaction boundaries are now redefined and if a failure occurs then messages are lost.

My main issue is that I need multiple consumers serving messages and and at the same time I do not want to lose messages during a crash event. Is there a way to extend/propagate transaction boundaries or at least manually acknowledge each message on the end of my flow ?

Questioner
ypanag
Viewed
0
Artem Bilan 2020-12-08 21:56:33

I think you misunderstood something and just got confused. The concurrency doesn’t break transactions: every concurrent consumer gets its own transaction and nothing is lost if message process is done in the same thread.

I think you placing a message to different thread somewhere downstream. That’s where your tx is committed and message might be lost in case of error.

You need to revise how you process messages to keep them in the tx boundaries or really consider to use a client ack mode to do that manually downstream.