use of org.apache.camel.component.sjms.consumer.InOnlyMessageHandler in project camel by apache.
the class SjmsConsumer method createMessageHandler.
/**
* Helper factory method used to create a MessageListener based on the MEP
*
* @param session a session is only required if we are a transacted consumer
* @return the listener
*/
protected MessageListener createMessageHandler(Session session) {
TransactionCommitStrategy commitStrategy;
if (getTransactionCommitStrategy() != null) {
commitStrategy = getTransactionCommitStrategy();
} else if (getTransactionBatchCount() > 0) {
commitStrategy = new BatchTransactionCommitStrategy(getTransactionBatchCount());
} else {
commitStrategy = new DefaultTransactionCommitStrategy();
}
Synchronization synchronization;
if (commitStrategy instanceof BatchTransactionCommitStrategy) {
TimedTaskManager timedTaskManager = getEndpoint().getComponent().getTimedTaskManager();
synchronization = new SessionBatchTransactionSynchronization(timedTaskManager, session, commitStrategy, getTransactionBatchTimeout());
} else {
synchronization = new SessionTransactionSynchronization(session, commitStrategy);
}
AbstractMessageHandler messageHandler;
if (getEndpoint().getExchangePattern().equals(ExchangePattern.InOnly)) {
if (isTransacted()) {
messageHandler = new InOnlyMessageHandler(getEndpoint(), executor, synchronization);
} else {
messageHandler = new InOnlyMessageHandler(getEndpoint(), executor);
}
} else {
if (isTransacted()) {
messageHandler = new InOutMessageHandler(getEndpoint(), executor, synchronization);
} else {
messageHandler = new InOutMessageHandler(getEndpoint(), executor);
}
}
messageHandler.setSession(session);
messageHandler.setProcessor(getAsyncProcessor());
messageHandler.setSynchronous(isSynchronous());
messageHandler.setTransacted(isTransacted());
messageHandler.setSharedJMSSession(isSharedJMSSession());
messageHandler.setTopic(isTopic());
return messageHandler;
}
Aggregations