use of javax.jms.TemporaryQueue in project camel by apache.
the class DefaultDestinationCreationStrategyTest method testTemporaryQueueCreation.
@Test
public void testTemporaryQueueCreation() throws Exception {
TemporaryQueue destination = (TemporaryQueue) strategy.createTemporaryDestination(getSession(), false);
assertNotNull(destination);
assertNotNull(destination.getQueueName());
}
use of javax.jms.TemporaryQueue in project qpid-broker-j by apache.
the class AuthenticationTest method assertConnectivity.
private void assertConnectivity(final int port, final String userName, final String userPassword, final String mechanism) throws Exception {
Connection connection = getConnectionBuilder().setPort(port).setUsername(userName).setPassword(userPassword).setSaslMechanisms(mechanism).build();
try {
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
TemporaryQueue queue = session.createTemporaryQueue();
assertNotNull("Temporary queue was not created", queue);
} finally {
connection.close();
}
try {
getConnectionBuilder().setPort(port).setUsername(userName).setPassword("invalid" + userPassword).setSaslMechanisms(mechanism).build();
fail("Connection is established for invalid password");
} catch (JMSException e) {
// pass
}
try {
getConnectionBuilder().setPort(port).setUsername("invalid" + userName).setPassword(userPassword).setSaslMechanisms(mechanism).build();
fail("Connection is established for invalid user name");
} catch (JMSException e) {
// pass
}
}
use of javax.jms.TemporaryQueue in project spring-integration by spring-projects.
the class JmsOutboundGateway method retryableReceiveReply.
/*
* If the replyTo is not temporary, and the connection is lost while waiting for a reply, reconnect for
* up to receiveTimeout.
*/
private javax.jms.Message retryableReceiveReply(Session session, Destination replyTo, String messageSelector) throws JMSException {
// NOSONAR
Connection consumerConnection = null;
Session consumerSession = session;
MessageConsumer messageConsumer = null;
JMSException exception = null;
boolean isTemporaryReplyTo = replyTo instanceof TemporaryQueue || replyTo instanceof TemporaryTopic;
long replyTimeout = isTemporaryReplyTo ? Long.MIN_VALUE : this.receiveTimeout < 0 ? Long.MAX_VALUE : System.currentTimeMillis() + this.receiveTimeout;
try {
do {
try {
messageConsumer = consumerSession.createConsumer(replyTo, messageSelector);
javax.jms.Message reply = receiveReplyMessage(messageConsumer);
if (reply == null) {
if (replyTimeout > System.currentTimeMillis()) {
throw new JMSException("Consumer closed before timeout");
}
}
return reply;
} catch (JMSException e) {
exception = e;
if (logger.isDebugEnabled()) {
logger.debug("Connection lost waiting for reply, retrying: " + e.getMessage());
}
do {
try {
consumerConnection = createConnection();
consumerSession = createSession(consumerConnection);
break;
} catch (JMSException ee) {
exception = ee;
if (logger.isDebugEnabled()) {
logger.debug("Could not reconnect, retrying: " + ee.getMessage());
}
try {
Thread.sleep(1000);
} catch (InterruptedException e1) {
Thread.currentThread().interrupt();
return null;
}
}
} while (replyTimeout > System.currentTimeMillis());
}
} while (replyTimeout > System.currentTimeMillis());
if (isTemporaryReplyTo) {
return null;
} else {
throw exception;
}
} finally {
if (consumerSession != session) {
JmsUtils.closeSession(consumerSession);
JmsUtils.closeConnection(consumerConnection);
}
JmsUtils.closeMessageConsumer(messageConsumer);
}
}
use of javax.jms.TemporaryQueue in project scout.rt by eclipse.
the class JmsMomImplementor method requestImpl.
protected <REQUEST, REPLY> Message requestImpl(final IBiDestination<REQUEST, REPLY> destination, final REQUEST requestObject, final PublishInput input, String replyId) throws JMSException {
Message responseMessage;
IJmsSessionProvider sessionProvider = createSessionProvider(destination, false);
try {
TemporaryQueue temporaryQueue = sessionProvider.getTemporaryQueue();
MessageConsumer responseQueueConsumer = sessionProvider.getSession().createConsumer(temporaryQueue);
// send request message
JmsMessageWriter messageWriter = JmsMessageWriter.newInstance(sessionProvider.getSession(), resolveMarshaller(destination)).writeReplyTo(temporaryQueue).writeReplyId(replyId).writeProperties(input.getProperties()).writeTransferObject(requestObject);
send(sessionProvider, destination, messageWriter, input);
// receive response message
responseMessage = responseQueueConsumer.receive();
} catch (JMSException e) {
if (IFuture.CURRENT.get().isCancelled()) {
// if job was canceled, we ignore JMSException as these are exceptions because of interruption
LOG.info("Request job canceled; {}", e.getMessage());
return null;
} else {
throw e;
}
} finally {
sessionProvider.close();
}
// After closing session, delete not required temporary queue. The queue is associated with the connection and exists as long as the connection is alive.
sessionProvider.deleteTemporaryQueue();
return responseMessage;
}
use of javax.jms.TemporaryQueue in project activemq-artemis by apache.
the class ActiveMQRASession method createTemporaryQueue.
/**
* Create a temporary queue
*
* @return The temporary queue
* @throws JMSException Thrown if an error occurs
*/
@Override
public TemporaryQueue createTemporaryQueue() throws JMSException {
if (cri.getType() == ActiveMQRAConnectionFactory.TOPIC_CONNECTION || cri.getType() == ActiveMQRAConnectionFactory.XA_TOPIC_CONNECTION) {
throw new IllegalStateException("Cannot create temporary queue for javax.jms.TopicSession");
}
lock();
try {
Session session = getSessionInternal();
if (ActiveMQRASession.trace) {
ActiveMQRALogger.LOGGER.trace("createTemporaryQueue " + session);
}
TemporaryQueue temp = session.createTemporaryQueue();
if (ActiveMQRASession.trace) {
ActiveMQRALogger.LOGGER.trace("createdTemporaryQueue " + session + " temp=" + temp);
}
sf.addTemporaryQueue(temp);
return temp;
} finally {
unlock();
}
}
Aggregations