public synchronized void stop() { if (this.abortStarted == 0) { // signal handle delivery to use offer this.abortStarted = System.currentTimeMillis(); } if (!this.cancelled()) { try { RabbitUtils.closeMessageConsumer(this.channel, getConsumerTags(), this.transactional); } catch (Exception e) { if (logger.isDebugEnabled()) { logger.debug("Error closing consumer " + this, e); } } } if (logger.isDebugEnabled()) { logger.debug("Closing Rabbit Channel: " + this.channel); } RabbitUtils.setPhysicalCloseRequired(this.channel, true); ConnectionFactoryUtils.releaseResources(this.resourceHolder); this.deliveryTags.clear(); this.consumers.clear(); this.queue.clear(); // in case we still have a client thread blocked }
public synchronized void stop() { if (this.abortStarted == 0) { // signal handle delivery to use offer this.abortStarted = System.currentTimeMillis(); } if (!this.cancelled()) { try { RabbitUtils.closeMessageConsumer(this.channel, getConsumerTags(), this.transactional); } catch (Exception e) { if (logger.isDebugEnabled()) { logger.debug("Error closing consumer " + this, e); } } } if (logger.isDebugEnabled()) { logger.debug("Closing Rabbit Channel: " + this.channel); } RabbitUtils.setPhysicalCloseRequired(this.channel, true); ConnectionFactoryUtils.releaseResources(this.resourceHolder); this.deliveryTags.clear(); this.consumers.clear(); this.queue.clear(); // in case we still have a client thread blocked }
RabbitUtils.setPhysicalCloseRequired(channel, true);
RabbitUtils.setPhysicalCloseRequired(channelToClose, true);
RabbitUtils.setPhysicalCloseRequired(channel, true);
RabbitUtils.setPhysicalCloseRequired(channelToClose, true);
RabbitUtils.setPhysicalCloseRequired(channel, true);
RabbitUtils.setPhysicalCloseRequired(channel, true);
private void finalizeConsumer() { RabbitUtils.setPhysicalCloseRequired(getChannel(), true); RabbitUtils.closeChannel(getChannel()); RabbitUtils.closeConnection(this.connection); DirectMessageListenerContainer.this.cancellationLock.release(this); consumerRemoved(this); }
private void finalizeConsumer() { RabbitUtils.setPhysicalCloseRequired(getChannel(), true); RabbitUtils.closeChannel(getChannel()); RabbitUtils.closeConnection(this.connection); DirectMessageListenerContainer.this.cancellationLock.release(this); consumerRemoved(this); }
RabbitUtils.setPhysicalCloseRequired(channel, true); when(mockChannel.isOpen()).thenReturn(false); final CountDownLatch physicalCloseLatch = new CountDownLatch(1); }).when(mockChannel).close(); channel.close(); RabbitUtils.setPhysicalCloseRequired(channel, false);
@Test @Ignore // Test to verify log message is suppressed after patch to CCF public void testReturnsNormalCloseDeferredClose() throws Exception { com.rabbitmq.client.ConnectionFactory mockConnectionFactory = mock(com.rabbitmq.client.ConnectionFactory.class); com.rabbitmq.client.Connection mockConnection = mock(com.rabbitmq.client.Connection.class); Channel mockChannel = mock(Channel.class); when(mockConnectionFactory.newConnection(any(ExecutorService.class), anyString())).thenReturn(mockConnection); when(mockConnection.isOpen()).thenReturn(true); when(mockConnection.createChannel()).thenReturn(mockChannel); when(mockChannel.isOpen()).thenReturn(true); doThrow(new ShutdownSignalException(true, false, new com.rabbitmq.client.AMQP.Connection.Close.Builder() .replyCode(200) .replyText("OK") .build(), null)).when(mockChannel).close(); CachingConnectionFactory ccf = new CachingConnectionFactory(mockConnectionFactory); ccf.setPublisherReturns(true); ccf.setExecutor(Executors.newSingleThreadExecutor()); Connection conn = ccf.createConnection(); Channel channel = conn.createChannel(false); RabbitUtils.setPhysicalCloseRequired(channel, true); channel.close(); RabbitUtils.setPhysicalCloseRequired(channel, false); Thread.sleep(6000); }
RabbitUtils.setPhysicalCloseRequired(channel1, true); assertEquals(0, ((Semaphore) TestUtils.getPropertyValue(ccf, "checkoutPermits", Map.class).values().iterator().next()) RabbitUtils.setPhysicalCloseRequired(channel1, false); con.close(); verify(mockChannel1).close();
template.execute(c -> { c.basicPublish("", "test.shutdown", new BasicProperties(), "foo".getBytes()); RabbitUtils.setPhysicalCloseRequired(c, false); return null; });