Spring Integration

org.springframework.integration.core
Interface PseudoTransactionalMessageSource<T,V>

All Superinterfaces:
MessageSource<T>
All Known Implementing Classes:
FileReadingMessageSource, MailReceivingMessageSource

public interface PseudoTransactionalMessageSource<T,V>
extends MessageSource<T>

MessageSources implementing this sub-interface can participate in a Spring transaction. While the underlying resource is not strictly transactional, the final disposition of the resource will be synchronized with any encompassing transaction. For example, when a message source is used with a transactional poller, if any upstream activity causes the transaction to roll back, then the afterRollback(Object) method will be called, allowing the message source to reset the state of whatever. If the transaction commits, the afterCommit(Object) method is called.

For example, with a MailReceivingMessageSource, the email can be deleted on successful commit, but not deleted if the transaction rolls back.

This implements the 'Best Chance 1PC' pattern where there is only a small (but present) window in which a transaction might commit but the resource is not updated to reflect that. This could result in duplicate messages.

Since:
2.2
Author:
Gary Russell

Method Summary
 void afterCommit(V resource)
          Invoked via TransactionSynchronization when the transaction commits.
 void afterReceiveNoTx(V resource)
          Called when there is no transaction and the receive() call completed.
 void afterRollback(V resource)
          Invoked via TransactionSynchronization when the transaction rolls back.
 void afterSendNoTx(V resource)
          Called when there is no transaction and after the message was sent to the channel.
 V getResource()
          Obtain the resource on which appropriate action needs to be taken.
 
Methods inherited from interface org.springframework.integration.core.MessageSource
receive
 

Method Detail

getResource

V getResource()
Obtain the resource on which appropriate action needs to be taken.

Returns:
The resource.

afterCommit

void afterCommit(V resource)
Invoked via TransactionSynchronization when the transaction commits.

Parameters:
resource - The resource to be "committed"

afterRollback

void afterRollback(V resource)
Invoked via TransactionSynchronization when the transaction rolls back.

Parameters:
resource -

afterReceiveNoTx

void afterReceiveNoTx(V resource)
Called when there is no transaction and the receive() call completed.

Parameters:
resource -

afterSendNoTx

void afterSendNoTx(V resource)
Called when there is no transaction and after the message was sent to the channel.

Parameters:
resource -

Spring Integration