container.setErrorHandler(this.replyErrorHandler); container.start(); this.directReplyToContainers.put(connectionFactory, container); this.replyAddress = Address.AMQ_RABBITMQ_REPLY_TO;
container.setErrorHandler(this.replyErrorHandler); container.start(); this.directReplyToContainers.put(connectionFactory, container); this.replyAddress = Address.AMQ_RABBITMQ_REPLY_TO;
@Override public synchronized void start() { if (!this.running) { if (this.internalTaskScheduler) { ThreadPoolTaskScheduler scheduler = new ThreadPoolTaskScheduler(); scheduler.setThreadNamePrefix(getBeanName() == null ? "asyncTemplate-" : (getBeanName() + "-")); scheduler.afterPropertiesSet(); this.taskScheduler = scheduler; } if (this.container != null) { this.container.start(); } if (this.directReplyToContainer != null) { this.directReplyToContainer.setTaskScheduler(this.taskScheduler); this.directReplyToContainer.start(); } } this.running = true; }
@Override public synchronized void start() { if (!this.running) { if (this.internalTaskScheduler) { ThreadPoolTaskScheduler scheduler = new ThreadPoolTaskScheduler(); scheduler.setThreadNamePrefix(getBeanName() == null ? "asyncTemplate-" : (getBeanName() + "-")); scheduler.afterPropertiesSet(); this.taskScheduler = scheduler; } if (this.container != null) { this.container.start(); } if (this.directReplyToContainer != null) { this.directReplyToContainer.setTaskScheduler(this.taskScheduler); this.directReplyToContainer.start(); } } this.running = true; }
@Test public void testReplyToReleaseWithCancel() throws Exception { CachingConnectionFactory cf = new CachingConnectionFactory("localhost"); DirectReplyToMessageListenerContainer container = new DirectReplyToMessageListenerContainer(cf); container.setBeanName("releaseCancel"); final CountDownLatch consumeLatch = new CountDownLatch(1); final CountDownLatch releaseLatch = new CountDownLatch(1); container.setApplicationEventPublisher(e -> { if (e instanceof ListenerContainerConsumerTerminatedEvent) { releaseLatch.countDown(); } else if (e instanceof ConsumeOkEvent) { consumeLatch.countDown(); } }); container.afterPropertiesSet(); container.start(); ChannelHolder channelHolder = container.getChannelHolder(); assertTrue(consumeLatch.await(10, TimeUnit.SECONDS)); container.releaseConsumerFor(channelHolder, true, "foo"); assertTrue(releaseLatch.await(10, TimeUnit.SECONDS)); container.stop(); cf.destroy(); }
.setPropertyValue("messageListener", mockMessageListener); container.start(); ChannelHolder channel1 = container.getChannelHolder(); BasicProperties props = new BasicProperties().builder().replyTo(Address.AMQ_RABBITMQ_REPLY_TO).build();
@Test public void testReplyToConsumersReduced() throws Exception { CachingConnectionFactory cf = new CachingConnectionFactory("localhost"); DirectReplyToMessageListenerContainer container = new DirectReplyToMessageListenerContainer(cf); container.setBeanName("reducing"); container.setIdleEventInterval(100); CountDownLatch latch = new CountDownLatch(5); container.setApplicationEventPublisher(e -> { if (e instanceof ListenerContainerIdleEvent) { latch.countDown(); } }); container.afterPropertiesSet(); container.start(); ChannelHolder channelHolder1 = container.getChannelHolder(); ChannelHolder channelHolder2 = container.getChannelHolder(); assertTrue(activeConsumerCount(container, 2)); container.releaseConsumerFor(channelHolder2, false, null); assertTrue(latch.await(10, TimeUnit.SECONDS)); assertTrue(channelHolder1.getChannel().isOpen()); container.releaseConsumerFor(channelHolder1, false, null); assertTrue(activeConsumerCount(container, 0)); container.stop(); cf.destroy(); }