use of org.apache.activemq.transport.amqp.client.AmqpClient in project activemq-artemis by apache.
the class AmqpAnonymousRelayTest method testSendMessageFailsOnAnonymousRelayLinkWhenNoToValueSet.
@Test(timeout = 60000)
public void testSendMessageFailsOnAnonymousRelayLinkWhenNoToValueSet() throws Exception {
AmqpClient client = createAmqpClient();
AmqpConnection connection = addConnection(client.connect());
try {
AmqpSession session = connection.createSession();
AmqpSender sender = session.createAnonymousSender();
AmqpMessage message = new AmqpMessage();
message.setMessageId("msg" + 1);
message.setText("Test-Message");
try {
sender.send(message);
fail("Should not be able to send, message should be rejected");
} catch (Exception ex) {
ex.printStackTrace();
} finally {
sender.close();
}
} finally {
connection.close();
}
}
use of org.apache.activemq.transport.amqp.client.AmqpClient in project activemq-artemis by apache.
the class AmqpBrokerReuqestedHearbeatsTest method testClientWithoutHeartbeatsGetsDropped.
@Test(timeout = 60000)
public void testClientWithoutHeartbeatsGetsDropped() throws Exception {
final CountDownLatch disconnected = new CountDownLatch(1);
AmqpClient client = createAmqpClient();
assertNotNull(client);
AmqpConnection connection = addConnection(client.createConnection());
assertNotNull(connection);
connection.setIdleProcessingDisabled(true);
connection.setListener(new AmqpConnectionListener() {
@Override
public void onException(Throwable ex) {
disconnected.countDown();
}
});
connection.connect();
assertEquals(1, server.getConnectionCount());
assertTrue(disconnected.await(30, TimeUnit.SECONDS));
connection.close();
Wait.assertEquals(0, server::getConnectionCount);
}
use of org.apache.activemq.transport.amqp.client.AmqpClient in project activemq-artemis by apache.
the class AmqpBrokerReuqestedHearbeatsTest method testBrokerSendsHalfConfiguredIdleTimeout.
@Test(timeout = 60000)
public void testBrokerSendsHalfConfiguredIdleTimeout() throws Exception {
AmqpClient client = createAmqpClient();
assertNotNull(client);
client.setValidator(new AmqpValidator() {
@Override
public void inspectOpenedResource(Connection connection) {
assertEquals("Broker did not send half the idle timeout", TEST_IDLE_TIMEOUT / 2, connection.getTransport().getRemoteIdleTimeout());
}
});
AmqpConnection connection = addConnection(client.connect());
assertNotNull(connection);
connection.getStateInspector().assertValid();
connection.close();
}
use of org.apache.activemq.transport.amqp.client.AmqpClient in project activemq-artemis by apache.
the class AmqpClientTestSupport method sendMessages.
protected void sendMessages(String destinationName, int count, RoutingType routingType, boolean durable) 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);
message.setDurable(true);
if (routingType != null) {
message.setMessageAnnotation(AMQPMessageSupport.ROUTING_TYPE.toString(), routingType.getType());
}
sender.send(message);
}
} finally {
connection.close();
}
}
use of org.apache.activemq.transport.amqp.client.AmqpClient in project activemq-artemis by apache.
the class AmqpClientTestSupport method sendMessages.
protected void sendMessages(String destinationName, int count, boolean durable) 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);
message.setDurable(durable);
sender.send(message);
}
} finally {
connection.close();
}
}
Aggregations