本文整理匯總了Java中javax.jms.TemporaryQueue.delete方法的典型用法代碼示例。如果您正苦於以下問題:Java TemporaryQueue.delete方法的具體用法?Java TemporaryQueue.delete怎麽用?Java TemporaryQueue.delete使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.jms.TemporaryQueue
的用法示例。
在下文中一共展示了TemporaryQueue.delete方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: doExecuteRequest
import javax.jms.TemporaryQueue; //導入方法依賴的package包/類
/**
* Actually execute the given request, sending the invoker request message
* to the specified target queue and waiting for a corresponding response.
* <p>The default implementation is based on standard JMS send/receive,
* using a {@link javax.jms.TemporaryQueue} for receiving the response.
* @param session the JMS Session to use
* @param queue the resolved target Queue to send to
* @param requestMessage the JMS Message to send
* @return the RemoteInvocationResult object
* @throws JMSException in case of JMS failure
*/
protected Message doExecuteRequest(Session session, Queue queue, Message requestMessage) throws JMSException {
TemporaryQueue responseQueue = null;
MessageProducer producer = null;
MessageConsumer consumer = null;
try {
responseQueue = session.createTemporaryQueue();
producer = session.createProducer(queue);
consumer = session.createConsumer(responseQueue);
requestMessage.setJMSReplyTo(responseQueue);
producer.send(requestMessage);
long timeout = getReceiveTimeout();
return (timeout > 0 ? consumer.receive(timeout) : consumer.receive());
}
finally {
JmsUtils.closeMessageConsumer(consumer);
JmsUtils.closeMessageProducer(producer);
if (responseQueue != null) {
responseQueue.delete();
}
}
}
示例2: testTempQueues
import javax.jms.TemporaryQueue; //導入方法依賴的package包/類
@Test
public void testTempQueues() throws Exception {
TemporaryQueue temp = localSession.createTemporaryQueue();
MessageProducer producer = localSession.createProducer(temp);
producer.send(localSession.createTextMessage("test"));
Thread.sleep(100);
assertEquals("Destination not created", 1, remoteBroker.getAdminView().getTemporaryQueues().length);
temp.delete();
assertTrue("Destination not deleted", Wait.waitFor(new Wait.Condition() {
@Override
public boolean isSatisified() throws Exception {
return 0 == remoteBroker.getAdminView().getTemporaryQueues().length;
}
}));
}
示例3: testDeleteDestinationWithSubscribersFails
import javax.jms.TemporaryQueue; //導入方法依賴的package包/類
/**
* Test you can't delete a Destination with Active Subscribers
*
* @throws JMSException
*/
@Test
public void testDeleteDestinationWithSubscribersFails() throws JMSException {
Connection connection = factory.createConnection();
connections.add(connection);
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
TemporaryQueue queue = session.createTemporaryQueue();
connection.start();
session.createConsumer(queue);
// This message delivery should NOT work since the temp connection is
// now closed.
try {
queue.delete();
Assert.fail("Should fail as Subscribers are active");
} catch (JMSException e) {
Assert.assertTrue("failed to throw an exception", true);
}
}
示例4: testTemporaryQueueLifecycle
import javax.jms.TemporaryQueue; //導入方法依賴的package包/類
public void testTemporaryQueueLifecycle() throws Exception
{
Session session;
TextMessage msg;
MessageProducer producer;
MessageConsumer consumer;
session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
TemporaryQueue tempQueue = session.createTemporaryQueue();
msg = session.createTextMessage("foobar");
producer = session.createProducer(tempQueue);
producer.send(msg, DeliveryMode.NON_PERSISTENT, 0, 0);
producer.close();
consumer = session.createConsumer(tempQueue);
connection.start();
msg = (TextMessage) consumer.receive(RECV_TIMEOUT);
assertNotNull(msg);
assertEquals("foobar", msg.getText());
tempQueue.delete();
session.close();
}
示例5: testCreateAndDeleteTemporaryQueue
import javax.jms.TemporaryQueue; //導入方法依賴的package包/類
@Test(timeout = 20000)
public void testCreateAndDeleteTemporaryQueue() throws Exception {
try (TestAmqpPeer testPeer = new TestAmqpPeer();) {
Connection connection = testFixture.establishConnecton(testPeer);
connection.start();
testPeer.expectBegin();
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
String dynamicAddress = "myTempQueueAddress";
testPeer.expectTempQueueCreationAttach(dynamicAddress);
TemporaryQueue tempQueue = session.createTemporaryQueue();
// Deleting the TemporaryQueue will be achieved by closing its creating link.
testPeer.expectDetach(true, true, true);
tempQueue.delete();
testPeer.expectClose();
connection.close();
testPeer.waitForAllHandlersToComplete(1000);
}
}
示例6: testDeleteOfTempQueueOnClosedConnection
import javax.jms.TemporaryQueue; //導入方法依賴的package包/類
@Test(timeout=30000)
public void testDeleteOfTempQueueOnClosedConnection() throws JMSException, IOException {
connection = new JmsConnection(connectionInfo, provider);
connection.start();
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
TemporaryQueue tempQueue = session.createTemporaryQueue();
assertNotNull(tempQueue);
connection.close();
try {
tempQueue.delete();
fail("Should have thrown an IllegalStateException");
} catch (IllegalStateException ex) {
}
}
示例7: testCannotCreateConsumerOnDeletedTemporaryDestination
import javax.jms.TemporaryQueue; //導入方法依賴的package包/類
@Test(timeout = 10000)
public void testCannotCreateConsumerOnDeletedTemporaryDestination() throws JMSException {
JmsSession session = (JmsSession) connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
TemporaryQueue tempQueue = session.createTemporaryQueue();
MessageProducer producer = session.createProducer(tempQueue);
try {
producer.send(session.createMessage());
} catch (Exception ex) {
fail("Should be able to send to this temporary destination");
}
tempQueue.delete();
try {
producer.send(session.createMessage());
fail("Should not be able to send to this temporary destination");
} catch (IllegalStateException ise) {}
}
示例8: testDeleteTemporaryQueue
import javax.jms.TemporaryQueue; //導入方法依賴的package包/類
@Test(timeout=30000)
public void testDeleteTemporaryQueue() throws Exception {
connection = createAmqpConnection();
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
Queue queue = session.createTemporaryQueue();
assertNotNull(queue);
assertTrue(queue instanceof TemporaryQueue);
final BrokerViewMBean broker = getProxyToBroker();
assertEquals(1, broker.getTemporaryQueues().length);
TemporaryQueue tempQueue = (TemporaryQueue) queue;
tempQueue.delete();
assertTrue("Temp Queue should be deleted.", Wait.waitFor(new Wait.Condition() {
@Override
public boolean isSatisified() throws Exception {
return broker.getTemporaryQueues().length == 0;
}
}, TimeUnit.SECONDS.toMillis(30), TimeUnit.MILLISECONDS.toMillis(50)));
}
示例9: testCantDeleteTemporaryQueueWithConsumers
import javax.jms.TemporaryQueue; //導入方法依賴的package包/類
@Test(timeout = 60000)
public void testCantDeleteTemporaryQueueWithConsumers() throws Exception {
connection = createAmqpConnection();
connection.start();
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
TemporaryQueue tempQueue = session.createTemporaryQueue();
MessageConsumer consumer = session.createConsumer(tempQueue);
try {
tempQueue.delete();
fail("should not be able to delete temporary queue with active consumers");
} catch (IllegalStateException ide) {
// expected
}
consumer.close();
// Now it should be allowed
tempQueue.delete();
}
示例10: doSendAndReceive
import javax.jms.TemporaryQueue; //導入方法依賴的package包/類
/**
* Send a request message to the given {@link Destination} and block until
* a reply has been received on a temporary queue created on-the-fly.
* <p>Return the response message or {@code null} if no message has
* @throws JMSException if thrown by JMS API methods
*/
protected Message doSendAndReceive(Session session, Destination destination, MessageCreator messageCreator)
throws JMSException {
Assert.notNull(messageCreator, "MessageCreator must not be null");
TemporaryQueue responseQueue = null;
MessageProducer producer = null;
MessageConsumer consumer = null;
try {
Message requestMessage = messageCreator.createMessage(session);
responseQueue = session.createTemporaryQueue();
producer = session.createProducer(destination);
consumer = session.createConsumer(responseQueue);
requestMessage.setJMSReplyTo(responseQueue);
if (logger.isDebugEnabled()) {
logger.debug("Sending created message: " + requestMessage);
}
doSend(producer, requestMessage);
return doReceive(consumer, getReceiveTimeout());
}
finally {
JmsUtils.closeMessageConsumer(consumer);
JmsUtils.closeMessageProducer(producer);
if (responseQueue != null) {
responseQueue.delete();
}
}
}
示例11: testTempQueueLeak
import javax.jms.TemporaryQueue; //導入方法依賴的package包/類
@Test
public void testTempQueueLeak() throws Exception {
Connection connection = null;
try {
connection = factory.createConnection();
connection.start();
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
TemporaryQueue temporaryQueue = session.createTemporaryQueue();
temporaryQueue.delete();
Object[] queueResources = server.getManagementService().getResources(QueueControl.class);
for (Object queueResource : queueResources) {
if (((QueueControl) queueResource).getAddress().equals("ActiveMQ.Advisory.TempQueue")) {
QueueControl queueControl = (QueueControl) queueResource;
Wait.waitFor(() -> queueControl.getMessageCount() == 0);
assertNotNull("addressControl for temp advisory", queueControl);
Wait.assertEquals(0, queueControl::getMessageCount);
Wait.assertEquals(2, queueControl::getMessagesAdded);
}
}
} finally {
if (connection != null) {
connection.close();
}
}
}
示例12: testTempQueueLeakManyConnections
import javax.jms.TemporaryQueue; //導入方法依賴的package包/類
@Test
public void testTempQueueLeakManyConnections() throws Exception {
final Connection[] connections = new Connection[20];
try {
for (int i = 0; i < connections.length; i++) {
connections[i] = factory.createConnection();
connections[i].start();
}
Session session = connections[0].createSession(false, Session.AUTO_ACKNOWLEDGE);
for (int i = 0; i < connections.length; i++) {
TemporaryQueue temporaryQueue = session.createTemporaryQueue();
temporaryQueue.delete();
}
Object[] addressResources = server.getManagementService().getResources(AddressControl.class);
for (Object addressResource : addressResources) {
if (((AddressControl) addressResource).getAddress().equals("ActiveMQ.Advisory.TempQueue")) {
AddressControl addressControl = (AddressControl) addressResource;
Wait.waitFor(() -> addressControl.getMessageCount() == 0);
assertNotNull("addressControl for temp advisory", addressControl);
Wait.assertEquals(0, addressControl::getMessageCount);
}
}
//sleep a bit to allow message count to go down.
} finally {
for (Connection conn : connections) {
if (conn != null) {
conn.close();
}
}
}
}
示例13: testDeleteTemporaryQueue
import javax.jms.TemporaryQueue; //導入方法依賴的package包/類
@Test(timeout = 30000)
public void testDeleteTemporaryQueue() throws Exception {
Connection connection = createConnection();
try {
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
final javax.jms.Queue queue = session.createTemporaryQueue();
assertNotNull(queue);
assertTrue(queue instanceof TemporaryQueue);
Queue queueView = getProxyToQueue(queue.getQueueName());
assertNotNull(queueView);
TemporaryQueue tempQueue = (TemporaryQueue) queue;
tempQueue.delete();
assertTrue("Temp Queue should be deleted.", Wait.waitFor(new Wait.Condition() {
@Override
public boolean isSatisfied() throws Exception {
return getProxyToQueue(queue.getQueueName()) == null;
}
}, TimeUnit.SECONDS.toMillis(30), TimeUnit.MILLISECONDS.toMillis(50)));
} finally {
connection.close();
}
}
示例14: testTempQueues
import javax.jms.TemporaryQueue; //導入方法依賴的package包/類
@Test
public void testTempQueues() throws Exception {
TemporaryQueue temp = localSession.createTemporaryQueue();
MessageProducer producer = localSession.createProducer(temp);
producer.send(localSession.createTextMessage("test"));
Thread.sleep(100);
assertEquals("Destination not created", 1, remoteBroker.getAdminView().getTemporaryQueues().length);
temp.delete();
Thread.sleep(100);
assertEquals("Destination not deleted", 0, remoteBroker.getAdminView().getTemporaryQueues().length);
}
開發者ID:apache,項目名稱:activemq-artemis,代碼行數:12,代碼來源:DynamicallyIncludedDestinationsDuplexNetworkTest.java
示例15: releaseDestination
import javax.jms.TemporaryQueue; //導入方法依賴的package包/類
protected void releaseDestination(Destination dest) throws JMSException {
if (dest instanceof TemporaryTopic) {
TemporaryTopic tt = (TemporaryTopic) dest;
tt.delete();
} else if (dest instanceof TemporaryQueue) {
TemporaryQueue tq = (TemporaryQueue) dest;
tq.delete();
}
}