use of org.apache.activemq.transport.amqp.client.AmqpSession in project activemq-artemis by apache.
the class AmqpLargeMessageTest method sendMessages.
private void sendMessages(int nMsgs, AmqpConnection connection) throws Exception {
connection.connect();
AmqpSession session = connection.createSession();
AmqpSender sender = session.createSender(testQueueName);
for (int i = 0; i < nMsgs; ++i) {
AmqpMessage message = createAmqpMessage((byte) 'A', PAYLOAD);
message.setApplicationProperty("i", (Integer) i);
message.setDurable(true);
sender.send(message);
}
session.close();
}
use of org.apache.activemq.transport.amqp.client.AmqpSession in project activemq-artemis by apache.
the class AmqpMessageDivertsTest method runQueueReceiverReadMessageWithDivert.
public void runQueueReceiverReadMessageWithDivert(String routingType) throws Exception {
final String forwardingAddress = getQueueName() + "Divert";
final SimpleString simpleForwardingAddress = SimpleString.toSimpleString(forwardingAddress);
server.createQueue(simpleForwardingAddress, RoutingType.ANYCAST, simpleForwardingAddress, null, true, false);
server.getActiveMQServerControl().createDivert("name", "routingName", getQueueName(), forwardingAddress, true, null, null, routingType);
sendMessages(getQueueName(), 1);
AmqpClient client = createAmqpClient();
AmqpConnection connection = addConnection(client.connect());
AmqpSession session = connection.createSession();
AmqpReceiver receiver = session.createReceiver(forwardingAddress);
Queue queueView = getProxyToQueue(forwardingAddress);
assertEquals(1, queueView.getMessageCount());
receiver.flow(1);
assertNotNull(receiver.receive(5, TimeUnit.SECONDS));
receiver.close();
assertEquals(1, queueView.getMessageCount());
connection.close();
}
use of org.apache.activemq.transport.amqp.client.AmqpSession in project activemq-artemis by apache.
the class AmqpMessagePriorityTest method testMessagePriorityPreservedAfterServerRestart.
@Test(timeout = 60000)
public void testMessagePriorityPreservedAfterServerRestart() throws Exception {
AmqpClient client = createAmqpClient();
AmqpConnection connection = addConnection(client.connect());
AmqpSession session = connection.createSession();
AmqpSender sender = session.createSender(getQueueName());
AmqpMessage message = new AmqpMessage();
message.setDurable(true);
message.setMessageId("MessageID:1");
message.setPriority((short) 7);
sender.send(message);
sender.close();
connection.close();
server.stop();
server.start();
client = createAmqpClient();
connection = addConnection(client.connect());
session = connection.createSession();
AmqpReceiver receiver = session.createReceiver(getQueueName());
Queue queueView = getProxyToQueue(getQueueName());
assertEquals(1, queueView.getMessageCount());
receiver.flow(1);
AmqpMessage receive = receiver.receive(5, TimeUnit.SECONDS);
assertNotNull(receive);
assertEquals((short) 7, receive.getPriority());
receiver.close();
assertEquals(1, queueView.getMessageCount());
connection.close();
}
use of org.apache.activemq.transport.amqp.client.AmqpSession in project activemq-artemis by apache.
the class AmqpMessagePriorityTest method testMessageNonDefaultPriority.
@Test(timeout = 60000)
public void testMessageNonDefaultPriority() throws Exception {
AmqpClient client = createAmqpClient();
AmqpConnection connection = addConnection(client.connect());
AmqpSession session = connection.createSession();
AmqpSender sender = session.createSender(getQueueName());
AmqpMessage message = new AmqpMessage();
message.setMessageId("MessageID:1");
message.setPriority((short) 0);
sender.send(message);
sender.close();
AmqpReceiver receiver = session.createReceiver(getQueueName());
Queue queueView = getProxyToQueue(getQueueName());
assertEquals(1, queueView.getMessageCount());
receiver.flow(1);
AmqpMessage receive = receiver.receive(5, TimeUnit.SECONDS);
assertNotNull(receive);
assertEquals((short) 0, receive.getPriority());
receiver.close();
assertEquals(1, queueView.getMessageCount());
connection.close();
}
use of org.apache.activemq.transport.amqp.client.AmqpSession in project activemq-artemis by apache.
the class AmqpMessagePriorityTest method testMessageNoPriority.
@Test(timeout = 60000)
public void testMessageNoPriority() throws Exception {
AmqpClient client = createAmqpClient();
AmqpConnection connection = addConnection(client.connect());
AmqpSession session = connection.createSession();
AmqpSender sender = session.createSender(getQueueName());
AmqpMessage message = new AmqpMessage();
message.setMessageId("MessageID:1");
sender.send(message);
sender.close();
AmqpReceiver receiver = session.createReceiver(getQueueName());
Queue queueView = getProxyToQueue(getQueueName());
assertEquals(1, queueView.getMessageCount());
receiver.flow(1);
AmqpMessage receive = receiver.receive(5, TimeUnit.SECONDS);
assertNotNull(receive);
assertEquals((short) 4, receive.getPriority());
receiver.close();
assertEquals(1, queueView.getMessageCount());
connection.close();
}
Aggregations