Search code examples
spring-integration

Spring Integration New Transactional Scope within File Poller Transaction


We have a file poller flow bounded by pseudoTransactionManager to move / delete the input file at the end of the processing based on success or failure. While this huge file is processed, we would want to update the processing stats in DB in-between the flow multiple times, however the Jpa update is NOT committed as it is part of the file's transaction scope.

How do we define a separate independent transaction scope for the Jpa.updatingGateway? Thanks

.handle(Jpa.updatingGateway(entityManagerFactory)
            .entityClass(SomeDAO.class)
            .flush(true),
        ConsumerEndpointSpec::transactional)

Solution

  • Able to do via a TransactionInterceptor with reference from Spring Integration: start new transaction in my Message flow IntegrationFlowBuilder to commit change and resume the outer transaction