use of org.apache.activemq.command.ActiveMQQueue in project activemq-artemis by apache.
the class DestinationListenerTest method testProducerForcesNotificationOfNewDestination.
public void testProducerForcesNotificationOfNewDestination() throws Exception {
// now lets cause a destination to be created
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
ActiveMQQueue newQueue = new ActiveMQQueue("Test.Beer");
MessageProducer producer = session.createProducer(newQueue);
TextMessage message = session.createTextMessage("<hello>world</hello>");
producer.send(message);
Thread.sleep(3000);
assertThat(newQueue, isIn(newDestinations));
LOG.info("New destinations are: " + newDestinations);
}
use of org.apache.activemq.command.ActiveMQQueue in project activemq-artemis by apache.
the class BrokerBenchmark method initCombosForTestPerformance.
public void initCombosForTestPerformance() {
addCombinationValues("destination", new Object[] { new ActiveMQQueue("TEST"), new ActiveMQTopic("TEST") });
addCombinationValues("PRODUCER_COUNT", new Object[] { new Integer("1"), new Integer("10") });
addCombinationValues("CONSUMER_COUNT", new Object[] { new Integer("1"), new Integer("10") });
addCombinationValues("CONSUMER_COUNT", new Object[] { new Integer("1"), new Integer("10") });
addCombinationValues("deliveryMode", new Object[] { Boolean.TRUE });
}
use of org.apache.activemq.command.ActiveMQQueue in project activemq-artemis by apache.
the class JmsMultipleClientsTestSupport method createDestination.
protected ActiveMQDestination createDestination() throws JMSException {
String name = "." + getClass().getName() + "." + getName();
// ensure not inadvertently composite because of combos
name = name.replace(' ', '_');
name = name.replace(',', '&');
if (topic) {
destination = new ActiveMQTopic("Topic" + name);
return (ActiveMQDestination) destination;
} else {
destination = new ActiveMQQueue("Queue" + name);
return (ActiveMQDestination) destination;
}
}
use of org.apache.activemq.command.ActiveMQQueue in project activemq-artemis by apache.
the class JmsQueueBrowserTest method testReceiveBrowseReceive.
/**
* Tests the queue browser. Browses the messages then the consumer tries to receive them. The messages should still
* be in the queue even when it was browsed.
*
* @throws Exception
*/
public void testReceiveBrowseReceive() throws Exception {
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
ActiveMQQueue destination = new ActiveMQQueue("TEST");
MessageProducer producer = session.createProducer(destination);
MessageConsumer consumer = session.createConsumer(destination);
connection.start();
Message[] outbound = new Message[] { session.createTextMessage("First Message"), session.createTextMessage("Second Message"), session.createTextMessage("Third Message") };
// lets consume any outstanding messages from previous test runs
while (consumer.receive(1000) != null) {
}
producer.send(outbound[0]);
producer.send(outbound[1]);
producer.send(outbound[2]);
// Get the first.
assertEquals(outbound[0], consumer.receive(1000));
consumer.close();
QueueBrowser browser = session.createBrowser(destination);
Enumeration<?> enumeration = browser.getEnumeration();
// browse the second
assertTrue("should have received the second message", enumeration.hasMoreElements());
assertEquals(outbound[1], enumeration.nextElement());
// browse the third.
assertTrue("Should have received the third message", enumeration.hasMoreElements());
assertEquals(outbound[2], enumeration.nextElement());
// There should be no more.
boolean tooMany = false;
while (enumeration.hasMoreElements()) {
LOG.info("Got extra message: " + ((TextMessage) enumeration.nextElement()).getText());
tooMany = true;
}
assertFalse(tooMany);
browser.close();
// Re-open the consumer.
consumer = session.createConsumer(destination);
// Receive the second.
assertEquals(outbound[1], consumer.receive(1000));
// Receive the third.
assertEquals(outbound[2], consumer.receive(1000));
consumer.close();
}
use of org.apache.activemq.command.ActiveMQQueue in project activemq-artemis by apache.
the class JmsQueueBrowserTest method testLargeNumberOfMessages.
public void testLargeNumberOfMessages() throws Exception {
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
ActiveMQQueue destination = new ActiveMQQueue("TEST");
connection.start();
MessageProducer producer = session.createProducer(destination);
int numberOfMessages = 4096;
for (int i = 0; i < numberOfMessages; i++) {
producer.send(session.createTextMessage("Message: " + i));
}
QueueBrowser browser = session.createBrowser(destination);
Enumeration<?> enumeration = browser.getEnumeration();
assertTrue(enumeration.hasMoreElements());
int numberBrowsed = 0;
while (enumeration.hasMoreElements()) {
Message browsed = (Message) enumeration.nextElement();
if (LOG.isDebugEnabled()) {
LOG.debug("Browsed Message [{}]", browsed.getJMSMessageID());
}
numberBrowsed++;
}
System.out.println("Number browsed: " + numberBrowsed);
assertEquals(numberOfMessages, numberBrowsed);
browser.close();
producer.close();
}
Aggregations