use of org.apache.activemq.artemis.tests.integration.stomp.util.ClientStompFrame in project activemq-artemis by apache.
the class StompTest method testMultiProtocolConsumers.
// HORNETQ-1007
@Test
public void testMultiProtocolConsumers() throws Exception {
final int TIME_OUT = 2000;
int count = 1000;
// Create 2 core consumers
MessageConsumer consumer1 = session.createConsumer(topic);
MessageConsumer consumer2 = session.createConsumer(topic);
// connect and subscribe STOMP consumer
conn.connect(defUser, defPass);
subscribeTopic(conn, null, null, null, true);
MessageProducer producer = session.createProducer(topic);
TextMessage message = session.createTextMessage(getName());
for (int i = 1; i <= count; i++) {
producer.send(message);
Assert.assertNotNull(consumer1.receive(TIME_OUT));
Assert.assertNotNull(consumer2.receive(TIME_OUT));
ClientStompFrame frame = conn.receiveFrame(TIME_OUT);
Assert.assertEquals(Stomp.Responses.MESSAGE, frame.getCommand());
Assert.assertEquals(getTopicPrefix() + getTopicName(), frame.getHeader(Stomp.Headers.Send.DESTINATION));
Assert.assertEquals(getName(), frame.getBody());
}
consumer1.close();
consumer2.close();
unsubscribe(conn, null, getTopicPrefix() + getTopicName(), true, false);
sendJmsMessage(getName(), topic);
ClientStompFrame frame = conn.receiveFrame(TIME_OUT);
log.info("Received frame: " + frame);
Assert.assertNull("No message should have been received since subscription was removed", frame);
conn.disconnect();
}
use of org.apache.activemq.artemis.tests.integration.stomp.util.ClientStompFrame in project activemq-artemis by apache.
the class StompTest method testBeginSameTransactionTwice.
@Test
public void testBeginSameTransactionTwice() throws Exception {
conn.connect(defUser, defPass);
beginTransaction(conn, "tx1");
beginTransaction(conn, "tx1");
ClientStompFrame frame = conn.receiveFrame(1000);
Assert.assertEquals(Stomp.Responses.ERROR, frame.getCommand());
}
use of org.apache.activemq.artemis.tests.integration.stomp.util.ClientStompFrame in project activemq-artemis by apache.
the class StompTest method testSendMessageWithDelay.
@Test
public void testSendMessageWithDelay() throws Exception {
MessageConsumer consumer = session.createConsumer(queue);
conn.connect(defUser, defPass);
ClientStompFrame frame = conn.createFrame(Stomp.Commands.SEND).addHeader(Stomp.Headers.Send.DESTINATION, getQueuePrefix() + getQueueName()).addHeader("foo", "abc").addHeader("bar", "123").addHeader("correlation-id", "c123").addHeader("persistent", "true").addHeader("type", "t345").addHeader("JMSXGroupID", "abc").addHeader("priority", "3").addHeader("AMQ_SCHEDULED_DELAY", "2000").setBody("Hello World");
conn.sendFrame(frame);
assertNull("Should not receive message yet", consumer.receive(1000));
TextMessage message = (TextMessage) consumer.receive(4000);
Assert.assertNotNull(message);
Assert.assertEquals("Hello World", message.getText());
Assert.assertEquals("JMSCorrelationID", "c123", message.getJMSCorrelationID());
Assert.assertEquals("getJMSType", "t345", message.getJMSType());
Assert.assertEquals("getJMSPriority", 3, message.getJMSPriority());
Assert.assertEquals(javax.jms.DeliveryMode.PERSISTENT, message.getJMSDeliveryMode());
Assert.assertEquals("foo", "abc", message.getStringProperty("foo"));
Assert.assertEquals("JMSXGroupID", "abc", message.getStringProperty("JMSXGroupID"));
}
use of org.apache.activemq.artemis.tests.integration.stomp.util.ClientStompFrame in project activemq-artemis by apache.
the class StompTest method sendMQTTReceiveSTOMP.
@Test
public void sendMQTTReceiveSTOMP() throws Exception {
String payload = "This is a test message";
// Set up STOMP subscription
conn.connect(defUser, defPass);
subscribe(conn, null, Stomp.Headers.Subscribe.AckModeValues.AUTO);
// Send MQTT Message
MQTTClientProvider clientProvider = new FuseMQTTClientProvider();
clientProvider.connect("tcp://" + hostname + ":" + port);
clientProvider.publish(getQueuePrefix() + getQueueName(), payload.getBytes(), 0);
clientProvider.disconnect();
// Receive STOMP Message
ClientStompFrame frame = conn.receiveFrame();
assertTrue(frame.getBody().contains(payload));
}
use of org.apache.activemq.artemis.tests.integration.stomp.util.ClientStompFrame in project activemq-artemis by apache.
the class StompTest method testSubscribeToTopic.
@Test
public void testSubscribeToTopic() throws Exception {
final int baselineQueueCount = server.getActiveMQServer().getActiveMQServerControl().getQueueNames().length;
conn.connect(defUser, defPass);
subscribeTopic(conn, null, null, null, true);
assertTrue("Subscription queue should be created here", Wait.waitFor(new Wait.Condition() {
@Override
public boolean isSatisfied() throws Exception {
int length = server.getActiveMQServer().getActiveMQServerControl().getQueueNames().length;
if (length - baselineQueueCount == 1) {
return true;
} else {
log.info("Queue count: " + (length - baselineQueueCount));
return false;
}
}
}, TimeUnit.SECONDS.toMillis(10), TimeUnit.MILLISECONDS.toMillis(100)));
sendJmsMessage(getName(), topic);
ClientStompFrame frame = conn.receiveFrame(1000);
Assert.assertEquals(Stomp.Responses.MESSAGE, frame.getCommand());
Assert.assertEquals(getTopicPrefix() + getTopicName(), frame.getHeader(Stomp.Headers.Send.DESTINATION));
Assert.assertEquals(getName(), frame.getBody());
unsubscribe(conn, null, getTopicPrefix() + getTopicName(), true, false);
sendJmsMessage(getName(), topic);
frame = conn.receiveFrame(1000);
log.info("Received frame: " + frame);
Assert.assertNull("No message should have been received since subscription was removed", frame);
assertEquals("Subscription queue should be deleted", 0, server.getActiveMQServer().getActiveMQServerControl().getQueueNames().length - baselineQueueCount);
conn.disconnect();
}
Aggregations