diff --git a/spring-integration-core/src/main/java/org/springframework/integration/endpoint/SourcePollingChannelAdapter.java b/spring-integration-core/src/main/java/org/springframework/integration/endpoint/SourcePollingChannelAdapter.java index f1a594b507..83d3dd55a2 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/endpoint/SourcePollingChannelAdapter.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/endpoint/SourcePollingChannelAdapter.java @@ -103,11 +103,10 @@ public class SourcePollingChannelAdapter extends AbstractPollingEndpoint impleme IntegrationResourceHolder holder = null; if (TransactionSynchronizationManager.isActualTransactionActive()) { - holder = new IntegrationResourceHolder(); - holder.addAttribute(IntegrationResourceHolder.MESSAGE_SOURCE, source); - TransactionSynchronizationManager.bindResource(source, holder); - if (transactionSynchronizationFactory != null){ + holder = new IntegrationResourceHolder(); + holder.addAttribute(IntegrationResourceHolder.MESSAGE_SOURCE, source); + TransactionSynchronizationManager.bindResource(source, holder); TransactionSynchronizationManager.registerSynchronization(transactionSynchronizationFactory.create(source)); } } diff --git a/spring-integration-mail/src/main/java/org/springframework/integration/mail/ImapIdleChannelAdapter.java b/spring-integration-mail/src/main/java/org/springframework/integration/mail/ImapIdleChannelAdapter.java index 43874d001a..dc4e6fca74 100755 --- a/spring-integration-mail/src/main/java/org/springframework/integration/mail/ImapIdleChannelAdapter.java +++ b/spring-integration-mail/src/main/java/org/springframework/integration/mail/ImapIdleChannelAdapter.java @@ -211,12 +211,10 @@ public class ImapIdleChannelAdapter extends MessageProducerSupport implements Be MessageBuilder.withPayload(mailMessage).build(); if (TransactionSynchronizationManager.isActualTransactionActive()) { - - IntegrationResourceHolder holder = new IntegrationResourceHolder(); - holder.setMessage(message); - TransactionSynchronizationManager.bindResource(ImapIdleChannelAdapter.this, holder); - if (transactionSynchronizationFactory != null){ + IntegrationResourceHolder holder = new IntegrationResourceHolder(); + holder.setMessage(message); + TransactionSynchronizationManager.bindResource(ImapIdleChannelAdapter.this, holder); TransactionSynchronizationManager. registerSynchronization(transactionSynchronizationFactory.create(ImapIdleChannelAdapter.this)); } diff --git a/src/reference/docbook/transactions.xml b/src/reference/docbook/transactions.xml index fde979ddef..26e38766df 100644 --- a/src/reference/docbook/transactions.xml +++ b/src/reference/docbook/transactions.xml @@ -254,10 +254,20 @@ public interface TransactionSynchronizationProcessor { 'payload'. + It is important to understand that this is simply synchronizing the actions with a transaction, it does not make a resource that is not inherently transactional actually transactional. Instead, the transaction (be it JDBC or otherwise) is started before the poll, and committed/rolled back when the flow completes, followed by the synchronized action. + + + It is also important to understand that if you provide a custom TransactionSynchronizationFactory, + it is responsible for creating a resource synchronization that will cause the bound resource to be unbound automatically, + when the transaction completes. + The default TransactionSynchronizationFactory does this by returning a subclass + of ResourceHolderSynchronization, with the default + shouldUnbindAtCompletion() returning true. + In addition to the after-commit and after-rollback expressions, diff --git a/src/reference/docbook/whats-new.xml b/src/reference/docbook/whats-new.xml index 91911c6f67..1eaeb7b8e5 100644 --- a/src/reference/docbook/whats-new.xml +++ b/src/reference/docbook/whats-new.xml @@ -119,14 +119,6 @@ For more information please see . -
- Transaction Synchronization - - When running from a transactional poller, - mail inbound adapters can be configured to update the mailbox only - if the transaction commits. - -
Orderly Shutdown