List of usage examples for org.springframework.jms.listener DefaultMessageListenerContainer isRegisteredWithDestination
public boolean isRegisteredWithDestination()
From source file:org.springframework.integration.jms.SubscribableJmsChannelTests.java
/** * Blocks until the listener container has subscribed; if the container does not support * this test, or the caching mode is incompatible, true is returned. Otherwise blocks * until timeout milliseconds have passed, or the consumer has registered. * @see DefaultMessageListenerContainer#isRegisteredWithDestination() * @param timeout Timeout in milliseconds. * @return True if a subscriber has connected or the container/attributes does not support * the test. False if a valid container does not have a registered consumer within * timeout milliseconds./*ww w . jav a 2 s . c o m*/ */ private static boolean waitUntilRegisteredWithDestination(SubscribableJmsChannel channel, long timeout) { AbstractMessageListenerContainer container = (AbstractMessageListenerContainer) new DirectFieldAccessor( channel).getPropertyValue("container"); if (container instanceof DefaultMessageListenerContainer) { DefaultMessageListenerContainer listenerContainer = (DefaultMessageListenerContainer) container; if (listenerContainer.getCacheLevel() != DefaultMessageListenerContainer.CACHE_CONSUMER) { return true; } while (timeout > 0) { if (listenerContainer.isRegisteredWithDestination()) { return true; } try { Thread.sleep(100); } catch (InterruptedException e) { } timeout -= 100; } return false; } return true; }