INT-2685 Transaction Synchronization
Remove M3 disposition-* attributes on File/(S)FTP inbound adapters. Add <pseudo-transactional/> and <transaction-synchronization/> elements to <poller/>. These elements provide the following attributes: * on-success-expression * on-success-result-channel * on-failure-expression * on-failure-result-channel * send-timeout <transaction-synchronization/> synchronizes these expression evaluations with the transaction, such that they are executed immediately after the commit/rollback. <psuedo-transactional/> is used for a non-transactional poller. When an <advice-chain/> is provided to the poller, <psuedo-transactional/> and <transaction-synchronization/> are synonyms; and the behavior is dictated by whether or not the <advice-chain/> contains a transaction advice. It is recommended that <pseudo-transactional/> is used when the <advice-chain/> does not have a txAdvice, and <transaction-synchronization/> when it does, but the framework does not enforce this. The expressions have the original (polled) message as the #root variable. In addition, a BeanResolver is provided, allowing expressions such as '@someBean.handleSuccess(payload)'. MessageSources may also implement PseudoTransactionalMessageSource. This has a number of methods allowing more flexibility in transactional and non-transactional environents. For example, for backwards compatibility. the mail-inbound-channel-adapter deletes its polled message after the receive() rather than after the polled message is sent (when running in a non-transactional poller). However, when running in a transactional poller, the delete is done after the transaction commits (but not when it rolls back). In addition, MessageSources that implement this interface can optionally provide an arbitrary object to the success/failure expressions in a variable named '#resource'. INT-2685 Polishing PR Review Comments Add tests for non-tx PseudoTransactionalMessageSource
This commit is contained in:
committed by
Oleg Zhurakousky
parent
d6623bda82
commit
4de02fa75e
@@ -81,25 +81,25 @@ public class MailReceivingMessageSource implements PseudoTransactionalMessageSou
|
||||
return this.mailReceiver.getTransactionContext();
|
||||
}
|
||||
|
||||
public void afterCommit(MailReceiverContext context) {
|
||||
public void afterCommit(Object context) {
|
||||
Assert.isTrue(context instanceof MailReceiverContext, "Expected a MailReceiverContext");
|
||||
this.mailReceiver.closeContextAfterSuccess(context);
|
||||
this.mailReceiver.closeContextAfterSuccess((MailReceiverContext) context);
|
||||
}
|
||||
|
||||
public void afterRollback(MailReceiverContext context) {
|
||||
public void afterRollback(Object context) {
|
||||
Assert.isTrue(context instanceof MailReceiverContext, "Expected a MailReceiverContext");
|
||||
this.mailReceiver.closeContextAfterFailure(context);
|
||||
this.mailReceiver.closeContextAfterFailure((MailReceiverContext) context);
|
||||
}
|
||||
|
||||
/**
|
||||
* For backwards-compatibility; the mail adapter updates the status before the send.
|
||||
* For backwards-compatibility; with no tx, the mail adapter updates the status before the send.
|
||||
*/
|
||||
public void afterReceiveNoTx(MailReceiverContext resource) {
|
||||
this.afterCommit(resource);
|
||||
}
|
||||
|
||||
/**
|
||||
* For backwards-compatibility; the mail adapter updates the status before the send.
|
||||
* For backwards-compatibility; with no tx, the mail adapter updates the status before the send.
|
||||
*/
|
||||
public void afterSendNoTx(MailReceiverContext resource) {
|
||||
// No op
|
||||
|
||||
Reference in New Issue
Block a user