本文整理匯總了Java中javax.jms.Session.createTemporaryQueue方法的典型用法代碼示例。如果您正苦於以下問題:Java Session.createTemporaryQueue方法的具體用法?Java Session.createTemporaryQueue怎麽用?Java Session.createTemporaryQueue使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.jms.Session
的用法示例。
在下文中一共展示了Session.createTemporaryQueue方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testReceive
import javax.jms.Session; //導入方法依賴的package包/類
@Test
public void testReceive() throws JMSException {
JmsPoolConnection connection = (JmsPoolConnection) cf.createQueueConnection();
Session session = connection.createSession();
Queue queue = session.createTemporaryQueue();
MessageConsumer consumer = session.createConsumer(queue, "Color = Red");
assertNull(consumer.receive());
consumer.close();
try {
consumer.receive();
fail("Should not be able to interact with closed consumer");
} catch (IllegalStateException ise) {}
}
示例2: testReceiveNoWait
import javax.jms.Session; //導入方法依賴的package包/類
@Test
public void testReceiveNoWait() throws JMSException {
JmsPoolConnection connection = (JmsPoolConnection) cf.createQueueConnection();
Session session = connection.createSession();
Queue queue = session.createTemporaryQueue();
MessageConsumer consumer = session.createConsumer(queue, "Color = Red");
assertNull(consumer.receiveNoWait());
consumer.close();
try {
consumer.receiveNoWait();
fail("Should not be able to interact with closed consumer");
} catch (IllegalStateException ise) {}
}
示例3: testReceiveTimed
import javax.jms.Session; //導入方法依賴的package包/類
@Test
public void testReceiveTimed() throws JMSException {
JmsPoolConnection connection = (JmsPoolConnection) cf.createQueueConnection();
Session session = connection.createSession();
Queue queue = session.createTemporaryQueue();
MessageConsumer consumer = session.createConsumer(queue, "Color = Red");
assertNull(consumer.receive(1));
consumer.close();
try {
consumer.receive(1);
fail("Should not be able to interact with closed consumer");
} catch (IllegalStateException ise) {}
}
示例4: testGetMessageSelector
import javax.jms.Session; //導入方法依賴的package包/類
@Test
public void testGetMessageSelector() throws JMSException {
JmsPoolConnection connection = (JmsPoolConnection) cf.createQueueConnection();
Session session = connection.createSession();
Queue queue = session.createTemporaryQueue();
MessageConsumer consumer = session.createConsumer(queue, "Color = Red");
assertNotNull(consumer.getMessageSelector());
assertEquals("Color = Red", consumer.getMessageSelector());
consumer.close();
try {
consumer.getMessageSelector();
fail("Should not be able to interact with closed consumer");
} catch (IllegalStateException ise) {}
}
示例5: doTestCreateMessageProducer
import javax.jms.Session; //導入方法依賴的package包/類
private void doTestCreateMessageProducer(boolean useAnonymousProducers) throws JMSException {
cf.setUseAnonymousProducers(useAnonymousProducers);
JmsPoolConnection connection = (JmsPoolConnection) cf.createConnection();
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
Queue queue1 = session.createTemporaryQueue();
Queue queue2 = session.createTemporaryQueue();
JmsPoolMessageProducer producer1 = (JmsPoolMessageProducer) session.createProducer(queue1);
JmsPoolMessageProducer producer2 = (JmsPoolMessageProducer) session.createProducer(queue2);
if (useAnonymousProducers) {
assertSame(producer1.getMessageProducer(), producer2.getMessageProducer());
} else {
assertNotSame(producer1.getMessageProducer(), producer2.getMessageProducer());
}
connection.close();
}
示例6: testClose
import javax.jms.Session; //導入方法依賴的package包/類
@Test(timeout = 60000)
public void testClose() throws Exception {
JmsPoolConnection connection = (JmsPoolConnection) cf.createConnection();
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
assertEquals(0, connection.getNumtIdleSessions());
session.close();
assertEquals(1, connection.getNumtIdleSessions());
try {
session.close();
} catch (JMSException ex) {
fail("Shouldn't fail on second close call.");
}
try {
session.createTemporaryQueue();
fail("Session should be closed.");
} catch (IllegalStateException ise) {}
}
示例7: testNoTemporaryQueueLeaksAfterConnectionClose
import javax.jms.Session; //導入方法依賴的package包/類
@Test(timeout = 60000)
public void testNoTemporaryQueueLeaksAfterConnectionClose() throws Exception {
JmsPoolConnection connection = null;
MockJMSConnection pooledConnection = null;
Session session = null;
Queue tempQueue = null;
for (int i = 0; i < 10; i++) {
connection = (JmsPoolConnection) cf.createConnection();
pooledConnection = (MockJMSConnection) connection.getConnection();
session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
tempQueue = session.createTemporaryQueue();
LOG.info("Created queue named: " + tempQueue.getQueueName());
connection.close();
assertEquals(0, pooledConnection.getConnectionStats().getActiveTemporaryQueueCount());
}
assertEquals(10, pooledConnection.getConnectionStats().getTotalTemporaryQueuesCreated());
}
示例8: testPooledTempDestsCleanupOverzealous
import javax.jms.Session; //導入方法依賴的package包/類
@Test(timeout = 60000)
public void testPooledTempDestsCleanupOverzealous() throws java.lang.Exception {
Session session1;
Session session2;
session1 = pooledConn1.createSession(false, Session.AUTO_ACKNOWLEDGE);
session2 = pooledConn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
tempDest = session1.createTemporaryQueue();
otherTempDest = session2.createTemporaryQueue();
assertTrue("TEST METHOD FAILURE - NEW TEMP DESTINATION DOES NOT EXIST", destinationExists(tempDest));
assertTrue("TEST METHOD FAILURE - NEW TEMP DESTINATION DOES NOT EXIST", destinationExists(otherTempDest));
pooledConn1.close();
// Now confirm the first temporary destination no longer exists and the
// second does.
assertTrue("FAILED: temp dest from closed pooled connection is lingering", !destinationExists(tempDest));
assertTrue("FAILED: second PooledConnectin's temporary destination was incorrectly deleted", destinationExists(otherTempDest));
}
示例9: sendWithReplyToTemp
import javax.jms.Session; //導入方法依賴的package包/類
private void sendWithReplyToTemp(ConnectionFactory cf, String serviceQueue) throws JMSException, InterruptedException {
Connection connection = cf.createConnection();
connection.start();
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
TemporaryQueue tempQueue = session.createTemporaryQueue();
TextMessage msg = session.createTextMessage("Request");
msg.setJMSReplyTo(tempQueue);
MessageProducer producer = session.createProducer(session.createQueue(serviceQueue));
producer.send(msg);
MessageConsumer consumer = session.createConsumer(tempQueue);
Message replyMsg = consumer.receive();
assertNotNull(replyMsg);
LOG.debug("Reply message: {}", replyMsg);
consumer.close();
producer.close();
session.close();
connection.close();
}
示例10: testToString
import javax.jms.Session; //導入方法依賴的package包/類
@Test
public void testToString() throws JMSException {
JmsPoolConnection connection = (JmsPoolConnection) cf.createQueueConnection();
Session session = connection.createSession();
Queue queue = session.createTemporaryQueue();
MessageProducer producer = session.createProducer(queue);
assertNotNull(producer.toString());
}
示例11: testCloseMoreThanOnce
import javax.jms.Session; //導入方法依賴的package包/類
@Test
public void testCloseMoreThanOnce() throws JMSException {
JmsPoolConnection connection = (JmsPoolConnection) cf.createQueueConnection();
Session session = connection.createSession();
Queue queue = session.createTemporaryQueue();
MessageProducer producer = session.createProducer(queue);
producer.close();
producer.close();
}
示例12: testToString
import javax.jms.Session; //導入方法依賴的package包/類
@Test
public void testToString() throws JMSException {
JmsPoolConnection connection = (JmsPoolConnection) cf.createQueueConnection();
Session session = connection.createSession();
Queue queue = session.createTemporaryQueue();
MessageConsumer consumer = session.createConsumer(queue);
assertNotNull(consumer.toString());
}
示例13: testCloseMoreThanOnce
import javax.jms.Session; //導入方法依賴的package包/類
@Test
public void testCloseMoreThanOnce() throws JMSException {
JmsPoolConnection connection = (JmsPoolConnection) cf.createQueueConnection();
Session session = connection.createSession();
Queue queue = session.createTemporaryQueue();
MessageConsumer consumer = session.createConsumer(queue);
consumer.close();
consumer.close();
}
示例14: testTemporaryQueueWithMultipleConnectionUsers
import javax.jms.Session; //導入方法依賴的package包/類
@Test(timeout = 60000)
public void testTemporaryQueueWithMultipleConnectionUsers() throws Exception {
Connection pooledConnection = null;
Connection pooledConnection2 = null;
Session session = null;
Session session2 = null;
Queue tempQueue = null;
Queue normalQueue = null;
pooledConnection = pooledFactory.createConnection();
session = pooledConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
tempQueue = session.createTemporaryQueue();
LOG.info("Created queue named: " + tempQueue.getQueueName());
assertEquals(1, countBrokerTemporaryQueues());
pooledConnection2 = pooledFactory.createConnection();
session2 = pooledConnection2.createSession(false, Session.AUTO_ACKNOWLEDGE);
normalQueue = session2.createQueue("queue:FOO.TEST");
LOG.info("Created queue named: " + normalQueue.getQueueName());
// didn't create a temp queue on pooledConnection2 so we should still have a temp queue
pooledConnection2.close();
assertEquals(1, countBrokerTemporaryQueues());
// after closing pooledConnection, where we created the temp queue, there should
// be no temp queues left
pooledConnection.close();
assertEquals(0, countBrokerTemporaryQueues());
}
開發者ID:messaginghub,項目名稱:pooled-jms,代碼行數:31,代碼來源:PooledConnectionFactoryWithTemporaryDestinationsTest.java
示例15: testTemporaryQueueLeakAfterConnectionClose
import javax.jms.Session; //導入方法依賴的package包/類
@Test(timeout = 60000)
public void testTemporaryQueueLeakAfterConnectionClose() throws Exception {
Connection pooledConnection = null;
Session session = null;
Queue tempQueue = null;
for (int i = 0; i < 2; i++) {
pooledConnection = pooledFactory.createConnection();
session = pooledConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
tempQueue = session.createTemporaryQueue();
LOG.info("Created queue named: " + tempQueue.getQueueName());
pooledConnection.close();
}
assertEquals(0, countBrokerTemporaryQueues());
}
開發者ID:messaginghub,項目名稱:pooled-jms,代碼行數:16,代碼來源:PooledConnectionFactoryWithTemporaryDestinationsTest.java