INT-2727 PseudoTX Refactoring

Remove the need for pseudo-transactional element

INT-2727 PseudoTX
Add PseudoTransactionalTransactionManager

INT-2727
addressed PR comments
cherry picked previous code for mail module to eliminate breaking change

INT-2727
initial refactoring pseudo-tx support to use common configuration

INT-2727
finalizing pseudo-tx synchronization support

INT-2727 polishing

INT-2727 polishing based on PR comments

INT-2727 addressed PR comments

INT-2727 polishing

INT-2727 Remove PseudoTransactionalMessageSource

Instead of getResource, bind the resource holder before
receive() and then add attributes to the holder.

INT-2727 polishing

INT-2727 Polishing

Remove bind of #resource; add beforeCommit() test;
add TransactionTemplate tests.
This commit is contained in:
Oleg Zhurakousky
2012-08-27 13:16:21 -04:00
committed by Gary Russell
parent 5828f70321
commit 94cc5a73e2
50 changed files with 1523 additions and 1357 deletions

View File

@@ -17,7 +17,6 @@ package org.springframework.integration.mongodb.inbound;
import java.util.List;
import org.springframework.context.MessageSource;
import org.springframework.data.mongodb.MongoDbFactory;
import org.springframework.data.mongodb.core.MongoOperations;
import org.springframework.data.mongodb.core.MongoTemplate;
@@ -29,10 +28,12 @@ import org.springframework.expression.common.LiteralExpression;
import org.springframework.expression.spel.support.StandardEvaluationContext;
import org.springframework.integration.Message;
import org.springframework.integration.context.IntegrationObjectSupport;
import org.springframework.integration.core.PseudoTransactionalMessageSource;
import org.springframework.integration.core.MessageSource;
import org.springframework.integration.mongodb.support.MongoHeaders;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.integration.transaction.MessageSourceResourceHolder;
import org.springframework.integration.util.ExpressionUtils;
import org.springframework.transaction.support.TransactionSynchronizationManager;
import org.springframework.util.Assert;
import org.springframework.util.CollectionUtils;
@@ -58,7 +59,7 @@ import com.mongodb.DBObject;
* @since 2.2
*/
public class MongoDbMessageSource extends IntegrationObjectSupport
implements PseudoTransactionalMessageSource<Object, MongoOperations>{
implements MessageSource<Object> {
private final Expression queryExpression;
@@ -215,29 +216,12 @@ public class MongoDbMessageSource extends IntegrationObjectSupport
.build();
}
Object holder = TransactionSynchronizationManager.getResource(this);
if (holder != null) {
Assert.isInstanceOf(MessageSourceResourceHolder.class, holder);
((MessageSourceResourceHolder) holder).addAttribute("mongoTemplate", this.mongoTemplate);
}
return message;
}
/**
* Returns the mongo-template.
*/
public MongoOperations getResource() {
return this.mongoTemplate;
}
public void afterCommit(Object object) {
}
public void afterRollback(Object object) {
}
public void afterReceiveNoTx(MongoOperations resource) {
}
public void afterSendNoTx(MongoOperations resource) {
}
}

View File

@@ -63,9 +63,13 @@
auto-startup="false">
<int:poller fixed-rate="200" max-messages-per-poll="1">
<int:pseudo-transactional on-success-expression="@documentCleaner.remove(#resource, payload, headers.mongo_collectionName)" on-success-result-channel="nullChannel"/>
<int:transactional synchronization-factory="syncFactory"/>
</int:poller>
</int-mongodb:inbound-channel-adapter>
<int:transaction-synchronization-factory id="syncFactory">
<int:after-commit expression="@documentCleaner.remove(#mongoTemplate, payload, headers.mongo_collectionName)"/>
</int:transaction-synchronization-factory>
<int-mongodb:inbound-channel-adapter id="mongoInboundAdapterWithConverter"
channel="replyChannel"
@@ -93,5 +97,6 @@
<int:queue/>
</int:channel>
<bean id="transactionManager" class="org.springframework.integration.transaction.PseudoTransactionManager"/>
</beans>