use of org.apache.activemq.artemis.tests.integration.stomp.util.ClientStompFrame in project activemq-artemis by apache.
the class StompV11Test method testUnsubscribe.
@Test
public void testUnsubscribe() throws Exception {
conn.connect(defUser, defPass);
subscribe(conn, "sub1", Stomp.Headers.Subscribe.AckModeValues.AUTO);
// send a message to our queue
sendJmsMessage("first message");
// receive message from socket
ClientStompFrame frame = conn.receiveFrame();
Assert.assertTrue(frame.getCommand().equals(Stomp.Responses.MESSAGE));
// remove suscription
unsubscribe(conn, "sub1", true);
// send a message to our queue
sendJmsMessage("second message");
frame = conn.receiveFrame(1000);
assertNull(frame);
conn.disconnect();
}
use of org.apache.activemq.artemis.tests.integration.stomp.util.ClientStompFrame in project activemq-artemis by apache.
the class StompV11Test method testRedeliveryWithClientAck.
@Test
public void testRedeliveryWithClientAck() throws Exception {
conn.connect(defUser, defPass);
subscribe(conn, "subscriptionId", Stomp.Headers.Subscribe.AckModeValues.CLIENT);
sendJmsMessage(getName());
ClientStompFrame frame = conn.receiveFrame();
assertTrue(frame.getCommand().equals(Stomp.Responses.MESSAGE));
conn.disconnect();
// message should be received since message was not acknowledged
MessageConsumer consumer = session.createConsumer(queue);
Message message = consumer.receive(1000);
Assert.assertNotNull(message);
Assert.assertTrue(message.getJMSRedelivered());
}
use of org.apache.activemq.artemis.tests.integration.stomp.util.ClientStompFrame in project activemq-artemis by apache.
the class StompV11Test method testNackWithWrongSubId.
@Test
public void testNackWithWrongSubId() 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);
nack(conn, "sub2", messageID);
ClientStompFrame error = conn.receiveFrame();
IntegrationTestLogger.LOGGER.info("Receiver error: " + error);
unsubscribe(conn, "sub1");
conn.disconnect();
// message should be still there
MessageConsumer consumer = session.createConsumer(queue);
Message message = consumer.receive(1000);
Assert.assertNotNull(message);
}
use of org.apache.activemq.artemis.tests.integration.stomp.util.ClientStompFrame in project activemq-artemis by apache.
the class StompV11Test method testHeartBeat2.
// server ping
@Test
public void testHeartBeat2() throws Exception {
// heart-beat (1,1)
ClientStompFrame frame = conn.createFrame(Stomp.Commands.CONNECT).addHeader(Stomp.Headers.Connect.HOST, "127.0.0.1").addHeader(Stomp.Headers.Connect.LOGIN, this.defUser).addHeader(Stomp.Headers.Connect.PASSCODE, this.defPass).addHeader(Stomp.Headers.Connect.HEART_BEAT, "1,1").addHeader(Stomp.Headers.Connect.ACCEPT_VERSION, "1.0,1.1");
ClientStompFrame reply = conn.sendFrame(frame);
assertEquals(Stomp.Responses.CONNECTED, reply.getCommand());
assertEquals("500,500", reply.getHeader(Stomp.Headers.Connect.HEART_BEAT));
conn.disconnect();
// heart-beat (500,1000)
conn = StompClientConnectionFactory.createClientConnection(uri);
frame = conn.createFrame(Stomp.Commands.CONNECT).addHeader(Stomp.Headers.Connect.HOST, "127.0.0.1").addHeader(Stomp.Headers.Connect.LOGIN, this.defUser).addHeader(Stomp.Headers.Connect.PASSCODE, this.defPass).addHeader(Stomp.Headers.Connect.HEART_BEAT, "500,1000").addHeader(Stomp.Headers.Connect.ACCEPT_VERSION, "1.0,1.1");
reply = conn.sendFrame(frame);
assertEquals(Stomp.Responses.CONNECTED, reply.getCommand());
assertEquals("1000,500", reply.getHeader(Stomp.Headers.Connect.HEART_BEAT));
IntegrationTestLogger.LOGGER.info("========== start pinger!");
conn.startPinger(500);
Thread.sleep(10000);
// now check the frame size
int size = conn.getServerPingNumber();
IntegrationTestLogger.LOGGER.info("ping received: " + size);
assertTrue(size > 5);
// now server side should be disconnected because we didn't send ping for 2 sec
// send will be ok
send(conn, getQueuePrefix() + getQueueName(), "text/plain", "Hello World");
conn.disconnect();
}
use of org.apache.activemq.artemis.tests.integration.stomp.util.ClientStompFrame in project activemq-artemis by apache.
the class StompV11Test method testAckModeClientIndividual.
@Test
public void testAckModeClientIndividual() throws Exception {
conn.connect(defUser, defPass);
subscribe(conn, "sub1", "client-individual");
int num = 50;
// send a bunch of messages
for (int i = 0; i < num; i++) {
this.sendJmsMessage("client-individual-ack" + i);
}
ClientStompFrame frame = null;
for (int i = 0; i < num; i++) {
frame = conn.receiveFrame();
assertNotNull(frame);
IntegrationTestLogger.LOGGER.info(i + " == received: " + frame);
// ack on even numbers
if (i % 2 == 0) {
ack(conn, "sub1", frame);
}
}
unsubscribe(conn, "sub1");
conn.disconnect();
// no messages can be received.
MessageConsumer consumer = session.createConsumer(queue);
TextMessage message = null;
for (int i = 0; i < num / 2; i++) {
message = (TextMessage) consumer.receive(1000);
Assert.assertNotNull(message);
IntegrationTestLogger.LOGGER.info("Legal: " + message.getText());
}
message = (TextMessage) consumer.receive(1000);
Assert.assertNull(message);
}
Aggregations