use of org.apache.activemq.transport.amqp.client.AmqpSender in project activemq-artemis by apache.
the class AmqpMaxFrameSizeTest method testMultipleTransfers.
@Test(timeout = 60000)
public void testMultipleTransfers() throws Exception {
server.getAddressSettingsRepository().addMatch("#", new AddressSettings().setDefaultAddressRoutingType(RoutingType.ANYCAST));
String testQueueName = "ConnectionFrameSize";
int nMsgs = 200;
AmqpClient client = createAmqpClient();
AmqpConnection connection = addConnection(client.connect());
try {
connection.connect();
AmqpSession session = connection.createSession();
AmqpSender sender = session.createSender(testQueueName);
final int payload = FRAME_SIZE * 16;
for (int i = 0; i < nMsgs; ++i) {
AmqpMessage message = createAmqpMessage((byte) 'A', payload);
sender.send(message);
}
int count = getMessageCount(server.getPostOffice(), testQueueName);
assertEquals(nMsgs, count);
AmqpReceiver receiver = session.createReceiver(testQueueName);
receiver.flow(nMsgs);
for (int i = 0; i < nMsgs; ++i) {
AmqpMessage message = receiver.receive(5, TimeUnit.SECONDS);
assertNotNull("failed at " + i, message);
MessageImpl wrapped = (MessageImpl) message.getWrappedMessage();
Data data = (Data) wrapped.getBody();
System.out.println("received : message: " + data.getValue().getLength());
assertEquals(payload, data.getValue().getLength());
message.accept();
}
} finally {
connection.close();
}
}
use of org.apache.activemq.transport.amqp.client.AmqpSender in project activemq-artemis by apache.
the class AmqpMessagePriorityTest method testMessageWithVeryHighPriority.
@Test(timeout = 60000)
public void testMessageWithVeryHighPriority() 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) 99);
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(99, receive.getPriority());
receiver.close();
assertEquals(1, queueView.getMessageCount());
connection.close();
}
use of org.apache.activemq.transport.amqp.client.AmqpSender in project activemq-artemis by apache.
the class AmqpDescribedTypePayloadTest method testSendMessageWithDescribedTypeInBodyReceiveOverOpenWire.
@Test(timeout = 60000)
public void testSendMessageWithDescribedTypeInBodyReceiveOverOpenWire() throws Exception {
AmqpClient client = createAmqpClient();
AmqpConnection connection = addConnection(client.connect());
AmqpSession session = connection.createSession();
AmqpSender sender = session.createSender(getQueueName());
AmqpMessage message = new AmqpMessage();
message.setDescribedType(new AmqpNoLocalFilter());
sender.send(message);
sender.close();
connection.close();
Queue queue = getProxyToQueue(getQueueName());
Wait.assertEquals(1, queue::getMessageCount);
ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(getBrokerOpenWireConnectionURI());
Connection jmsConnection = factory.createConnection();
try {
Session jmsSession = jmsConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
Destination destination = jmsSession.createQueue(getName());
MessageConsumer jmsConsumer = jmsSession.createConsumer(destination);
jmsConnection.start();
Message received = jmsConsumer.receive(5000);
assertNotNull(received);
assertTrue(received instanceof BytesMessage);
} finally {
jmsConnection.close();
}
}
use of org.apache.activemq.transport.amqp.client.AmqpSender in project activemq-artemis by apache.
the class AmqpDeliveryAnnotationsTest method testDeliveryAnnotationsStrippedFromIncoming.
@Test(timeout = 60000)
public void testDeliveryAnnotationsStrippedFromIncoming() throws Exception {
AmqpClient client = createAmqpClient();
AmqpConnection connection = addConnection(client.connect());
AmqpSession session = connection.createSession();
AmqpSender sender = session.createSender(getQueueName());
AmqpReceiver receiver = session.createReceiver(getQueueName());
AmqpMessage message = new AmqpMessage();
message.setText("Test-Message");
message.setDeliveryAnnotation(DELIVERY_ANNOTATION_NAME, getQueueName());
sender.send(message);
receiver.flow(1);
Queue queue = getProxyToQueue(getQueueName());
assertEquals(1, queue.getMessageCount());
AmqpMessage received = receiver.receive(5, TimeUnit.SECONDS);
assertNotNull(received);
assertNull(received.getDeliveryAnnotation(DELIVERY_ANNOTATION_NAME));
sender.close();
connection.close();
}
use of org.apache.activemq.transport.amqp.client.AmqpSender in project activemq-artemis by apache.
the class AmqpPluginTest method sendMessages.
@Override
public void sendMessages(String destinationName, int count, RoutingType routingType) throws Exception {
AmqpClient client = createAmqpClient();
AmqpConnection connection = addConnection(client.connect());
try {
AmqpSession session = connection.createSession();
AmqpSender sender = session.createSender(destinationName);
for (int i = 0; i < count; ++i) {
AmqpMessage message = new AmqpMessage();
message.setMessageId("MessageID:" + i);
if (routingType != null) {
message.setMessageAnnotation(AMQPMessageSupport.ROUTING_TYPE.toString(), routingType.getType());
}
sender.send(message);
}
} finally {
connection.close();
}
}
Aggregations