Commit 30efbf7
committed
GH-3005: Fix
Fixes: #3005
Issue link: #3005
The `SimpleMessageListenerContainer$AsyncMessageProcessingConsumer.killOrRestart()`
is also called during application context shutdown.
At this moment we cannot emit events into an application context.
Otherwise, it fails with:
```
Exception in thread "rabbitListenerExecutor1" org.springframework.beans.factory.BeanCreationNotAllowedException: Error creating bean with name 'refreshEventListener': Singleton bean creation not allowed while singletons of this factory are in destruction (Do not request a bean from a BeanFactory in a destroy method implementation!)
```
* Introduce `ObservableListenerContainer.isApplicationContextClosed()`
and call it as additional condition in the `SimpleMessageListenerContainer$AsyncMessageProcessingConsumer.killOrRestart()`
before trying to emit `AsyncConsumerStoppedEvent`
**Auto-cherry-pick to `3.2.x`**
The fix for `3.1.x` requires a slightly different approach via `ContextClosedEvent`SimpleMLC.killOrRestart for closed AC1 parent b55010f commit 30efbf7
File tree
2 files changed
+11
-5
lines changed- spring-rabbit/src/main/java/org/springframework/amqp/rabbit/listener
2 files changed
+11
-5
lines changedLines changed: 7 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| 29 | + | |
29 | 30 | | |
30 | 31 | | |
31 | 32 | | |
| |||
121 | 122 | | |
122 | 123 | | |
123 | 124 | | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
124 | 131 | | |
125 | 132 | | |
126 | 133 | | |
| |||
Lines changed: 4 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
| 67 | + | |
67 | 68 | | |
68 | 69 | | |
69 | 70 | | |
| |||
807 | 808 | | |
808 | 809 | | |
809 | 810 | | |
810 | | - | |
811 | 811 | | |
812 | 812 | | |
813 | 813 | | |
| |||
875 | 875 | | |
876 | 876 | | |
877 | 877 | | |
878 | | - | |
879 | 878 | | |
880 | 879 | | |
881 | 880 | | |
| |||
1272 | 1271 | | |
1273 | 1272 | | |
1274 | 1273 | | |
1275 | | - | |
1276 | 1274 | | |
1277 | 1275 | | |
1278 | 1276 | | |
| |||
1556 | 1554 | | |
1557 | 1555 | | |
1558 | 1556 | | |
1559 | | - | |
1560 | | - | |
| 1557 | + | |
| 1558 | + | |
| 1559 | + | |
1561 | 1560 | | |
1562 | 1561 | | |
1563 | 1562 | | |
| |||
0 commit comments