Search in sources :

Example 1 with ActiveMQTempQueue

use of org.apache.activemq.command.ActiveMQTempQueue in project activemq-artemis by apache.

the class RequestReplyNoAdvisoryNetworkTest method doTestNonAdvisoryNetworkRequestReply.

public void doTestNonAdvisoryNetworkRequestReply() throws Exception {
    waitForBridgeFormation(a, 1, 0);
    waitForBridgeFormation(b, 1, 0);
    ActiveMQConnectionFactory sendFactory = createConnectionFactory(a);
    ActiveMQConnection sendConnection = createConnection(sendFactory);
    ActiveMQSession sendSession = (ActiveMQSession) sendConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
    MessageProducer producer = sendSession.createProducer(sendQ);
    ActiveMQTempQueue realReplyQ = (ActiveMQTempQueue) sendSession.createTemporaryQueue();
    TextMessage message = sendSession.createTextMessage("1");
    message.setJMSReplyTo(realReplyQ);
    producer.send(message);
    LOG.info("request sent");
    // responder
    ActiveMQConnectionFactory consumerFactory = createConnectionFactory(b);
    ActiveMQConnection consumerConnection = createConnection(consumerFactory);
    ActiveMQSession consumerSession = (ActiveMQSession) consumerConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
    MessageConsumer consumer = consumerSession.createConsumer(sendQ);
    TextMessage received = (TextMessage) consumer.receive(receiveTimeout);
    assertNotNull("got request from sender ok", received);
    LOG.info("got request, sending reply");
    MessageProducer consumerProducer = consumerSession.createProducer(received.getJMSReplyTo());
    consumerProducer.send(consumerSession.createTextMessage("got " + received.getText()));
    // temp dest on reply broker tied to this connection, setOptimizedDispatch=true ensures
    // message gets delivered before destination is removed
    consumerConnection.close();
    // reply consumer
    MessageConsumer replyConsumer = sendSession.createConsumer(realReplyQ);
    TextMessage reply = (TextMessage) replyConsumer.receive(receiveTimeout);
    assertNotNull("expected reply message", reply);
    assertEquals("text is as expected", "got 1", reply.getText());
    sendConnection.close();
    LOG.info("checking for dangling temp destinations");
    // ensure all temp dests get cleaned up on all brokers
    for (BrokerService brokerService : brokers) {
        final RegionBroker regionBroker = (RegionBroker) brokerService.getRegionBroker();
        assertTrue("all temps are gone on " + regionBroker.getBrokerName(), Wait.waitFor(new Wait.Condition() {

            @Override
            public boolean isSatisified() throws Exception {
                Map<?, ?> tempTopics = regionBroker.getTempTopicRegion().getDestinationMap();
                LOG.info("temp topics on " + regionBroker.getBrokerName() + ", " + tempTopics);
                Map<?, ?> tempQ = regionBroker.getTempQueueRegion().getDestinationMap();
                LOG.info("temp queues on " + regionBroker.getBrokerName() + ", " + tempQ);
                return tempQ.isEmpty() && tempTopics.isEmpty();
            }
        }));
    }
}
Also used : ActiveMQConnectionFactory(org.apache.activemq.ActiveMQConnectionFactory) MessageConsumer(javax.jms.MessageConsumer) ActiveMQSession(org.apache.activemq.ActiveMQSession) RegionBroker(org.apache.activemq.broker.region.RegionBroker) ActiveMQConnection(org.apache.activemq.ActiveMQConnection) MessageProducer(javax.jms.MessageProducer) BrokerService(org.apache.activemq.broker.BrokerService) ActiveMQTempQueue(org.apache.activemq.command.ActiveMQTempQueue) TextMessage(javax.jms.TextMessage)

Example 2 with ActiveMQTempQueue

use of org.apache.activemq.command.ActiveMQTempQueue in project activemq-artemis by apache.

the class NetworkDestinationFilterTest method testFilter.

public void testFilter() throws Exception {
    NetworkBridgeConfiguration config = new NetworkBridgeConfiguration();
    assertEquals(AdvisorySupport.CONSUMER_ADVISORY_TOPIC_PREFIX + ">", config.getDestinationFilter());
    List<ActiveMQDestination> dests = new ArrayList<>();
    config.setDynamicallyIncludedDestinations(dests);
    assertEquals(AdvisorySupport.CONSUMER_ADVISORY_TOPIC_PREFIX + ">", config.getDestinationFilter());
    dests.add(new ActiveMQQueue("TEST.>"));
    dests.add(new ActiveMQTopic("TEST.>"));
    dests.add(new ActiveMQTempQueue("TEST.>"));
    String prefix = AdvisorySupport.CONSUMER_ADVISORY_TOPIC_PREFIX;
    assertEquals(prefix + "Queue.TEST.>," + prefix + "Topic.TEST.>", config.getDestinationFilter());
}
Also used : ActiveMQTopic(org.apache.activemq.command.ActiveMQTopic) ArrayList(java.util.ArrayList) ActiveMQQueue(org.apache.activemq.command.ActiveMQQueue) ActiveMQTempQueue(org.apache.activemq.command.ActiveMQTempQueue) ActiveMQDestination(org.apache.activemq.command.ActiveMQDestination)

Example 3 with ActiveMQTempQueue

use of org.apache.activemq.command.ActiveMQTempQueue in project activemq-artemis by apache.

the class ActiveMQTempQueueTest method createObject.

@Override
public Object createObject() throws Exception {
    ActiveMQTempQueue info = new ActiveMQTempQueue();
    populateObject(info);
    return info;
}
Also used : ActiveMQTempQueue(org.apache.activemq.command.ActiveMQTempQueue)

Example 4 with ActiveMQTempQueue

use of org.apache.activemq.command.ActiveMQTempQueue in project activemq-artemis by apache.

the class ActiveMQTempQueueTest method populateObject.

@Override
protected void populateObject(Object object) throws Exception {
    super.populateObject(object);
    ActiveMQTempQueue info = (ActiveMQTempQueue) object;
}
Also used : ActiveMQTempQueue(org.apache.activemq.command.ActiveMQTempQueue)

Example 5 with ActiveMQTempQueue

use of org.apache.activemq.command.ActiveMQTempQueue in project activemq-artemis by apache.

the class ActiveMQTempQueueTest method createObject.

@Override
public Object createObject() throws Exception {
    ActiveMQTempQueue info = new ActiveMQTempQueue();
    populateObject(info);
    return info;
}
Also used : ActiveMQTempQueue(org.apache.activemq.command.ActiveMQTempQueue)

Aggregations

ActiveMQTempQueue (org.apache.activemq.command.ActiveMQTempQueue)9 ActiveMQDestination (org.apache.activemq.command.ActiveMQDestination)3 ActiveMQTopic (org.apache.activemq.command.ActiveMQTopic)3 ActiveMQQueue (org.apache.activemq.command.ActiveMQQueue)2 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 IllegalStateException (javax.jms.IllegalStateException)1 InvalidClientIDException (javax.jms.InvalidClientIDException)1 InvalidDestinationException (javax.jms.InvalidDestinationException)1 JMSSecurityException (javax.jms.JMSSecurityException)1 MessageConsumer (javax.jms.MessageConsumer)1 MessageProducer (javax.jms.MessageProducer)1 TextMessage (javax.jms.TextMessage)1 XAException (javax.transaction.xa.XAException)1 ActiveMQConnection (org.apache.activemq.ActiveMQConnection)1 ActiveMQConnectionFactory (org.apache.activemq.ActiveMQConnectionFactory)1 ActiveMQSession (org.apache.activemq.ActiveMQSession)1 ActiveMQAddressExistsException (org.apache.activemq.artemis.api.core.ActiveMQAddressExistsException)1 ActiveMQException (org.apache.activemq.artemis.api.core.ActiveMQException)1 ActiveMQNonExistentQueueException (org.apache.activemq.artemis.api.core.ActiveMQNonExistentQueueException)1