List of usage examples for com.rabbitmq.client Channel queueDelete
Queue.DeleteOk queueDelete(String queue) throws IOException;
From source file:org.springframework.amqp.rabbit.junit.BrokerRunning.java
License:Apache License
/** * Remove any test queues that were created by an * {@link #isRunningWithEmptyQueues(String...)} method. * @param additionalQueues additional queues to remove that might have been created by * tests.//ww w. j av a 2 s. c o m */ public void removeTestQueues(String... additionalQueues) { List<String> queuesToRemove = Arrays.asList(this.queues); if (additionalQueues != null) { queuesToRemove = new ArrayList<>(queuesToRemove); queuesToRemove.addAll(Arrays.asList(additionalQueues)); } logger.debug("deleting test queues: " + queuesToRemove); ConnectionFactory connectionFactory = getConnectionFactory(); Connection connection = null; // NOSONAR (closeResources()) Channel channel = null; try { connection = connectionFactory.newConnection(); connection.setId(generateId() + ".queueDelete"); channel = connection.createChannel(); for (String queue : queuesToRemove) { channel.queueDelete(queue); } } catch (Exception e) { logger.warn("Failed to delete queues", e); } finally { closeResources(connection, channel); } }
From source file:org.springframework.amqp.rabbit.junit.BrokerRunning.java
License:Apache License
/** * Delete arbitrary queues from the broker. * @param queues the queues to delete.// ww w.j a v a 2 s . c o m */ public void deleteQueues(String... queues) { ConnectionFactory connectionFactory = getConnectionFactory(); Connection connection = null; // NOSONAR (closeResources()) Channel channel = null; try { connection = connectionFactory.newConnection(); connection.setId(generateId() + ".queueDelete"); channel = connection.createChannel(); for (String queue : queues) { channel.queueDelete(queue); } } catch (Exception e) { logger.warn("Failed to delete queues", e); } finally { closeResources(connection, channel); } }
From source file:org.teksme.server.common.messaging.AMQPBrokerManager.java
License:Apache License
protected void deleteQueue(Channel channel, String queue) throws IOException { channel.queueDelete(queue); }
From source file:org.wso2.carbon.event.adaptor.rabbitmq.input.RabbitMQInputEventAdaptorTypeTest.java
License:Apache License
@AfterClass public static void afterClass() { try {//ww w . j av a 2 s . co m ConnectionFactory factory = EventAdapterHelper.getConnectionFactory("localhost", 5672, "admin", "admin", "/"); Connection connection = factory.newConnection(); Channel channel = connection.createChannel(); channel.queueDelete("wso2cep_test_input_queue"); } catch (IOException e) { e.printStackTrace(); } }
From source file:org.wso2.carbon.event.adaptor.rabbitmq.output.RabbitMQOutputEventAdaptorTypeTest.java
License:Apache License
@AfterClass public static void afterClass() { try {/* w w w. j a va2 s .com*/ ConnectionFactory factory = EventAdapterHelper.getConnectionFactory("localhost", 5672, "admin", "admin", "/"); Connection connection = factory.newConnection(); Channel channel = connection.createChannel(); channel.queueDelete("wso2cep_test_output_queue"); } catch (IOException e) { e.printStackTrace(); } }
From source file:pl.nask.hsn2.bus.rabbitmq.RbtUtils.java
License:Open Source License
/** * Removes queue./*from w w w . j a va2 s. co m*/ * * @param channel Channel for queue deletion. * @param queueName Name of the queue to be deleted. */ public static void deleteQueue(Channel channel, String queueName) { try { channel.queueDelete(queueName); } catch (IOException ex) { LOGGER.error("Error during deletion queue: {}", queueName); } }
From source file:reactor.rabbitmq.ConnectionRecoveryTests.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 2 s .c o m connection.close(); } if (sender != null) { sender.close(); } if (receiver != null) { receiver.close(); } if (connectionMono != null) { connectionMono.block().close(); } }
From source file:reactor.rabbitmq.RabbitFluxTests.java
License:Open Source License
@AfterEach public void tearDown() throws Exception { if (connection != null) { Channel channel = connection.createChannel(); channel.queueDelete(queue); channel.close();/*from w w w . j a va2 s. c o m*/ connection.close(); } if (sender != null) { sender.close(); } if (receiver != null) { receiver.close(); } }
From source file:reactor.rabbitmq.RabbitFluxTests.java
License:Open Source License
@ParameterizedTest @MethodSource("noAckAndManualAckFluxArguments") public void receiverQueueDeleted(BiFunction<Receiver, String, Flux<? extends Delivery>> fluxFactory) throws Exception { // given/*from ww w.j ava2s. co m*/ Channel channel = connection.createChannel(); Channel channelSpy = spy(channel); Connection mockConnection = mock(Connection.class); when(mockConnection.createChannel()).thenReturn(channelSpy); CountDownLatch latch = new CountDownLatch(1); channel.basicPublish("", queue, null, "Hello".getBytes()); receiver = RabbitFlux.createReceiver(new ReceiverOptions().connectionMono(Mono.just(mockConnection))); fluxFactory.apply(receiver, queue).subscribe(delivery -> { latch.countDown(); }); assertTrue(latch.await(1, TimeUnit.SECONDS)); // when channel.queueDelete(queue); // calls CancelCallback, consumerTag is unknown // then verify(channelSpy, never()).basicCancel(anyString()); }
From source file:reactor.rabbitmq.RabbitFluxTests.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 w w.j a v a 2 s .c o m*/ sender = createSender(); receiver = RabbitFlux.createReceiver(); CountDownLatch latch = new CountDownLatch(nbMessages); AtomicInteger count = new AtomicInteger(); Disposable resourceSendingConsuming = sender.declare(exchange(exchangeName)) .then(sender.declare(queue(queueName))) .then(sender.bind(binding(exchangeName, routingKey, queueName))) .thenMany(sender.send(Flux.range(0, nbMessages) .map(i -> new OutboundMessage(exchangeName, routingKey, i.toString().getBytes())))) .thenMany(receiver.consumeNoAck(queueName, new ConsumeOptions().stopConsumingBiFunction( (emitter, msg) -> Integer.parseInt(new String(msg.getBody())) == nbMessages - 1))) .subscribe(msg -> { count.incrementAndGet(); latch.countDown(); }); assertTrue(latch.await(5, TimeUnit.SECONDS)); assertEquals(nbMessages, count.get()); resourceSendingConsuming.dispose(); } finally { final Channel channel = connection.createChannel(); channel.exchangeDelete(exchangeName); channel.queueDelete(queueName); channel.close(); } }