Hi Mark,
For the moment, here is my configuration :
Code:
<int:poller id="myPollerMetadata" task-executor="pollerTaskExecutor" fixed-rate="3000">
<int:transactional transaction-manager="fileSendingTransactionManager" propagation="REQUIRES_NEW" isolation="DEFAULT" timeout="60000" read-only="false"/>
</int:poller>
<bean id="pollerTaskExecutor" class="org.springframework.core.task.SyncTaskExecutor"/>
I want to define my own poller because I want to override the "doPoll" method. On the previous code, you can see I defined a transactionManager for my poller. My problem is I have to manage not only one database, so I have to deal with more transactionManagers. I intend to write a doPoll method like this :
Code:
@Override
protected boolean doPoll() {
Message<?> message = (this.receiveTimeout >= 0)
? this.inputChannel.receive(this.receiveTimeout)
: this.inputChannel.receive();
if (message == null) {
return false;
}
//My correlationId defines my transactionManager
Object correlationId = message.getHeaders().getCorrelationId();
//Defines my TransactionDefinition
TransactionDefinition td = ...
TransactionStatus ts = this.transactionManagerProxy.getTransaction(correlationId, td);
try {
this.handler.handleMessage(message);
this.transactionManagerProxy.commit(correlationId, ts);
} catch (Exception e) {
this.transactionManagerProxy.rollback(correlationId, ts);
}
return true;
}
The transactionManagerProxy manages a pool of transactionManagers and determines dynamically (depending on the incomming message) which one it has to use.