@Override public void handleShutdownSignal(String consumerTag, ShutdownSignalException sig) { if (logger.isDebugEnabled()) { if (RabbitUtils.isNormalShutdown(sig)) { logger.debug("Received shutdown signal for consumer tag=" + consumerTag + ": " + sig.getMessage()); } else { logger.debug("Received shutdown signal for consumer tag=" + consumerTag, sig); } } BlockingQueueConsumer.this.shutdown = sig; // The delivery tags will be invalid if the channel shuts down BlockingQueueConsumer.this.deliveryTags.clear(); BlockingQueueConsumer.this.activeObjectCounter.release(BlockingQueueConsumer.this); }
@Override public void handleShutdownSignal(String consumerTag, ShutdownSignalException sig) { if (logger.isDebugEnabled()) { if (RabbitUtils.isNormalShutdown(sig)) { logger.debug("Received shutdown signal for consumer tag=" + consumerTag + ": " + sig.getMessage()); } else { logger.debug("Received shutdown signal for consumer tag=" + consumerTag, sig); } } BlockingQueueConsumer.this.shutdown = sig; // The delivery tags will be invalid if the channel shuts down BlockingQueueConsumer.this.deliveryTags.clear(); BlockingQueueConsumer.this.activeObjectCounter.release(BlockingQueueConsumer.this); }
private void handleDeclarationException(int passiveDeclareRetries, DeclarationException e) { if (passiveDeclareRetries > 0 && this.channel.isOpen()) { if (logger.isWarnEnabled()) { logger.warn("Queue declaration failed; retries left=" + (passiveDeclareRetries), e); try { Thread.sleep(this.failedDeclarationRetryInterval); } catch (InterruptedException e1) { this.declaring = false; Thread.currentThread().interrupt(); this.activeObjectCounter.release(this); throw RabbitExceptionTranslator.convertRabbitAccessException(e1); // NOSONAR stack trace loss } } } else if (e.getFailedQueues().size() < this.queues.length) { if (logger.isWarnEnabled()) { logger.warn("Not all queues are available; only listening on those that are - configured: " + Arrays.asList(this.queues) + "; not available: " + e.getFailedQueues()); } this.missingQueues.addAll(e.getFailedQueues()); this.lastRetryDeclaration = System.currentTimeMillis(); } else { this.declaring = false; this.activeObjectCounter.release(this); throw new QueuesNotAvailableException("Cannot prepare queue for listener. " + "Either the queue doesn't exist or the broker will not allow us to use it.", e); } }
private void handleDeclarationException(int passiveDeclareRetries, DeclarationException e) { if (passiveDeclareRetries > 0 && this.channel.isOpen()) { if (logger.isWarnEnabled()) { logger.warn("Queue declaration failed; retries left=" + (passiveDeclareRetries), e); try { Thread.sleep(this.failedDeclarationRetryInterval); } catch (InterruptedException e1) { this.declaring = false; Thread.currentThread().interrupt(); this.activeObjectCounter.release(this); throw RabbitExceptionTranslator.convertRabbitAccessException(e1); // NOSONAR stack trace loss } } } else if (e.getFailedQueues().size() < this.queues.length) { if (logger.isWarnEnabled()) { logger.warn("Not all queues are available; only listening on those that are - configured: " + Arrays.asList(this.queues) + "; not available: " + e.getFailedQueues()); } this.missingQueues.addAll(e.getFailedQueues()); this.lastRetryDeclaration = System.currentTimeMillis(); } else { this.declaring = false; this.activeObjectCounter.release(this); throw new QueuesNotAvailableException("Cannot prepare queue for listener. " + "Either the queue doesn't exist or the broker will not allow us to use it.", e); } }
consumer.stop(); logger.error("Error starting new consumer", e); this.cancellationLock.release(consumer); this.consumers.remove(consumer);
consumer.stop(); logger.error("Error starting new consumer", e); this.cancellationLock.release(consumer); this.consumers.remove(consumer);
try { this.consumer.stop(); SimpleMessageListenerContainer.this.cancellationLock.release(this.consumer); if (getApplicationEventPublisher() != null) { getApplicationEventPublisher().publishEvent(
try { this.consumer.stop(); SimpleMessageListenerContainer.this.cancellationLock.release(this.consumer); if (getApplicationEventPublisher() != null) { getApplicationEventPublisher().publishEvent(
@Test public void testWaitForLocks() throws Exception { final Object object1 = new Object(); final Object object2 = new Object(); counter.add(object1); counter.add(object2); Future<Boolean> future = Executors.newSingleThreadExecutor().submit(() -> { counter.release(object1); counter.release(object2); counter.release(object2); return true; }); assertEquals(true, counter.await(1000L, TimeUnit.MILLISECONDS)); assertEquals(true, future.get()); }
this.cancellationLock.release(consumer); this.consumers.remove(consumer); if (!isActive()) {
this.cancellationLock.release(consumer); this.consumers.remove(consumer); if (!isActive()) {
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); }
@Test public void testActiveCount() throws Exception { final Object object1 = new Object(); final Object object2 = new Object(); counter.add(object1); counter.add(object2); assertEquals(2, counter.getCount()); counter.release(object2); assertEquals(1, counter.getCount()); counter.release(object1); counter.release(object1); assertEquals(0, counter.getCount()); }
private void setQosAndreateConsumers() { if (!this.acknowledgeMode.isAutoAck() && !cancelled()) { // Set basicQos before calling basicConsume (otherwise if we are not acking the broker // will send blocks of 100 messages) try { this.channel.basicQos(this.prefetchCount); } catch (IOException e) { this.activeObjectCounter.release(this); throw new AmqpIOException(e); } } try { if (!cancelled()) { for (String queueName : this.queues) { if (!this.missingQueues.contains(queueName)) { consumeFromQueue(queueName); } } } } catch (IOException e) { throw RabbitExceptionTranslator.convertRabbitAccessException(e); } }
private void setQosAndreateConsumers() { if (!this.acknowledgeMode.isAutoAck() && !cancelled()) { // Set basicQos before calling basicConsume (otherwise if we are not acking the broker // will send blocks of 100 messages) try { this.channel.basicQos(this.prefetchCount); } catch (IOException e) { this.activeObjectCounter.release(this); throw new AmqpIOException(e); } } try { if (!cancelled()) { for (String queueName : this.queues) { if (!this.missingQueues.contains(queueName)) { consumeFromQueue(queueName); } } } } catch (IOException e) { throw RabbitExceptionTranslator.convertRabbitAccessException(e); } }
logger.debug("Consumer stopping; no queues for " + this.consumer); SimpleMessageListenerContainer.this.cancellationLock.release(this.consumer); if (getApplicationEventPublisher() != null) { getApplicationEventPublisher().publishEvent(
logger.debug("Consumer stopping; no queues for " + this.consumer); SimpleMessageListenerContainer.this.cancellationLock.release(this.consumer); if (getApplicationEventPublisher() != null) { getApplicationEventPublisher().publishEvent(