You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: org.springframework.jms/src/main/java/org/springframework/jms/listener/DefaultMessageListenerContainer.java
+31Lines changed: 31 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -178,6 +178,8 @@ public class DefaultMessageListenerContainer extends AbstractPollingMessageListe
178
178
179
179
privateintactiveInvokerCount = 0;
180
180
181
+
privateintregisteredWithDestination = 0;
182
+
181
183
privateRunnablestopCallback;
182
184
183
185
privateObjectcurrentRecoveryMarker = newObject();
@@ -577,6 +579,27 @@ public final int getActiveConsumerCount() {
577
579
}
578
580
}
579
581
582
+
/**
583
+
* Return whether at lease one consumer has entered a fixed registration with the
584
+
* target destination. This is particularly interesting for the pub-sub case where
585
+
* it might be important to have an actual consumer registered that is guaranteed
586
+
* to not miss any messages that are just about to be published.
587
+
* <p>This method may be polled after a {@link #start()} call, until asynchronous
588
+
* registration of consumers has happened which is when the method will start returning
589
+
* <code>true</code> - provided that the listener container actually ever establishes
590
+
* a fixed registration. It will then keep returning <code>true</code> until shutdown,
591
+
* since the container will hold on to at least one consumer registration thereafter.
592
+
* <p>Note that a listener container is not bound to having a fixed registration in
593
+
* the first place. It may also keep recreating consumers for every invoker execution.
594
+
* This particularly depends on the {@link #setCacheLevel cache level} setting:
595
+
* Only CACHE_CONSUMER will lead to a fixed registration.
596
+
*/
597
+
publicbooleanisRegisteredWithDestination() {
598
+
synchronized (this.lifecycleMonitor) {
599
+
return (this.registeredWithDestination > 0);
600
+
}
601
+
}
602
+
580
603
581
604
/**
582
605
* Create a default TaskExecutor. Called if no explicit TaskExecutor has been specified.
0 commit comments