use of org.apache.cxf.transport.jms.util.PollingMessageListenerContainer in project cxf by apache.
the class JMSDestination method createTargetDestinationListener.
private JMSListenerContainer createTargetDestinationListener() {
Session session = null;
try {
ExceptionListener exListener = new ExceptionListener() {
public void onException(JMSException exception) {
if (!shutdown) {
LOG.log(Level.WARNING, "Exception on JMS connection. Trying to reconnect", exception);
restartConnection();
}
}
};
PollingMessageListenerContainer container;
if (!jmsConfig.isOneSessionPerConnection()) {
connection = JMSFactory.createConnection(jmsConfig);
session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
Destination destination = jmsConfig.getTargetDestination(session);
container = new PollingMessageListenerContainer(connection, destination, this, exListener);
} else {
container = new PollingMessageListenerContainer(jmsConfig, false, this);
}
container.setConcurrentConsumers(jmsConfig.getConcurrentConsumers());
container.setTransactionManager(jmsConfig.getTransactionManager());
container.setMessageSelector(jmsConfig.getMessageSelector());
container.setTransacted(jmsConfig.isSessionTransacted());
container.setDurableSubscriptionName(jmsConfig.getDurableSubscriptionName());
container.setPubSubNoLocal(jmsConfig.isPubSubNoLocal());
Object executor = bus.getProperty(JMSFactory.JMS_DESTINATION_EXECUTOR);
if (executor instanceof Executor) {
container.setExecutor((Executor) executor);
}
container.setJndiEnvironment(jmsConfig.getJndiEnvironment());
container.start();
suspendedContinuations.setListenerContainer(container);
if (!jmsConfig.isOneSessionPerConnection()) {
connection.start();
}
return container;
} catch (JMSException e) {
ResourceCloser.close(connection);
this.connection = null;
throw JMSUtil.convertJmsException(e);
} finally {
ResourceCloser.close(session);
}
}
use of org.apache.cxf.transport.jms.util.PollingMessageListenerContainer in project cxf by apache.
the class JMSConduit method setupReplyDestination.
private void setupReplyDestination(Session session) throws JMSException {
if (staticReplyDestination == null) {
synchronized (this) {
if (staticReplyDestination == null) {
staticReplyDestination = jmsConfig.getReplyDestination(session);
String messageSelector = JMSFactory.getMessageSelector(jmsConfig, conduitId);
if (jmsConfig.getMessageSelector() != null) {
messageSelector += (messageSelector != null && !messageSelector.isEmpty() ? " AND " : "") + jmsConfig.getMessageSelector();
}
if (messageSelector == null && !jmsConfig.isPubSubDomain()) {
// An option for this might be a good idea for people who do not plan to share queues.
return;
}
AbstractMessageListenerContainer container;
if (jmsConfig.isOneSessionPerConnection()) {
container = new PollingMessageListenerContainer(jmsConfig, true, this);
} else {
container = new MessageListenerContainer(getConnection(), staticReplyDestination, this);
}
container.setTransactionManager(jmsConfig.getTransactionManager());
container.setTransacted(jmsConfig.isSessionTransacted());
container.setDurableSubscriptionName(jmsConfig.getDurableSubscriptionName());
container.setMessageSelector(messageSelector);
Object executor = bus.getProperty(JMSFactory.JMS_CONDUIT_EXECUTOR);
if (executor instanceof Executor) {
container.setExecutor((Executor) executor);
}
container.start();
jmsListener = container;
addBusListener();
}
}
}
}
Aggregations