Search in sources :

Example 36 with AmqpMessage

use of org.apache.activemq.transport.amqp.client.AmqpMessage 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();
}
Also used : AmqpSession(org.apache.activemq.transport.amqp.client.AmqpSession) AmqpSender(org.apache.activemq.transport.amqp.client.AmqpSender) AmqpMessage(org.apache.activemq.transport.amqp.client.AmqpMessage)

Example 37 with AmqpMessage

use of org.apache.activemq.transport.amqp.client.AmqpMessage in project activemq-artemis by apache.

the class AmqpLargeMessageTest method createAmqpMessage.

private AmqpMessage createAmqpMessage(byte value, int payloadSize) {
    AmqpMessage message = new AmqpMessage();
    byte[] payload = new byte[payloadSize];
    for (int i = 0; i < payload.length; i++) {
        payload[i] = value;
    }
    message.setBytes(payload);
    return message;
}
Also used : AmqpMessage(org.apache.activemq.transport.amqp.client.AmqpMessage)

Example 38 with AmqpMessage

use of org.apache.activemq.transport.amqp.client.AmqpMessage 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();
}
Also used : AmqpConnection(org.apache.activemq.transport.amqp.client.AmqpConnection) AmqpSession(org.apache.activemq.transport.amqp.client.AmqpSession) AmqpReceiver(org.apache.activemq.transport.amqp.client.AmqpReceiver) AmqpClient(org.apache.activemq.transport.amqp.client.AmqpClient) AmqpSender(org.apache.activemq.transport.amqp.client.AmqpSender) Queue(org.apache.activemq.artemis.core.server.Queue) AmqpMessage(org.apache.activemq.transport.amqp.client.AmqpMessage) Test(org.junit.Test)

Example 39 with AmqpMessage

use of org.apache.activemq.transport.amqp.client.AmqpMessage 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();
}
Also used : AmqpConnection(org.apache.activemq.transport.amqp.client.AmqpConnection) AmqpSession(org.apache.activemq.transport.amqp.client.AmqpSession) AmqpReceiver(org.apache.activemq.transport.amqp.client.AmqpReceiver) AmqpClient(org.apache.activemq.transport.amqp.client.AmqpClient) AmqpSender(org.apache.activemq.transport.amqp.client.AmqpSender) Queue(org.apache.activemq.artemis.core.server.Queue) AmqpMessage(org.apache.activemq.transport.amqp.client.AmqpMessage) Test(org.junit.Test)

Example 40 with AmqpMessage

use of org.apache.activemq.transport.amqp.client.AmqpMessage 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();
}
Also used : AmqpConnection(org.apache.activemq.transport.amqp.client.AmqpConnection) AmqpSession(org.apache.activemq.transport.amqp.client.AmqpSession) AmqpReceiver(org.apache.activemq.transport.amqp.client.AmqpReceiver) AmqpClient(org.apache.activemq.transport.amqp.client.AmqpClient) AmqpSender(org.apache.activemq.transport.amqp.client.AmqpSender) Queue(org.apache.activemq.artemis.core.server.Queue) AmqpMessage(org.apache.activemq.transport.amqp.client.AmqpMessage) Test(org.junit.Test)

Aggregations

AmqpMessage (org.apache.activemq.transport.amqp.client.AmqpMessage)118 AmqpSession (org.apache.activemq.transport.amqp.client.AmqpSession)115 AmqpClient (org.apache.activemq.transport.amqp.client.AmqpClient)114 AmqpConnection (org.apache.activemq.transport.amqp.client.AmqpConnection)114 Test (org.junit.Test)100 AmqpReceiver (org.apache.activemq.transport.amqp.client.AmqpReceiver)94 AmqpSender (org.apache.activemq.transport.amqp.client.AmqpSender)82 Queue (org.apache.activemq.artemis.core.server.Queue)56 AddressInfo (org.apache.activemq.artemis.core.server.impl.AddressInfo)16 Source (org.apache.qpid.proton.amqp.messaging.Source)9 SimpleString (org.apache.activemq.artemis.api.core.SimpleString)8 CountDownLatch (java.util.concurrent.CountDownLatch)7 URI (java.net.URI)4 ArrayList (java.util.ArrayList)4 Connection (javax.jms.Connection)4 Message (javax.jms.Message)4 MessageConsumer (javax.jms.MessageConsumer)4 Session (javax.jms.Session)4 AmqpValidator (org.apache.activemq.transport.amqp.client.AmqpValidator)4 Delivery (org.apache.qpid.proton.engine.Delivery)4