Pravat Panda
Pravat Panda

Reputation: 1090

Spring Integration Transaction management using Atomikos

I am thinking to create a Spring Integration Spring Boot application to

1-Poll messages from a DB
2-Do some processing on it
3-Publish messages to EMS Queue

using Atomikos for Transaction management. My question is: If the above configuration will be transactional with all the required JTA configurations done? Also I have read somewhere, if multiple threads are created in Spring Integration,e.g,using a Splitter, then the context won't to transactional. How to overcome this?

Upvotes: 0

Views: 545

Answers (2)

Hafsa Ch
Hafsa Ch

Reputation: 43

Spring Integration has different requirements for transactions, to Do so you need to pass a transaction manager in the poller metaData, for example:

@Bean
    public PollerMetadata pollerMetadata() throws  NamingException   {
        return Pollers.fixedDelay(Long.valueOf(env.getProperty("poller.interval")))
                .transactional(**transactionManager**).get();
    }

With

 @Autowired
     private PlatformTransactionManager **transactionManager**;

And putting :

@InboundChannelAdapter(channel = "jpaInputChannel", poller = @Poller(value = "**pollerMetadata**"))

Upvotes: 0

Gary Russell
Gary Russell

Reputation: 174544

If you configure the poller as transactional, the flow will run in a transaction, as long as you don't hand off to another thread (via an ExecutorChannel or QueueChannel channel, for example).

Adding a splitter will not break the transaction boundary as each split will be processed on the same thread.

Upvotes: 1

Related Questions