use of org.apache.activemq.artemis.tests.integration.stomp.util.ClientStompFrame in project activemq-artemis by apache.
the class StompV12Test method testSubscribeToTopicWithNoLocal.
@Test
public void testSubscribeToTopicWithNoLocal() throws Exception {
conn.connect(defUser, defPass);
subscribeTopic(conn, "sub1", null, null, true, true);
// send a message on the same connection => it should not be received
send(conn, getTopicPrefix() + getTopicName(), null, "Hello World");
ClientStompFrame frame = conn.receiveFrame(2000);
Assert.assertNull(frame);
// send message on another JMS connection => it should be received
sendJmsMessage(getName(), topic);
frame = conn.receiveFrame();
Assert.assertTrue(frame.getCommand().equals(Stomp.Responses.MESSAGE));
Assert.assertTrue(frame.getHeader(Stomp.Headers.Subscribe.DESTINATION).equals(getTopicPrefix() + getTopicName()));
Assert.assertTrue(frame.getBody().equals(getName()));
unsubscribe(conn, "sub1");
conn.disconnect();
}
use of org.apache.activemq.artemis.tests.integration.stomp.util.ClientStompFrame in project activemq-artemis by apache.
the class ExtraStompTest method testNoGarbageOnPersistentRedelivery.
public void testNoGarbageOnPersistentRedelivery(StompClientConnection conn) throws Exception {
ClientStompFrame frame = conn.createFrame(Stomp.Commands.SEND);
frame.addHeader(Stomp.Headers.Subscribe.DESTINATION, getQueuePrefix() + getQueueName());
frame.addHeader(Stomp.Headers.CONTENT_LENGTH, "11");
frame.addHeader(Stomp.Headers.Send.PERSISTENT, Boolean.TRUE.toString());
frame.setBody("Hello World");
conn.sendFrame(frame);
frame = conn.createFrame(Stomp.Commands.SEND);
frame.addHeader(Stomp.Headers.Subscribe.DESTINATION, getQueuePrefix() + getQueueName());
frame.addHeader(Stomp.Headers.CONTENT_LENGTH, "11");
frame.addHeader(Stomp.Headers.Send.PERSISTENT, Boolean.TRUE.toString());
frame.setBody("Hello World");
conn.sendFrame(frame);
frame = subscribe(conn, "a-sub", Stomp.Headers.Subscribe.AckModeValues.CLIENT);
// receive but don't ack
frame = conn.receiveFrame(10000);
System.out.println(frame);
frame = conn.receiveFrame(10000);
System.out.println(frame);
unsubscribe(conn, "a-sub");
frame = subscribe(conn, "a-sub");
frame = conn.receiveFrame(10000);
// second receive will get problem if trailing bytes
assertEquals("Hello World", frame.getBody());
// unsub
unsubscribe(conn, "a-sub");
}
use of org.apache.activemq.artemis.tests.integration.stomp.util.ClientStompFrame in project activemq-artemis by apache.
the class StompV11Test method testAck.
@Test
public void testAck() throws Exception {
conn.connect(defUser, defPass);
subscribe(conn, "sub1", Stomp.Headers.Subscribe.AckModeValues.CLIENT);
sendJmsMessage(getName());
ClientStompFrame frame = conn.receiveFrame();
String messageID = frame.getHeader(Stomp.Headers.Message.MESSAGE_ID);
ack(conn, "sub1", messageID, null);
unsubscribe(conn, "sub1");
conn.disconnect();
// Nack makes the message be dropped.
MessageConsumer consumer = session.createConsumer(queue);
Message message = consumer.receive(1000);
Assert.assertNull(message);
}
use of org.apache.activemq.artemis.tests.integration.stomp.util.ClientStompFrame in project activemq-artemis by apache.
the class StompV11Test method testAckModeClient2.
@Test
public void testAckModeClient2() throws Exception {
conn.connect(defUser, defPass);
subscribe(conn, "sub1", Stomp.Headers.Subscribe.AckModeValues.CLIENT);
Thread.sleep(1000);
int num = 50;
// send a bunch of messages
for (int i = 0; i < num; i++) {
this.sendJmsMessage("client-ack" + i);
}
ClientStompFrame frame = null;
for (int i = 0; i < num; i++) {
frame = conn.receiveFrame();
assertNotNull(frame);
// ack the 49th
if (i == num - 2) {
ack(conn, "sub1", frame);
}
}
unsubscribe(conn, "sub1");
conn.disconnect();
// no messages can be received.
MessageConsumer consumer = session.createConsumer(queue);
Message message = consumer.receive(10000);
Assert.assertNotNull(message);
message = consumer.receive(1000);
Assert.assertNull(message);
}
use of org.apache.activemq.artemis.tests.integration.stomp.util.ClientStompFrame in project activemq-artemis by apache.
the class StompV11Test method testSubscribeWithAutoAckAndSelector.
@Test
public void testSubscribeWithAutoAckAndSelector() throws Exception {
conn.connect(defUser, defPass);
subscribe(conn, "sub1", Stomp.Headers.Subscribe.AckModeValues.AUTO, null, "foo = 'zzz'");
sendJmsMessage("Ignored message", "foo", "1234");
sendJmsMessage("Real message", "foo", "zzz");
ClientStompFrame frame = conn.receiveFrame();
Assert.assertTrue("Should have received the real message but got: " + frame, frame.getBody().equals("Real message"));
conn.disconnect();
}
Aggregations