BatchMessageListenerContainer using DMLC and Sprin

2019-08-30 03:48发布

问题:

I am trying to setup a DMLC so that it picks up a certain amount of messages from a JMS broker (ActiveMQ) within the same transaction and should any error occur, the transaction is rolled back so that all message contained within that transaction end up in DLQ, or better yet, do not leave the broker.

I found an implementation for a BatchMessageListenerContainer using spring-batch under the spring-batch-infrastucture-tests repo (https://github.com/spring-projects/spring-batch/tree/master/spring-batch-infrastructure-tests) however the tests don't really do anything with the message.

Ideally I'd like to adapt so that the messages received in the message listener would somehow be bound to the RepeatContext so that actions done by repeatOperations can be performed on the messages too however the issue is that the method currently being intercepted, receiveAndExecute returns a boolean which is what actually gets passed to the RepeatContext and is available inside the RepeatOperations class. I am a little but uncertain how the whole Repeat**** class package works so is there any simple way to implement such a functionality?