use of org.apache.activemq.artemis.tests.integration.stomp.util.ClientStompFrame in project activemq-artemis by apache.
the class StompV12Test method ack.
// STOMP 1.2-specific ACK and NACK methods
private void ack(StompClientConnection conn, String mid) throws IOException, InterruptedException {
ClientStompFrame ackFrame = conn.createFrame(Stomp.Commands.ACK);
ackFrame.addHeader(Stomp.Headers.Subscribe.ID, mid);
conn.sendFrame(ackFrame);
}
use of org.apache.activemq.artemis.tests.integration.stomp.util.ClientStompFrame in project activemq-artemis by apache.
the class StompV12Test method testSubscribeToTopic.
@Test
public void testSubscribeToTopic() throws Exception {
conn.connect(defUser, defPass);
subscribeTopic(conn, "sub1", null, null, true);
sendJmsMessage(getName(), topic);
ClientStompFrame 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", true);
sendJmsMessage(getName(), topic);
frame = conn.receiveFrame(1000);
Assert.assertNull(frame);
conn.disconnect();
}
use of org.apache.activemq.artemis.tests.integration.stomp.util.ClientStompFrame in project activemq-artemis by apache.
the class StompV12Test method testNack.
@Test
public void testNack() throws Exception {
conn.connect(defUser, defPass);
subscribe(conn, "sub1", "client");
sendJmsMessage(getName());
ClientStompFrame frame = conn.receiveFrame();
String messageID = frame.getHeader(Stomp.Headers.Message.MESSAGE_ID);
nack(conn, messageID);
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 StompV12Test method testDurableSubscriberWithReconnection.
@Test
public void testDurableSubscriberWithReconnection() throws Exception {
conn.connect(defUser, defPass, CLIENT_ID);
subscribeTopic(conn, "sub1", Stomp.Headers.Subscribe.AckModeValues.AUTO, getName());
ClientStompFrame frame = conn.createFrame("DISCONNECT");
frame.addHeader(Stomp.Headers.RECEIPT_REQUESTED, "1");
ClientStompFrame result = conn.sendFrame(frame);
if (result == null || (!Stomp.Responses.RECEIPT.equals(result.getCommand())) || (!"1".equals(result.getHeader("receipt-id")))) {
Assert.fail("Disconnect failed! " + result);
}
// send the message when the durable subscriber is disconnected
sendJmsMessage(getName(), topic);
conn.destroy();
conn = (StompClientConnectionV12) StompClientConnectionFactory.createClientConnection(uri);
conn.connect(defUser, defPass, CLIENT_ID);
subscribeTopic(conn, "sub1", Stomp.Headers.Subscribe.AckModeValues.AUTO, getName());
// we must have received the message
frame = conn.receiveFrame();
Assert.assertTrue(frame.getCommand().equals(Stomp.Responses.MESSAGE));
Assert.assertNotNull(frame.getHeader(Stomp.Headers.Subscribe.DESTINATION));
Assert.assertEquals(getName(), frame.getBody());
unsubscribe(conn, "sub1");
conn.disconnect();
}
use of org.apache.activemq.artemis.tests.integration.stomp.util.ClientStompFrame in project activemq-artemis by apache.
the class StompV12Test method testSubscribeWithMessageSentWithProperties.
@Test
public void testSubscribeWithMessageSentWithProperties() throws Exception {
conn.connect(defUser, defPass);
subscribe(conn, "sub1", Stomp.Headers.Subscribe.AckModeValues.AUTO);
MessageProducer producer = session.createProducer(queue);
BytesMessage message = session.createBytesMessage();
message.setStringProperty("S", "value");
message.setBooleanProperty("n", false);
message.setByteProperty("byte", (byte) 9);
message.setDoubleProperty("d", 2.0);
message.setFloatProperty("f", (float) 6.0);
message.setIntProperty("i", 10);
message.setLongProperty("l", 121);
message.setShortProperty("s", (short) 12);
message.writeBytes("Hello World".getBytes(StandardCharsets.UTF_8));
producer.send(message);
ClientStompFrame frame = conn.receiveFrame();
Assert.assertNotNull(frame);
Assert.assertTrue(frame.getHeader("S") != null);
Assert.assertTrue(frame.getHeader("n") != null);
Assert.assertTrue(frame.getHeader("byte") != null);
Assert.assertTrue(frame.getHeader("d") != null);
Assert.assertTrue(frame.getHeader("f") != null);
Assert.assertTrue(frame.getHeader("i") != null);
Assert.assertTrue(frame.getHeader("l") != null);
Assert.assertTrue(frame.getHeader("s") != null);
Assert.assertEquals("Hello World", frame.getBody());
conn.disconnect();
}
Aggregations