use of org.apache.activemq.artemis.tests.integration.stomp.util.ClientStompFrame in project activemq-artemis by apache.
the class AMQPToStompTest method testSendAmqpReceiveStomp.
@Test
public void testSendAmqpReceiveStomp() throws Exception {
AmqpClient client = new AmqpClient(new URI("tcp://127.0.0.1:61616"), null, null);
AmqpConnection amqpconnection = client.connect();
try {
AmqpSession session = amqpconnection.createSession();
AmqpSender sender = session.createSender(queueName);
AmqpMessage message = new AmqpMessage();
message.setText("mine");
sender.send(message);
} finally {
amqpconnection.close();
}
StompClientConnection conn = StompClientConnectionFactory.createClientConnection(new URI("tcp://127.0.0.1:61616"));
conn.connect(null, null);
try {
StompTestBase.subscribeQueue(conn, null, queueName);
ClientStompFrame frame = conn.receiveFrame();
assertNotNull(frame);
assertNotNull(frame.getBody());
assertTrue(frame.getBody().contains("mine"));
} finally {
conn.closeTransport();
}
}
use of org.apache.activemq.artemis.tests.integration.stomp.util.ClientStompFrame in project activemq-artemis by apache.
the class StompTest method assertSubscribeWithClientAckThenConsumeWithAutoAck.
protected void assertSubscribeWithClientAckThenConsumeWithAutoAck(boolean sendDisconnect) throws Exception {
conn.connect(defUser, defPass);
subscribe(conn, null, Stomp.Headers.Subscribe.AckModeValues.CLIENT);
sendJmsMessage(getName());
ClientStompFrame frame = conn.receiveFrame(10000);
Assert.assertEquals(Stomp.Responses.MESSAGE, frame.getCommand());
log.info("Reconnecting!");
if (sendDisconnect) {
conn.disconnect();
conn.destroy();
conn = StompClientConnectionFactory.createClientConnection(uri);
} else {
conn.destroy();
conn = StompClientConnectionFactory.createClientConnection(uri);
}
// message should be received since message was not acknowledged
conn.connect(defUser, defPass);
subscribe(conn, null);
frame = conn.receiveFrame(10000);
Assert.assertEquals(Stomp.Responses.MESSAGE, frame.getCommand());
conn.disconnect();
conn.destroy();
conn = StompClientConnectionFactory.createClientConnection(uri);
// now let's make sure we don't see the message again
conn.connect(defUser, defPass);
subscribe(conn, null, Stomp.Headers.Subscribe.AckModeValues.AUTO, null, true);
sendJmsMessage("shouldBeNextMessage");
frame = conn.receiveFrame(10000);
Assert.assertEquals(Stomp.Responses.MESSAGE, frame.getCommand());
Assert.assertEquals("shouldBeNextMessage", frame.getBody());
}
use of org.apache.activemq.artemis.tests.integration.stomp.util.ClientStompFrame in project activemq-artemis by apache.
the class StompTest method testSubscribeWithClientAck.
@Test
public void testSubscribeWithClientAck() throws Exception {
conn.connect(defUser, defPass);
subscribe(conn, null, Stomp.Headers.Subscribe.AckModeValues.CLIENT);
sendJmsMessage(getName());
ClientStompFrame frame = conn.receiveFrame(10000);
Assert.assertEquals(Stomp.Responses.MESSAGE, frame.getCommand());
Assert.assertNotNull(frame.getHeader(Stomp.Headers.Message.MESSAGE_ID));
ack(conn, null, frame);
conn.disconnect();
// message should not be received since message was acknowledged by the client
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 StompTest method testSubscribeToTopicWithNoLocal.
@Test
public void testSubscribeToTopicWithNoLocal() throws Exception {
conn.connect(defUser, defPass);
subscribeTopic(conn, null, null, null, true, true);
// send a message on the same connection => it should not be received is noLocal = true on subscribe
send(conn, getTopicPrefix() + getTopicName(), null, "Hello World");
ClientStompFrame frame = conn.receiveFrame(2000);
log.info("Received frame: " + frame);
Assert.assertNull("No message should have been received since subscription was removed", frame);
// send message on another JMS connection => it should be received
sendJmsMessage(getName(), topic);
frame = conn.receiveFrame(10000);
Assert.assertEquals(Stomp.Responses.MESSAGE, frame.getCommand());
Assert.assertEquals(getTopicPrefix() + getTopicName(), frame.getHeader(Stomp.Headers.Send.DESTINATION));
Assert.assertEquals(getName(), frame.getBody());
conn.disconnect();
}
use of org.apache.activemq.artemis.tests.integration.stomp.util.ClientStompFrame in project activemq-artemis by apache.
the class StompTest method testUnsubscribeWithID.
@Test
public void testUnsubscribeWithID() throws Exception {
conn.connect(defUser, defPass);
subscribe(conn, "mysubid", Stomp.Headers.Subscribe.AckModeValues.AUTO);
// send a message to our queue
sendJmsMessage("first message");
// receive message from socket
ClientStompFrame frame = conn.receiveFrame(10000);
Assert.assertEquals(Stomp.Responses.MESSAGE, frame.getCommand());
// remove suscription
unsubscribe(conn, "mysubid", null, true, false);
// send a message to our queue
sendJmsMessage("second message");
frame = conn.receiveFrame(1000);
log.info("Received frame: " + frame);
Assert.assertNull("No message should have been received since subscription was removed", frame);
}
Aggregations