List of usage examples for org.springframework.data.redis.connection RedisConnection isSubscribed
boolean isSubscribed();
From source file:com.zxy.commons.cache.RedisUtils.java
/** * Indicates whether the current connection is subscribed (to at least one channel) or not. * //from ww w . j a va 2 s . c o m * @return true if the connection is subscribed, false otherwise */ public static boolean isSubscribed() { return redisTemplate.execute(new RedisCallback<Boolean>() { @Override public Boolean doInRedis(RedisConnection redis) throws DataAccessException { return redis.isSubscribed(); } }); }
From source file:com.zxy.commons.cache.RedisHelper.java
/** * Indicates whether the current connection is subscribed (to at least one channel) or not. * //from w w w . java 2 s . c o m * @return true if the connection is subscribed, false otherwise */ public boolean isSubscribed() { return redisTemplate.execute(new RedisCallback<Boolean>() { @Override public Boolean doInRedis(RedisConnection redis) throws DataAccessException { return redis.isSubscribed(); } }); }
From source file:org.springframework.integration.redis.inbound.RedisInboundChannelAdapterTests.java
/** * Wait until the container has subscribed to the queue and return a * reference to it, so we can stop it at the end of the test. *//*from www . j a va 2 s. co m*/ protected RedisMessageListenerContainer waitUntilSubscribed(RedisInboundChannelAdapter adapter) throws Exception { RedisMessageListenerContainer container = (RedisMessageListenerContainer) TestUtils .getPropertyValue(adapter, "container"); Object subscriptionTask = TestUtils.getPropertyValue(container, "subscriptionTask"); RedisConnection connection = (RedisConnection) TestUtils.getPropertyValue(subscriptionTask, "connection"); int n = 0; while (true) { if (n++ > 50) { fail("RMLC Failed to Subscribe"); } if (connection.isSubscribed()) { logger.debug("Subscribed OK"); break; } logger.debug("Waiting..."); Thread.sleep(100); } Thread.sleep(100); // Wait a little longer due to race condition in connection.isSubscribed() return container; }