use of com.rabbitmq.client.ConnectionFactory in project pinpoint by naver.
the class RabbitMQClient_3_3_0_to_4_0_0_IT method testPush_autorecovery.
@Test
public void testPush_autorecovery() throws Exception {
ConnectionFactory connectionFactory = getConnectionFactory();
connectionFactory.setAutomaticRecoveryEnabled(true);
testRunner.runPushTest();
}
use of com.rabbitmq.client.ConnectionFactory in project pinpoint by naver.
the class RabbitMQClient_5_x_IT method testPush_nio_autorecovery.
@Test
public void testPush_nio_autorecovery() throws Exception {
ConnectionFactory connectionFactory = getConnectionFactory();
connectionFactory.setAutomaticRecoveryEnabled(true);
connectionFactory.useNio();
testRunner.runPushTest();
}
use of com.rabbitmq.client.ConnectionFactory in project beam by apache.
the class RabbitMqIOTest method testReadQueue.
@Test
public void testReadQueue() throws Exception {
final int maxNumRecords = 10;
PCollection<RabbitMqMessage> raw = p.apply(RabbitMqIO.read().withUri("amqp://guest:guest@localhost:" + port).withQueue("READ").withMaxNumRecords(maxNumRecords));
PCollection<String> output = raw.apply(MapElements.into(TypeDescriptors.strings()).via((RabbitMqMessage message) -> RabbitMqTestUtils.recordToString(message.getBody())));
List<String> records = RabbitMqTestUtils.generateRecords(maxNumRecords).stream().map(RabbitMqTestUtils::recordToString).collect(Collectors.toList());
PAssert.that(output).containsInAnyOrder(records);
ConnectionFactory connectionFactory = new ConnectionFactory();
connectionFactory.setUri("amqp://guest:guest@localhost:" + port);
Connection connection = null;
Channel channel = null;
try {
connection = connectionFactory.newConnection();
channel = connection.createChannel();
channel.queueDeclare("READ", false, false, false, null);
for (String record : records) {
channel.basicPublish("", "READ", null, record.getBytes(StandardCharsets.UTF_8));
}
p.run();
} finally {
if (channel != null) {
channel.close();
}
if (connection != null) {
connection.close();
}
}
}
use of com.rabbitmq.client.ConnectionFactory in project beam by apache.
the class RabbitMqIOTest method testWriteExchange.
@Test
public void testWriteExchange() throws Exception {
final int maxNumRecords = 1000;
List<RabbitMqMessage> data = RabbitMqTestUtils.generateRecords(maxNumRecords).stream().map(RabbitMqMessage::new).collect(Collectors.toList());
p.apply(Create.of(data)).apply(RabbitMqIO.write().withUri("amqp://guest:guest@localhost:" + port).withExchange("WRITE", "fanout"));
ConnectionFactory connectionFactory = new ConnectionFactory();
connectionFactory.setUri("amqp://guest:guest@localhost:" + port);
Connection connection = null;
Channel channel = null;
try {
connection = connectionFactory.newConnection();
channel = connection.createChannel();
channel.exchangeDeclare("WRITE", "fanout");
String queueName = channel.queueDeclare().getQueue();
channel.queueBind(queueName, "WRITE", "");
RabbitMqTestUtils.TestConsumer consumer = new RabbitMqTestUtils.TestConsumer(channel);
channel.basicConsume(queueName, true, consumer);
p.run();
while (consumer.getReceived().size() < maxNumRecords) {
Thread.sleep(500);
}
assertEquals(maxNumRecords, consumer.getReceived().size());
for (int i = 0; i < maxNumRecords; i++) {
assertTrue(consumer.getReceived().contains("Test " + i));
}
} finally {
if (channel != null) {
channel.close();
}
if (connection != null) {
connection.close();
}
}
}
use of com.rabbitmq.client.ConnectionFactory in project spring-boot by spring-projects.
the class RabbitConnectionFactoryMetricsPostProcessor method bindConnectionFactoryToRegistry.
private void bindConnectionFactoryToRegistry(MeterRegistry registry, String beanName, AbstractConnectionFactory connectionFactory) {
ConnectionFactory rabbitConnectionFactory = connectionFactory.getRabbitConnectionFactory();
String connectionFactoryName = getConnectionFactoryName(beanName);
new RabbitMetrics(rabbitConnectionFactory, Tags.of("name", connectionFactoryName)).bindTo(registry);
}
Aggregations