use of org.apache.activemq.transport.amqp.client.AmqpSession in project activemq-artemis by apache.
the class AmqpSendReceiveTest method doTestMessageWithToFieldSet.
private void doTestMessageWithToFieldSet(boolean anonymous, String expected) throws Exception {
AmqpClient client = createAmqpClient();
AmqpConnection connection = addConnection(client.connect());
AmqpSession session = connection.createSession();
final String address = getQueueName();
AmqpSender sender = session.createSender(anonymous ? null : address);
AmqpMessage message = new AmqpMessage();
message.setAddress(expected);
message.setMessageId("msg:1");
sender.send(message);
AmqpReceiver receiver = session.createReceiver(address);
Queue queueView = getProxyToQueue(address);
assertEquals(1, queueView.getMessageCount());
receiver.flow(1);
AmqpMessage received = receiver.receive(5, TimeUnit.SECONDS);
assertNotNull(received);
assertEquals(expected, received.getAddress());
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 AmqpSenderTest 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();
AmqpSender sender = session.createSender("queue://" + getTestName(), SenderSettleMode.UNSETTLED, modeToUse);
Queue queueView = getProxyToQueue(getQueueName());
assertNotNull(queueView);
assertEquals(0, queueView.getMessageCount());
assertEquals(ReceiverSettleMode.FIRST, sender.getEndpoint().getRemoteReceiverSettleMode());
sender.close();
connection.close();
}
use of org.apache.activemq.transport.amqp.client.AmqpSession in project activemq-artemis by apache.
the class AmqpSessionTest method testCreateSession.
@Test(timeout = 60000)
public void testCreateSession() throws Exception {
AmqpClient client = createAmqpClient();
AmqpConnection connection = addConnection(client.connect());
AmqpSession session = connection.createSession();
assertNotNull(session);
connection.close();
}
use of org.apache.activemq.transport.amqp.client.AmqpSession in project activemq-artemis by apache.
the class AmqpTempDestinationTest method doTestCreateDynamicSender.
@SuppressWarnings("unchecked")
protected void doTestCreateDynamicSender(boolean topic) throws Exception {
Target target = createDynamicTarget(topic);
AmqpClient client = createAmqpClient();
AmqpConnection connection = addConnection(client.connect());
AmqpSession session = connection.createSession();
AmqpSender sender = session.createSender(target);
assertNotNull(sender);
Target remoteTarget = (Target) sender.getEndpoint().getRemoteTarget();
assertTrue(remoteTarget.getDynamic());
assertTrue(remoteTarget.getDurable().equals(TerminusDurability.NONE));
assertTrue(remoteTarget.getExpiryPolicy().equals(TerminusExpiryPolicy.LINK_DETACH));
// Check the dynamic node lifetime-policy
Map<Symbol, Object> dynamicNodeProperties = remoteTarget.getDynamicNodeProperties();
assertTrue(dynamicNodeProperties.containsKey(LIFETIME_POLICY));
assertEquals(DeleteOnClose.getInstance(), dynamicNodeProperties.get(LIFETIME_POLICY));
Queue queueView = getProxyToQueue(remoteTarget.getAddress());
assertNotNull(queueView);
connection.close();
}
use of org.apache.activemq.transport.amqp.client.AmqpSession in project activemq-artemis by apache.
the class AmqpTempDestinationTest method doTestDynamicReceiverLifetimeBoundToLinkQueue.
protected void doTestDynamicReceiverLifetimeBoundToLinkQueue(boolean topic) throws Exception {
Source source = createDynamicSource(topic);
AmqpClient client = createAmqpClient();
AmqpConnection connection = addConnection(client.connect());
AmqpSession session = connection.createSession();
AmqpReceiver receiver = session.createReceiver(source);
assertNotNull(receiver);
Source remoteSource = (Source) receiver.getEndpoint().getRemoteSource();
Queue queueView = getProxyToQueue(remoteSource.getAddress());
assertNotNull(queueView);
receiver.close();
queueView = getProxyToQueue(remoteSource.getAddress());
assertNull(queueView);
connection.close();
}
Aggregations