|
61 | 61 | import org.springframework.amqp.rabbit.support.ListenerExecutionFailedException;
|
62 | 62 | import org.springframework.amqp.rabbit.support.RabbitExceptionTranslator;
|
63 | 63 | import org.springframework.amqp.support.ConsumerTagStrategy;
|
| 64 | +import org.springframework.context.ApplicationEventPublisher; |
64 | 65 | import org.springframework.core.log.LogMessage;
|
65 | 66 | import org.springframework.jmx.export.annotation.ManagedMetric;
|
66 | 67 | import org.springframework.jmx.support.MetricType;
|
@@ -798,7 +799,6 @@ protected void adjustConsumers(int deltaArg) {
|
798 | 799 | }
|
799 | 800 | }
|
800 | 801 |
|
801 |
| - |
802 | 802 | /**
|
803 | 803 | * Start up to delta consumers, limited by {@link #setMaxConcurrentConsumers(int)}.
|
804 | 804 | * @param delta the consumers to add.
|
@@ -863,7 +863,6 @@ private void considerAddingAConsumer() {
|
863 | 863 | }
|
864 | 864 | }
|
865 | 865 |
|
866 |
| - |
867 | 866 | private void considerStoppingAConsumer(BlockingQueueConsumer consumer) {
|
868 | 867 | this.consumersLock.lock();
|
869 | 868 | try {
|
@@ -1266,7 +1265,6 @@ private final class AsyncMessageProcessingConsumer implements Runnable {
|
1266 | 1265 |
|
1267 | 1266 | private boolean failedExclusive;
|
1268 | 1267 |
|
1269 |
| - |
1270 | 1268 | AsyncMessageProcessingConsumer(BlockingQueueConsumer consumer) {
|
1271 | 1269 | this.consumer = consumer;
|
1272 | 1270 | this.start = new CountDownLatch(1);
|
@@ -1531,8 +1529,9 @@ private void killOrRestart(boolean aborted) {
|
1531 | 1529 | try {
|
1532 | 1530 | this.consumer.stop();
|
1533 | 1531 | SimpleMessageListenerContainer.this.cancellationLock.release(this.consumer);
|
1534 |
| - if (getApplicationEventPublisher() != null) { |
1535 |
| - getApplicationEventPublisher().publishEvent( |
| 1532 | + ApplicationEventPublisher applicationEventPublisher = getApplicationEventPublisher(); |
| 1533 | + if (applicationEventPublisher != null && !isApplicationContextClosed()) { |
| 1534 | + applicationEventPublisher.publishEvent( |
1536 | 1535 | new AsyncConsumerStoppedEvent(SimpleMessageListenerContainer.this, this.consumer));
|
1537 | 1536 | }
|
1538 | 1537 | }
|
|
0 commit comments