List of usage examples for org.springframework.amqp.rabbit.connection ChannelProxy getTargetChannel
Channel getTargetChannel();
From source file:acromusashi.stream.component.rabbitmq.CachingConnectionFactory.java
/** * Reset the Channel cache and underlying shared Connection, to be reinitialized on next access. *///from ww w.j a v a 2s .com protected void reset() { this.active = false; synchronized (this.cachedChannelsNonTransactional) { for (ChannelProxy channel : this.cachedChannelsNonTransactional) { try { channel.getTargetChannel().close(); } catch (Throwable ex) { this.logger.trace("Could not close cached Rabbit Channel", ex); } } this.cachedChannelsNonTransactional.clear(); } synchronized (this.cachedChannelsTransactional) { for (ChannelProxy channel : this.cachedChannelsTransactional) { try { channel.getTargetChannel().close(); } catch (Throwable ex) { this.logger.trace("Could not close cached Rabbit Channel", ex); } } this.cachedChannelsTransactional.clear(); } this.active = true; }
From source file:org.springframework.amqp.rabbit.connection.CachingConnectionFactory.java
/** * Reset the Channel cache and underlying shared Connection, to be reinitialized on next access. */// w w w. j a va2s . c om protected void reset() { this.active = false; synchronized (this.cachedChannelsNonTransactional) { for (ChannelProxy channel : cachedChannelsNonTransactional) { try { channel.getTargetChannel().close(); } catch (Throwable ex) { logger.trace("Could not close cached Rabbit Channel", ex); } } this.cachedChannelsNonTransactional.clear(); } this.active = true; super.reset(); this.targetConnection = null; }
From source file:org.springframework.amqp.rabbit.connection.CachingConnectionFactoryTests.java
private void verifyChannelIs(Channel mockChannel, Channel channel) { ChannelProxy proxy = (ChannelProxy) channel; assertSame(mockChannel, proxy.getTargetChannel()); }
From source file:org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainerTests.java
private Answer<Object> messageToConsumer(final Channel mockChannel, final SimpleMessageListenerContainer container, final boolean cancel, final CountDownLatch latch) { return invocation -> { String returnValue = null; Set<?> consumers = TestUtils.getPropertyValue(container, "consumers", Map.class).keySet(); for (Object consumer : consumers) { ChannelProxy channel = TestUtils.getPropertyValue(consumer, "channel", ChannelProxy.class); if (channel != null && channel.getTargetChannel() == mockChannel) { Consumer rabbitConsumer = TestUtils.getPropertyValue(consumer, "consumer", Consumer.class); if (cancel) { rabbitConsumer.handleCancelOk((String) invocation.getArguments()[0]); } else { rabbitConsumer.handleConsumeOk("foo"); returnValue = "foo"; }/* w ww .j a v a 2 s . c o m*/ latch.countDown(); } } return returnValue; }; }