user1052610
user1052610

Reputation: 4719

Transactional semantics of jdbc poller with task executor

What is the transactional behaviour of the jdbc:inbound-channel-adapter when it uses a task executor, as in the following code:

<task:executor id="pollerPool" pool-size="10" queue-capacity="1000" />
<int-jdbc:inbound-channel-adapter id="pollingAdapter"
  channel="..." data-source="..." auto-startup="true" query="..." 
  row-mapper="..." update="..." max-rows-per-poll="100">
  <int:poller fixed-rate="50000" task-executor="pollerPool">
    <int:transactional transaction-manager="..."
      isolation="DEFAULT" propagation="REQUIRED" read-only="false" timeout="1000"/>
  </int:poller>
</int-jdbc:inbound-channel-adapter>

Obviously the use of a task executor will start a new transaction, but that is no issue because the jdbc poller is the begining of the pipeline. But will componenents further down the pipeline participate in the same transaction? This is important because, if not, the update statement of the jdbc:inbound-channel-adapter will not be rolled back if there is a failure further down the line.

Upvotes: 0

Views: 705

Answers (1)

Artem Bilan
Artem Bilan

Reputation: 121262

Correct. Polling task AbstractPollingEndpoint#createPoller() is wrapped with TransactionInterceptor and it independ of provided TaskExecutor. In other words: that thread which poll message from JDBC is within transaction boundaries. And that transaction lives until that downstream flow ends its work or you shift a message to another thread, e.g. some Executor Channel.

Don't forget that transaction is single-threaded anyway.

For more info take a look here please: http://docs.spring.io/spring-integration/docs/3.0.1.RELEASE/reference/html/transactions.html

Upvotes: 1

Related Questions