use of javax.jms.TemporaryQueue in project activemq-artemis by apache.
the class AdvisoryTempDestinationTests method testMessageDeliveryAdvisory.
public void testMessageDeliveryAdvisory() throws Exception {
Session s = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
TemporaryQueue queue = s.createTemporaryQueue();
MessageConsumer consumer = s.createConsumer(queue);
assertNotNull(consumer);
Topic advisoryTopic = AdvisorySupport.getMessageDeliveredAdvisoryTopic((ActiveMQDestination) queue);
MessageConsumer advisoryConsumer = s.createConsumer(advisoryTopic);
// start throwing messages at the consumer
MessageProducer producer = s.createProducer(queue);
BytesMessage m = s.createBytesMessage();
m.writeBytes(new byte[1024]);
producer.send(m);
Message msg = advisoryConsumer.receive(1000);
assertNotNull(msg);
}
use of javax.jms.TemporaryQueue in project activemq-artemis by apache.
the class TempDestLoadTest method testLoadTempAdvisoryQueues.
public void testLoadTempAdvisoryQueues() throws Exception {
for (int i = 0; i < MESSAGE_COUNT; i++) {
TemporaryQueue tempQueue = session.createTemporaryQueue();
MessageConsumer consumer = session.createConsumer(tempQueue);
MessageProducer producer = session.createProducer(tempQueue);
consumer.close();
producer.close();
tempQueue.delete();
}
AdvisoryBroker ab = (AdvisoryBroker) broker.getBroker().getAdaptor(AdvisoryBroker.class);
assertTrue(ab.getAdvisoryDestinations().size() == 0);
assertTrue(ab.getAdvisoryConsumers().size() == 0);
assertTrue(ab.getAdvisoryProducers().size() == 0);
RegionBroker rb = (RegionBroker) broker.getBroker().getAdaptor(RegionBroker.class);
for (Destination dest : rb.getDestinationMap().values()) {
LOG.debug("Destination: {}", dest);
}
// there should be at least 2 destinations - advisories -
// 1 for the connection + 1 generic ones
assertTrue("Should be at least 2 destinations", rb.getDestinationMap().size() > 2);
}
use of javax.jms.TemporaryQueue in project activemq-artemis by apache.
the class JMSTemporaryDestinationTest method testCreateTemporaryQueue.
@Test(timeout = 60000)
public void testCreateTemporaryQueue() throws Throwable {
Connection connection = createConnection();
try {
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
TemporaryQueue queue = session.createTemporaryQueue();
System.out.println("queue:" + queue.getQueueName());
MessageProducer producer = session.createProducer(queue);
TextMessage message = session.createTextMessage();
message.setText("Message temporary");
producer.send(message);
MessageConsumer consumer = session.createConsumer(queue);
connection.start();
message = (TextMessage) consumer.receive(5000);
assertNotNull(message);
} finally {
connection.close();
}
}
use of javax.jms.TemporaryQueue in project activemq-artemis by apache.
the class JMSMessageProducerTest method testReplyToUsingQueue.
@Test(timeout = 60000)
public void testReplyToUsingQueue() throws Throwable {
Connection connection = createConnection();
try {
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
TemporaryQueue queue = session.createTemporaryQueue();
MessageProducer p = session.createProducer(queue);
TextMessage message = session.createTextMessage();
message.setText("Message temporary");
message.setJMSReplyTo(session.createQueue(getQueueName()));
p.send(message);
MessageConsumer cons = session.createConsumer(queue);
connection.start();
message = (TextMessage) cons.receive(5000);
assertNotNull(message);
Destination jmsReplyTo = message.getJMSReplyTo();
assertNotNull(jmsReplyTo);
assertNotNull(message);
} finally {
connection.close();
}
}
use of javax.jms.TemporaryQueue in project activemq-artemis by apache.
the class JMSMessageProducerTest method testReplyToUsingTempQueue.
@Test(timeout = 60000)
public void testReplyToUsingTempQueue() throws Throwable {
Connection connection = createConnection();
try {
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
TemporaryQueue queue = session.createTemporaryQueue();
MessageProducer p = session.createProducer(queue);
TextMessage message = session.createTextMessage();
message.setText("Message temporary");
message.setJMSReplyTo(session.createTemporaryQueue());
p.send(message);
MessageConsumer cons = session.createConsumer(queue);
connection.start();
message = (TextMessage) cons.receive(5000);
Destination jmsReplyTo = message.getJMSReplyTo();
assertNotNull(jmsReplyTo);
assertNotNull(message);
} finally {
connection.close();
}
}
Aggregations