本文整理匯總了Java中javax.jms.TemporaryQueue.getQueueName方法的典型用法代碼示例。如果您正苦於以下問題:Java TemporaryQueue.getQueueName方法的具體用法?Java TemporaryQueue.getQueueName怎麽用?Java TemporaryQueue.getQueueName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.jms.TemporaryQueue
的用法示例。
在下文中一共展示了TemporaryQueue.getQueueName方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testTemporaryQueueShouldNotBeInJNDI
import javax.jms.TemporaryQueue; //導入方法依賴的package包/類
@Test
public void testTemporaryQueueShouldNotBeInJNDI() throws Exception {
Connection producerConnection = createConnection();
Session producerSession = producerConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
TemporaryQueue tempQueue = producerSession.createTemporaryQueue();
String queueName = tempQueue.getQueueName();
try {
ic.lookup("/queue/" + queueName);
ProxyAssertSupport.fail("The temporary queue should not be bound to JNDI");
} catch (NamingException e) {
// Expected
}
}
示例2: verifyConnection
import javax.jms.TemporaryQueue; //導入方法依賴的package包/類
/**
* Verify whether the JMS connection was still validate.
*
* @return result
*/
private boolean verifyConnection() {
boolean result = false;
TemporaryQueue tq = null;
MessageProducer producer = null;
MessageConsumer consumer = null;
try {
tq = this.session.createTemporaryQueue();
producer = this.session.createProducer(tq);
producer.setTimeToLive(Constants.ONE_MINUTE * 5);
consumer = this.session.createConsumer(tq);
String token = CommonUtils.generateToken();
Message msg = this.session.createMessage();
setProperty(msg, "heartbeat", token);
producer.send(msg);
Message msg2 = consumer.receive(Constants.ONE_SECOND * 30);
if (msg2 != null && token.equals(getProperty(msg2, "heartbeat", "")))
result = true;
} catch (Exception e) {
log.error("Verify Message Connection failed.", e);
} finally {
CommonUtils.closeQuietly(consumer);
CommonUtils.closeQuietly(producer);
String tqn = null;
try {
if (tq != null) {
tqn = tq.getQueueName();
tq.delete();
}
} catch (Exception ex) {
log.error("Delete temporary queue[" + tqn + "] failed.", ex);
}
}
return result;
}
示例3: JmsTemporaryQueueEndpoint
import javax.jms.TemporaryQueue; //導入方法依賴的package包/類
public JmsTemporaryQueueEndpoint(TemporaryQueue jmsDestination) throws JMSException {
super("jms:temp:queue:" + jmsDestination.getQueueName(), null);
setDestinationType("temp:queue");
this.jmsDestination = jmsDestination;
setDestination(jmsDestination);
}