use of org.apache.activemq.artemis.tests.integration.stomp.util.ClientStompFrame in project activemq-artemis by apache.
the class StompTest method testDurableSubscriberWithReconnection.
@Test
public void testDurableSubscriberWithReconnection() throws Exception {
conn.connect(defUser, defPass, "myclientid");
subscribeTopic(conn, null, null, getName());
conn.disconnect();
Thread.sleep(500);
// send the message when the durable subscriber is disconnected
sendJmsMessage(getName(), topic);
conn.destroy();
conn = StompClientConnectionFactory.createClientConnection(uri);
conn.connect(defUser, defPass, "myclientid");
subscribeTopic(conn, null, null, getName());
ClientStompFrame frame = conn.receiveFrame(3000);
assertNotNull("Should have received a message from the durable subscription", frame);
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, true);
conn.disconnect();
}
use of org.apache.activemq.artemis.tests.integration.stomp.util.ClientStompFrame in project activemq-artemis by apache.
the class StompTest method testDurableSubscriber.
@Test
public void testDurableSubscriber() throws Exception {
conn.connect(defUser, defPass, "myclientid");
subscribeTopic(conn, null, null, getName(), true);
ClientStompFrame response = subscribeTopic(conn, null, null, getName(), true);
// creating a subscriber with the same durable-subscriber-name must fail
Assert.assertEquals(Stomp.Responses.ERROR, response.getCommand());
conn.disconnect();
}
use of org.apache.activemq.artemis.tests.integration.stomp.util.ClientStompFrame in project activemq-artemis by apache.
the class StompTest method testSendMessageWithLongHeaders.
@Test
public void testSendMessageWithLongHeaders() throws Exception {
MessageConsumer consumer = session.createConsumer(queue);
conn.connect(defUser, defPass);
StringBuffer buffer = new StringBuffer();
for (int i = 0; i < 1024; i++) {
buffer.append("a");
}
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("longHeader", buffer.toString()).setBody("Hello World");
conn.sendFrame(frame);
TextMessage message = (TextMessage) consumer.receive(1000);
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("longHeader", 1024, message.getStringProperty("longHeader").length());
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 testTopicExistsAfterNoUnsubscribeDisconnect.
@Test
public void testTopicExistsAfterNoUnsubscribeDisconnect() throws Exception {
conn.connect(defUser, defPass);
subscribeTopic(conn, null, null, null, true);
// disconnect, _without unsubscribing_
conn.disconnect();
Thread.sleep(500);
conn.destroy();
// connect again
conn = StompClientConnectionFactory.createClientConnection(uri);
conn.connect(defUser, defPass);
// send a receipted message to the topic
ClientStompFrame response = send(conn, getTopicPrefix() + getTopicName(), null, "Hello World", true);
assertEquals(Stomp.Responses.RECEIPT, response.getCommand());
// ...and nothing else
ClientStompFrame frame = conn.receiveFrame(2000);
log.info("Received frame: " + frame);
Assert.assertNull(frame);
conn.disconnect();
}
use of org.apache.activemq.artemis.tests.integration.stomp.util.ClientStompFrame in project activemq-artemis by apache.
the class StompTest method testSubscribeWithAutoAckAndSelector.
@Test
public void testSubscribeWithAutoAckAndSelector() throws Exception {
conn.connect(defUser, defPass);
subscribe(conn, null, Stomp.Headers.Subscribe.AckModeValues.AUTO, null, "foo = 'zzz'");
sendJmsMessage("Ignored message", "foo", "1234");
sendJmsMessage("Real message", "foo", "zzz");
ClientStompFrame frame = conn.receiveFrame(10000);
Assert.assertEquals(Stomp.Responses.MESSAGE, frame.getCommand());
Assert.assertTrue("Should have received the real message but got: " + frame, frame.getBody().equals("Real message"));
conn.disconnect();
}
Aggregations