Reputation: 173
Our TransactionSynchronizationFactory
is deleting the source file even before the flow ends and this is causing a failure in the flow. After reading the file, we split()
, make a WebClient Gateway
call, resequence()
and then aggregate()
. Just after aggregation the TransactionSynchronizationFactory
is performing a commit. Please suggest why is the behavior?
syncProcessor.setAfterCommitExpression(parser.parseExpression("payload.delete()"));
syncProcessor.setAfterRollbackExpression(parser.parseExpression("payload.delete()"));
return Pollers.fixedDelay(Duration.ofMinutes(pollInterval))
.maxMessagesPerPoll(maxMessagesPerPoll)
.transactionSynchronizationFactory(transactionSynchronizationFactory)
.transactional(pseudoTransactionManager)
.advice(loggingAdvice);
Upvotes: 0
Views: 90
Reputation: 121462
The transaction synchronization is tied to a thread which has started transaction. Whenever you leave that thread (kinda unblock), the end of transaction is triggered. Be sure that you don't shift a message after that aggregate()
to some other thread, e.g. via an ExecutorChannel
or QueueChannel
.
In addition I would look into some other solution where you are not tied to transaction and threading model. Just have the file stored in the headers and whenever you done call its delete()
! No reason to deal with transaction with simple files.
Upvotes: 1