List of usage examples for org.springframework.data.redis.connection RedisConnection publish
@Nullable Long publish(byte[] channel, byte[] message);
From source file:com.miko.demo.mongo.service.RedisPublishSubscribeTest.java
@Test public void testRedisSubNoConversation() { RedisConnection redis = connectionFactory.getConnection(); try {/*from w w w.j av a 2s .co m*/ redis.publish(DUMP_CHANNEL.getBytes(), "Hello World!".getBytes()); } finally { redis.close(); } }
From source file:com.miko.demo.mongo.service.RedisPublishSubscribeTest.java
@Test public void testPubSubWithConversion() { RedisConnection redis = connectionFactory.getConnection(); RedisMessageListenerContainer listeners = new RedisMessageListenerContainer(); listeners.setConnectionFactory(connectionFactory); MessageListenerAdapter listener = new MessageListenerAdapter(new BeanMessageListener()); listener.setSerializer(new BeanMessageSerializer()); listener.afterPropertiesSet();/* www.ja v a 2 s . c o m*/ listeners.addMessageListener(listener, new ChannelTopic(DUMP_CHANNEL)); listeners.afterPropertiesSet(); listeners.start(); try { redis.publish(DUMP_CHANNEL.getBytes(), "Hello World!".getBytes()); } finally { redis.close(); listeners.stop(); } }
From source file:com.zxy.commons.cache.RedisUtils.java
/** * Publishes the given message to the given channel. * /*from w w w . ja va 2 s. c om*/ * @param channel the channel to publish to * @param message message to publish * @return the number of clients that received the message */ public static Long publish(byte[] channel, byte[] message) { return redisTemplate.execute(new RedisCallback<Long>() { @Override public Long doInRedis(RedisConnection redis) throws DataAccessException { return redis.publish(channel, message); } }); }
From source file:com.zxy.commons.cache.RedisHelper.java
/** * Publishes the given message to the given channel. * //w w w. ja v a 2 s . com * @param channel the channel to publish to * @param message message to publish * @return the number of clients that received the message */ public Long publish(byte[] channel, byte[] message) { return redisTemplate.execute(new RedisCallback<Long>() { @Override public Long doInRedis(RedisConnection redis) throws DataAccessException { return redis.publish(channel, message); } }); }