private void checkTempQueues(Destination destination) throws JMSException { ActiveMQDestination jbdest = (ActiveMQDestination) destination; if (jbdest.isTemporary() && !containsTemporaryQueue(jbdest.getSimpleAddress())) { throw new JMSException("Can not create consumer for temporary destination " + destination + " from another JMS connection"); } }
@Override public MessageConsumer createConsumer(final Destination destination, final String messageSelector, final boolean noLocal) throws JMSException { if (destination == null) { throw new InvalidDestinationException("Cannot create a consumer with a null destination"); } if (!(destination instanceof ActiveMQDestination)) { throw new InvalidDestinationException("Not an ActiveMQDestination:" + destination); } ActiveMQDestination jbdest = (ActiveMQDestination) destination; if (jbdest.isTemporary() && !connection.containsTemporaryQueue(jbdest.getSimpleAddress())) { throw new JMSException("Can not create consumer for temporary destination " + destination + " from another JMS connection"); } return createConsumer(jbdest, null, messageSelector, noLocal, ConsumerDurability.NON_DURABLE); }
private void checkTempQueues(Destination destination) throws JMSException { ActiveMQDestination jbdest = (ActiveMQDestination) destination; if (jbdest.isTemporary() && !containsTemporaryQueue(jbdest.getSimpleAddress())) { throw new JMSException("Can not create consumer for temporary destination " + destination + " from another JMS connection"); } }
private void checkTempQueues(Destination destination) throws JMSException { ActiveMQDestination jbdest = (ActiveMQDestination) destination; if (jbdest.isTemporary() && !containsTemporaryQueue(jbdest.getSimpleAddress())) { throw new JMSException("Can not create consumer for temporary destination " + destination + " from another JMS connection"); } }
private void checkTempQueues(Destination destination) throws JMSException { ActiveMQDestination jbdest = (ActiveMQDestination) destination; if (jbdest.isTemporary() && !containsTemporaryQueue(jbdest.getSimpleAddress())) { throw new JMSException("Can not create consumer for temporary destination " + destination + " from another JMS connection"); } }
private void checkTempQueues(Destination destination) throws JMSException { ActiveMQDestination jbdest = (ActiveMQDestination) destination; if (jbdest.isTemporary() && !containsTemporaryQueue(jbdest.getSimpleAddress())) { throw new JMSException("Can not create consumer for temporary destination " + destination + " from another JMS connection"); } }
@Override public MessageConsumer createConsumer(final Destination destination, final String messageSelector, final boolean noLocal) throws JMSException { if (destination == null) { throw new InvalidDestinationException("Cannot create a consumer with a null destination"); } if (!(destination instanceof ActiveMQDestination)) { throw new InvalidDestinationException("Not an ActiveMQDestination:" + destination); } ActiveMQDestination jbdest = (ActiveMQDestination) destination; if (jbdest.isTemporary() && !connection.containsTemporaryQueue(jbdest.getSimpleAddress())) { throw new JMSException("Can not create consumer for temporary destination " + destination + " from another JMS connection"); } return createConsumer(jbdest, null, messageSelector, noLocal, ConsumerDurability.NON_DURABLE); }
@Override public MessageConsumer createConsumer(final Destination destination, final String messageSelector, final boolean noLocal) throws JMSException { if (destination == null) { throw new InvalidDestinationException("Cannot create a consumer with a null destination"); } if (!(destination instanceof ActiveMQDestination)) { throw new InvalidDestinationException("Not an ActiveMQDestination:" + destination); } ActiveMQDestination jbdest = (ActiveMQDestination) destination; if (jbdest.isTemporary() && !connection.containsTemporaryQueue(jbdest.getSimpleAddress())) { throw new JMSException("Can not create consumer for temporary destination " + destination + " from another JMS connection"); } return createConsumer(jbdest, null, messageSelector, noLocal, ConsumerDurability.NON_DURABLE); }
@Override public MessageConsumer createConsumer(final Destination destination, final String messageSelector, final boolean noLocal) throws JMSException { if (destination == null) { throw new InvalidDestinationException("Cannot create a consumer with a null destination"); } if (!(destination instanceof ActiveMQDestination)) { throw new InvalidDestinationException("Not an ActiveMQDestination:" + destination); } ActiveMQDestination jbdest = (ActiveMQDestination) destination; if (jbdest.isTemporary() && !connection.containsTemporaryQueue(jbdest.getSimpleAddress())) { throw new JMSException("Can not create consumer for temporary destination " + destination + " from another JMS connection"); } return createConsumer(jbdest, null, messageSelector, noLocal, ConsumerDurability.NON_DURABLE); }
@Override public MessageConsumer createConsumer(final Destination destination, final String messageSelector, final boolean noLocal) throws JMSException { if (destination == null) { throw new InvalidDestinationException("Cannot create a consumer with a null destination"); } if (!(destination instanceof ActiveMQDestination)) { throw new InvalidDestinationException("Not an ActiveMQDestination:" + destination); } ActiveMQDestination jbdest = (ActiveMQDestination) destination; if (jbdest.isTemporary() && !connection.containsTemporaryQueue(jbdest.getSimpleAddress())) { throw new JMSException("Can not create consumer for temporary destination " + destination + " from another JMS connection"); } return createConsumer(jbdest, null, messageSelector, noLocal, ConsumerDurability.NON_DURABLE); }
@Test public void testTemporaryQueueLeak() throws Exception { ActiveMQConnection conn = null; try { conn = (ActiveMQConnection) createConnection(); Session producerSession = conn.createSession(false, Session.AUTO_ACKNOWLEDGE); Session consumerSession = conn.createSession(false, Session.AUTO_ACKNOWLEDGE); TemporaryQueue tempQueue = producerSession.createTemporaryQueue(); MessageProducer producer = producerSession.createProducer(tempQueue); MessageConsumer consumer = consumerSession.createConsumer(tempQueue); conn.start(); final String messageText = "This is a message"; javax.jms.Message m = producerSession.createTextMessage(messageText); producer.send(m); TextMessage m2 = (TextMessage) consumer.receive(2000); assertNotNull(m2); assertEquals(messageText, m2.getText()); consumer.close(); tempQueue.delete(); assertFalse(conn.containsKnownDestination(SimpleString.toSimpleString(tempQueue.getQueueName()))); assertFalse(conn.containsTemporaryQueue(SimpleString.toSimpleString(tempQueue.getQueueName()))); } finally { if (conn != null) { conn.close(); } } } @Test