use of javax.jms.Destination 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 javax.jms.Destination in project cxf by apache.
the class PollingMessageListenerContainer method createConsumer.
private MessageConsumer createConsumer(final Connection connection, final Session session) throws JMSException {
final MessageConsumer consumer;
if (jmsConfig != null && jmsConfig.isOneSessionPerConnection()) {
Destination destination;
if (!isReply()) {
destination = jmsConfig.getTargetDestination(session);
} else {
destination = jmsConfig.getReplyDestination(session);
}
consumer = createConsumer(destination, session);
connection.start();
} else {
consumer = createConsumer(session);
}
return consumer;
}
use of javax.jms.Destination in project apex-malhar by apache.
the class JMSTestBase method produceMsg.
public void produceMsg(String text) throws Exception {
// Create a ConnectionFactory
ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://localhost");
// Create a Connection
Connection connection = connectionFactory.createConnection();
connection.start();
// Create a Session
Session session = connection.createSession(false, Session.CLIENT_ACKNOWLEDGE);
// Create the destination (Topic or Queue)
Destination destination = session.createQueue("TEST.FOO");
// Create a MessageProducer from the Session to the Topic or Queue
MessageProducer producer = session.createProducer(destination);
producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
// Create a messages
TextMessage message = session.createTextMessage(text);
producer.send(message);
// Clean up
session.close();
connection.close();
}
use of javax.jms.Destination in project apex-malhar by apache.
the class JMSObjectInputOperatorTest method produceMsg.
private void produceMsg() throws Exception {
// Create a ConnectionFactory
ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://localhost");
// Create a Connection
testMeta.connection = connectionFactory.createConnection();
testMeta.connection.start();
// Create a Session
testMeta.session = testMeta.connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
// Create the destination (Topic or Queue)
Destination destination = testMeta.session.createQueue("TEST.FOO");
// Create a MessageProducer from the Session to the Topic or Queue
testMeta.producer = testMeta.session.createProducer(destination);
testMeta.producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
}
use of javax.jms.Destination in project tomee by apache.
the class JmsTest method testProxy.
public void testProxy() throws Exception {
// Create a Session
final Connection connection = connectionFactory.createConnection();
try {
connection.start();
final Destination requestQueue = createListener(connection);
createSender(connection, requestQueue);
} finally {
MdbUtil.close(connection);
}
}
Aggregations