use of org.apache.activemq.transport.amqp.client.AmqpReceiver in project activemq-artemis by apache.
the class AmqpReceiverTest method doTestSenderSettlementModeIsHonored.
public void doTestSenderSettlementModeIsHonored(SenderSettleMode settleMode) throws Exception {
AmqpClient client = createAmqpClient();
AmqpConnection connection = addConnection(client.connect());
AmqpSession session = connection.createSession();
AmqpReceiver receiver = session.createReceiver("queue://" + getTestName(), settleMode, ReceiverSettleMode.FIRST);
Queue queueView = getProxyToQueue(getQueueName());
assertNotNull(queueView);
assertEquals(0, queueView.getMessageCount());
assertEquals(1, server.getTotalConsumerCount());
assertEquals(settleMode, receiver.getEndpoint().getRemoteSenderSettleMode());
receiver.close();
connection.close();
}
use of org.apache.activemq.transport.amqp.client.AmqpReceiver in project activemq-artemis by apache.
the class AmqpReceiverTest method doTestReceiverSettlementModeForcedToFirst.
/*
* The Broker does not currently support ReceiverSettleMode of SECOND so we ensure that it
* always drops that back to FIRST to let the client know. The client will need to check and
* react accordingly.
*/
private void doTestReceiverSettlementModeForcedToFirst(ReceiverSettleMode modeToUse) throws Exception {
AmqpClient client = createAmqpClient();
AmqpConnection connection = addConnection(client.connect());
AmqpSession session = connection.createSession();
AmqpReceiver receiver = session.createReceiver("queue://" + getTestName(), SenderSettleMode.MIXED, modeToUse);
Queue queueView = getProxyToQueue(getQueueName());
assertNotNull(queueView);
assertEquals(0, queueView.getMessageCount());
assertEquals(1, server.getTotalConsumerCount());
assertEquals(ReceiverSettleMode.FIRST, receiver.getEndpoint().getRemoteReceiverSettleMode());
receiver.close();
connection.close();
}
use of org.apache.activemq.transport.amqp.client.AmqpReceiver in project activemq-artemis by apache.
the class AmqpScheduledMessageTest method testSendRecvWithDeliveryTime.
@Test(timeout = 60000)
public void testSendRecvWithDeliveryTime() throws Exception {
AmqpClient client = createAmqpClient();
AmqpConnection connection = addConnection(client.connect());
try {
AmqpSession session = connection.createSession();
AmqpSender sender = session.createSender(getQueueName());
// Get the Queue View early to avoid racing the delivery.
final Queue queueView = getProxyToQueue(getQueueName());
assertNotNull(queueView);
AmqpMessage message = new AmqpMessage();
long deliveryTime = System.currentTimeMillis() + 6000;
message.setMessageAnnotation("x-opt-delivery-time", deliveryTime);
message.setText("Test-Message");
sender.send(message);
sender.close();
assertEquals(1, queueView.getScheduledCount());
AmqpReceiver receiver = session.createReceiver(getQueueName());
receiver.flow(1);
// Now try and get the message, should not due to being scheduled.
AmqpMessage received = receiver.receive(2, TimeUnit.SECONDS);
assertNull(received);
// Now try and get the message, should get it now
received = receiver.receive(10, TimeUnit.SECONDS);
assertNotNull(received);
received.accept();
} finally {
connection.close();
}
}
use of org.apache.activemq.transport.amqp.client.AmqpReceiver in project activemq-artemis by apache.
the class AmqpScheduledMessageTest method testSendWithDeliveryTimeIsScheduled.
@Test(timeout = 60000)
public void testSendWithDeliveryTimeIsScheduled() throws Exception {
AmqpClient client = createAmqpClient();
AmqpConnection connection = addConnection(client.connect());
try {
AmqpSession session = connection.createSession();
AmqpSender sender = session.createSender(getQueueName());
// Get the Queue View early to avoid racing the delivery.
final Queue queueView = getProxyToQueue(getQueueName());
assertNotNull(queueView);
AmqpMessage message = new AmqpMessage();
long deliveryTime = System.currentTimeMillis() + TimeUnit.MINUTES.toMillis(2);
message.setMessageAnnotation("x-opt-delivery-time", deliveryTime);
message.setText("Test-Message");
sender.send(message);
sender.close();
assertEquals(1, queueView.getScheduledCount());
// Now try and get the message
AmqpReceiver receiver = session.createReceiver(getQueueName());
receiver.flow(1);
AmqpMessage received = receiver.receive(5, TimeUnit.SECONDS);
assertNull(received);
} finally {
connection.close();
}
}
use of org.apache.activemq.transport.amqp.client.AmqpReceiver in project activemq-artemis by apache.
the class AmqpScheduledMessageTest method testScheduleWithDelay.
@Test(timeout = 60000)
public void testScheduleWithDelay() throws Exception {
AmqpClient client = createAmqpClient();
AmqpConnection connection = addConnection(client.connect());
try {
AmqpSession session = connection.createSession();
AmqpSender sender = session.createSender(getQueueName());
// Get the Queue View early to avoid racing the delivery.
final Queue queueView = getProxyToQueue(getQueueName());
assertNotNull(queueView);
AmqpMessage message = new AmqpMessage();
long delay = 6000;
message.setMessageAnnotation("x-opt-delivery-delay", delay);
message.setText("Test-Message");
sender.send(message);
sender.close();
assertEquals(1, queueView.getScheduledCount());
AmqpReceiver receiver = session.createReceiver(getQueueName());
receiver.flow(1);
// Now try and get the message, should not due to being scheduled.
AmqpMessage received = receiver.receive(2, TimeUnit.SECONDS);
assertNull(received);
// Now try and get the message, should get it now
received = receiver.receive(10, TimeUnit.SECONDS);
assertNotNull(received);
received.accept();
} finally {
connection.close();
}
}
Aggregations