List of usage examples for com.rabbitmq.client Channel queueDelete
Queue.DeleteOk queueDelete(String queue) throws IOException;
From source file:reactor.rabbitmq.RabbitFluxTests.java
License:Open Source License
@Test public void shovel() throws Exception { final String sourceQueue = UUID.randomUUID().toString(); final String destinationQueue = UUID.randomUUID().toString(); try {//from ww w .ja v a 2 s.co m sender = createSender(); receiver = RabbitFlux.createReceiver(); Mono<AMQP.Queue.DeclareOk> resources = sender.declare(queue(sourceQueue)) .then(sender.declare(queue(destinationQueue))); int nbMessages = 100; AtomicInteger counter = new AtomicInteger(); CountDownLatch latch = new CountDownLatch(nbMessages); Disposable shovel = resources .then(sender.send(Flux.range(0, nbMessages) .map(i -> new OutboundMessage("", sourceQueue, i.toString().getBytes())))) .thenMany(receiver .consumeNoAck(sourceQueue, new ConsumeOptions().stopConsumingBiFunction((emitter, msg) -> Integer.parseInt(new String(msg.getBody())) == nbMessages - 1)) .map(delivery -> new OutboundMessage("", destinationQueue, delivery.getBody())) .transform(messages -> sender.send(messages))) .thenMany(receiver.consumeNoAck(destinationQueue)).subscribe(msg -> { counter.incrementAndGet(); latch.countDown(); }); assertTrue(latch.await(3, TimeUnit.SECONDS)); assertEquals(nbMessages, counter.get()); shovel.dispose(); } finally { Channel channel = connection.createChannel(); channel.queueDelete(sourceQueue); channel.queueDelete(destinationQueue); } }
From source file:reactor.rabbitmq.ReactorRabbitMqTests.java
License:Open Source License
@After public void tearDown() throws Exception { if (connection != null) { Channel channel = connection.createChannel(); channel.queueDelete(queue); channel.close();/* w ww . jav a2 s . co m*/ connection.close(); } if (sender != null) { sender.close(); } if (receiver != null) { receiver.close(); } }
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 w w w . j a v a 2 s . c o 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 {/*from ww w. j a v a2 s . c o 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:reactor.rabbitmq.ReactorRabbitMqTests.java
License:Open Source License
@Test public void shovel() throws Exception { final String sourceQueue = UUID.randomUUID().toString(); final String destinationQueue = UUID.randomUUID().toString(); try {/* w w w. j ava 2 s . c o m*/ sender = ReactorRabbitMq.createSender(); Mono<AMQP.Queue.DeclareOk> resources = sender.createQueue(QueueSpecification.queue(sourceQueue)) .then(sender.createQueue(QueueSpecification.queue(destinationQueue))); resources.block(); int nbMessages = 100; MonoProcessor<Void> sourceMessages = sender .send(Flux.range(0, nbMessages).map(i -> new OutboundMessage("", sourceQueue, "".getBytes()))) .subscribe(); receiver = ReactorRabbitMq.createReceiver(); Flux<OutboundMessage> forwardedMessages = receiver.consumeNoAck(sourceQueue) .map(delivery -> new OutboundMessage("", destinationQueue, delivery.getBody())); AtomicInteger counter = new AtomicInteger(); CountDownLatch latch = new CountDownLatch(nbMessages); MonoProcessor<Void> shovelSubscription = sourceMessages.then(sender.send(forwardedMessages)) .subscribe(); Disposable consumerSubscription = receiver.consumeNoAck(destinationQueue).subscribe(msg -> { counter.incrementAndGet(); latch.countDown(); }); assertTrue(latch.await(1, TimeUnit.SECONDS)); assertEquals(nbMessages, counter.get()); shovelSubscription.dispose(); consumerSubscription.dispose(); } finally { Channel channel = connection.createChannel(); channel.queueDelete(sourceQueue); channel.queueDelete(destinationQueue); } }
From source file:reactor.rabbitmq.RequestReplyTests.java
License:Open Source License
@AfterAll public static void tearDownAll() throws Exception { try (Connection c = new ConnectionFactory().newConnection()) { Channel ch = c.createChannel(); for (String queue : QUEUES) { ch.queueDelete(queue); }//w ww . j a va 2 s . c o m } }
From source file:reactor.rabbitmq.SenderBenchmarkUtils.java
License:Open Source License
public static void deleteQueue(Connection connection, String queue) throws Exception { Channel channel = connection.createChannel(); channel.queueDelete(queue); channel.close();//from w w w . ja v a 2s. c o m }
From source file:reactor.rabbitmq.SenderTests.java
License:Open Source License
@AfterEach public void tearDown() throws Exception { if (connection != null) { Channel channel = connection.createChannel(); channel.queueDelete(queue); channel.close();/*from ww w .j a v a 2s.com*/ connection.close(); } if (sender != null) { sender.close(); } }
From source file:uk.ac.soton.itinnovation.experimedia.arch.ecc.amqpAPI.impl.faces.AbstractAMQPInterface.java
public void shutdown() { if (amqpChannel != null) { // Clear up queue, if it exists if (subListenQueue != null) try { if (amqpChannel.isOpen()) { Channel channel = (Channel) amqpChannel.getChannelImpl(); channel.queueDelete(subListenQueue); subProcessor = null; msgDispatch = null;/*from w w w . j a va2 s . c om*/ } else amqpIntLogger.warn("Could not close AMQP channel: already closed"); } catch (IOException ioe) { amqpIntLogger.error("Could not delete AMQP queue: " + ioe.getMessage()); } } // Tidy up (channel is managed elsewhere) interfaceName = null; providerExchangeName = null; userExchangeName = null; providerQueueName = null; userQueueName = null; providerRoutingKey = null; userRoutingKey = null; subListenQueue = null; interfaceReady = false; }
From source file:xyz.cloudbans.barker.amqp.AmqpBarkerTest.java
License:Apache License
private void cleanup(AmqpBarkerOptions options, Channel channel) { try {/*from w ww . j av a2 s.c om*/ 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."); } }