问题
we have an ETL scenario where we use the resequencer.
Messages arrive to the flow with a sequence number that the resequencer uses it to send messages in order, but sometimes messages are discarded previously (because of data validation) and do not arrive to the resequencer. This produces holes in the sequence and resequencer stops sending messages using the default release strategy. To avoid this, we developed a new SequenceTimeoutReleaseStrategy that is a mix between default strategy and TimeoutCountSequenceSizeReleaseStrategy from SI. When a message arrives, it checks the timeout and release it if necesary.
All this worked well unless for the last messages that arrive before the timeout and have holes. This messages aren't release by the strategy. We could use a reaper but the secuence may have more than one hole in the sequence so when the resequencer release them it will stop in the first sequence break and remove the group losing the rest of the messages. So, the question is: is there a way to use the resequencer where there can be holes in the sequence?
One solution we have and want to avoid is having a scheduled tasks that removes the messages directly from the message store, but this could be a problem with concurrency and so on, so we prefer other solutions.
Any help is appreciated here
Regards Guzman
回答1:
There are two components involved; the release strategy says "something" can be released; the actual decision as to what is released is performed by the MessageGroupProcessor
. In this case, a ResequencingMessageGroupProcessor
.
You would need to customize that class to "skip" the hole(s).
You can't wire in a customized MGP using the <reseequencer/>
namespace, you would have to wire up using <bean/>
s - a ResequencingMessageHandler
and a ConsumerEndpointFactoryBean
.
Or use a BeanFactoryPostProcessor
to change the constructor argument to your custom class.
来源:https://stackoverflow.com/questions/26405379/resequencer-with-holes-on-secuence