List of usage examples for com.rabbitmq.client Channel exchangeDelete
Exchange.DeleteOk exchangeDelete(String exchange) throws IOException;
From source file:reactor.rabbitmq.ReactorRabbitMqTests.java
License:Open Source License
@Test public void createResources() throws Exception { final Channel channel = connection.createChannel(); final String queueName = UUID.randomUUID().toString(); final String exchangeName = UUID.randomUUID().toString(); try {/*from ww w . java2s . co m*/ sender = ReactorRabbitMq.createSender(); Mono<AMQP.Queue.BindOk> resources = sender .createExchange(ExchangeSpecification.exchange().name(exchangeName)) .then(sender.createQueue(QueueSpecification.queue(queueName))) .then(sender.bind(BindingSpecification.binding().queue(queueName).exchange(exchangeName) .routingKey("a.b"))); resources.block(java.time.Duration.ofSeconds(1)); channel.exchangeDeclarePassive(exchangeName); channel.queueDeclarePassive(queueName); } finally { channel.exchangeDelete(exchangeName); channel.queueDelete(queueName); channel.close(); } }
From source file:reactor.rabbitmq.ReactorRabbitMqTests.java
License:Open Source License
@Test public void createResourcesPublishConsume() throws Exception { final String queueName = UUID.randomUUID().toString(); final String exchangeName = UUID.randomUUID().toString(); final String routingKey = "a.b"; int nbMessages = 100; try {/* w ww . ja va2 s. co m*/ sender = ReactorRabbitMq.createSender(); MonoProcessor<Void> resourceSendingSub = sender .createExchange(ExchangeSpecification.exchange(exchangeName)) .then(sender.createQueue(QueueSpecification.queue(queueName))) .then(sender.bind(BindingSpecification.binding().queue(queueName).exchange(exchangeName) .routingKey(routingKey))) .then(sender.send(Flux.range(0, nbMessages) .map(i -> new OutboundMessage(exchangeName, routingKey, "".getBytes())))) .subscribe(); resourceSendingSub.dispose(); CountDownLatch latch = new CountDownLatch(nbMessages); AtomicInteger count = new AtomicInteger(); receiver = ReactorRabbitMq.createReceiver(); Disposable receiverSubscription = receiver.consumeNoAck(queueName).subscribe(msg -> { count.incrementAndGet(); latch.countDown(); }); assertTrue(latch.await(1, TimeUnit.SECONDS)); assertEquals(nbMessages, count.get()); receiverSubscription.dispose(); } finally { final Channel channel = connection.createChannel(); channel.exchangeDelete(exchangeName); channel.queueDelete(queueName); channel.close(); } }
From source file:xyz.cloudbans.barker.amqp.AmqpBarkerTest.java
License:Apache License
private void cleanup(AmqpBarkerOptions options, Channel channel) { try {/*from www .j a v a2 s.com*/ channel.exchangeDelete(options.getInputExchange()); } catch (IOException ignore) { LOGGER.info("An non-critical exception occurred while deleting exchange."); } try { channel.queueDelete(options.getQueuePrefix() + TOPIC_NAME); } catch (IOException ignore) { LOGGER.info("An non-critical exception occurred while deleting queue."); } }