List of usage examples for com.rabbitmq.client Channel close
@Override void close() throws IOException, TimeoutException;
From source file:zipkin2.collector.rabbitmq.ITRabbitMQCollector.java
License:Apache License
/** See GitHub issue #2068 */ @Test//from ww w.j av a 2 s . co m public void startsWhenConfiguredQueueAlreadyExists() throws IOException, TimeoutException { Channel channel = rabbit.collector.connection.get().createChannel(); // make a queue with non-default properties channel.queueDeclare("zipkin-test2", true, false, false, Collections.singletonMap("x-message-ttl", 36000000)); try { RabbitMQCollector.builder().storage(InMemoryStorage.newBuilder().build()) .metrics(CollectorMetrics.NOOP_METRICS).queue("zipkin-test2") .addresses(Collections.singletonList(rabbit.address())).build().start().close(); } finally { channel.queueDelete("zipkin-test2"); channel.close(); } }
From source file:zipkin2.collector.rabbitmq.RabbitMQCollectorRule.java
License:Apache License
void publish(byte[] message) throws IOException, TimeoutException { Channel channel = collector.connection.get().createChannel(); try {//from ww w . jav a 2 s.c o m channel.basicPublish("", collector.queue, null, message); } finally { channel.close(); } }
From source file:zipkin2.reporter.amqp.RabbitMQSenderTest.java
License:Apache License
private void declareQueue(String queue) throws Exception { Channel channel = sender.get().createChannel(); try {//from w w w.j a v a2 s. c o m channel.queueDelete(queue); channel.queueDeclare(queue, false, true, true, null); } finally { channel.close(); } Thread.sleep(500L); }
From source file:zipkin2.reporter.amqp.RabbitMQSenderTest.java
License:Apache License
private byte[] readMessage() throws Exception { final CountDownLatch countDown = new CountDownLatch(1); final AtomicReference<byte[]> result = new AtomicReference<>(); Channel channel = sender.get().createChannel(); try {//ww w .j a va2 s .c o m channel.basicConsume(sender.queue, true, new DefaultConsumer(channel) { @Override public void handleDelivery(String consumerTag, Envelope envelope, AMQP.BasicProperties properties, byte[] body) throws IOException { result.set(body); countDown.countDown(); } }); countDown.await(5, TimeUnit.SECONDS); } finally { channel.close(); } return result.get(); }