net.dredis.redis listenerr.impl.messagedelegateredis listenerrimpl 哪个jar

Spring Data Redis实现一个订阅/发布系统
我的图书馆
Spring Data Redis实现一个订阅/发布系统
Redis是一个key-value的存储系统,提供的key-value类似与Memcached而数据结构又多于memcached,而且性能优异.广泛用于缓存,临时存储等.而我今天
这个例子是使用Redis实现一个订阅/发布系统,而不是如何使用它存储key-value的数据.
Redis是天生支持订阅/发布的,不是我牵强附会拼凑而实现这样的效果,如果真是这样性能没法保证,而且要实现订阅/发布这样的系统是有很多解决方案的.
下载,安装和配置Redis,见:&&和&
Spring一直秉承不发明轮子的,对于很多其他技术都是提供一个模板:Template,如JDBC-JdbcTemplate,JMSTemplate等,Redis他也提供RedisTemplate,有了这个RedisTemplate你可以做任何事,存取key-value,订阅,发布等都通过这个对象实现.
实现一个RedisDAO,接口我不贴了
01public class RedisDAOImpl implements RedisDAO {02&03&&&&private RedisTemplate&String, Object& redisTemplate = null;04&05&&&&public RedisDAOImpl() {06&07&&&&}08&09&&&&@Override10&&&&public void sendMessage(String channel, Serializable message) {11&&&&&&&&redisTemplate.convertAndSend(channel, message);12&&&&}13&14&15&&&&public RedisTemplate getRedisTemplate() {16&&&&&&&&return redisT17&&&&}18&19&&&&public void setRedisTemplate(RedisTemplate redisTemplate) {20&&&&&&&&this.redisTemplate = redisT21&&&&}22} 可以看到,通过这个 sendMessage方法,我可以把一条可序列化的消息发送到channel频道,订阅者只要订阅了这个channel,他就会接收发布者发布的消息.
当然有了发布消息的sendMessage也得有个接收消息的Listener,用于接收订阅到的消息.
01public class MessageDelegateListenerImpl implements MessageDelegateListener {02&03&&&&@Override04&&&&public void handleMessage(Serializable message) {05&&&&&&&&//什么都不做,只输出06&&&&&&&&if(message == null){07&&&&&&&&&&&&System.out.println("null");08&&&&&&&&} else if(message.getClass().isArray()){09&&&&&&&&&&&&System.out.println(Arrays.toString((Object[])message));10&&&&&&&&} else if(message instanceof List&?&) {11&&&&&&&&&&&&System.out.println(message);12&&&&&&&&} else if(message instanceof Map&? , ?&) {13&&&&&&&&&&&&System.out.println(message);14&&&&&&&&} else {15&&&&&&&&&&&&System.out.println(ToStringBuilder.reflectionToString(message));16&&&&&&&&}17&&&&}18} 好了,有上面的两个类,加上Spring基本上就可以工作了.当然还得启动Redis.
Spring Schema:
01&?xml version="1.0" encoding="UTF-8"?&02&beans xmlns="http://www.springframework.org/schema/beans"03&&&&&&&xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"04&&&&&&&xmlns:context="http://www.springframework.org/schema/context"05&&&&&&&xmlns:redis="http://www.springframework.org/schema/redis"06&&&&&&&xmlns:p="http://www.springframework.org/schema/p"07&08&&&&&&&xsi:schemaLocation="http://www.springframework.org/schema/beans09&&&&&&&http://www.springframework.org/schema/beans/spring-beans-3.0.xsd10&&&&&&&http://www.springframework.org/schema/context11&&&&&&&http://www.springframework.org/schema/context/spring-context-3.0.xsd12&&&&&&&http://www.springframework.org/schema/redis13&&&&&&&&http://www.springframework.org/schema/redis/spring-redis-1.0.xsd"&14&15&&&&&bean id="redisConnectionFactory" class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory"16&&&&&&&&&&p:hostName="localhost" p:port="6379" p:usePool="true"&17&&&&&/bean&18&19&&&&&!-- redis template definition --&20&&&&&bean id="redisTemplate" class="org.springframework.data.redis.core.RedisTemplate"21&&&&&&&&&&p:connectionFactory-ref="redisConnectionFactory"/&22&23&&&&&bean id="redisDAO" class="net.dredis.dao.impl.RedisDAOImpl"&24&&&&&&&&&property name="redisTemplate" ref="redisTemplate" /&25&&&&&/bean&26&27&&&&&bean id="listener" class="net.dredis.listener.impl.MessageDelegateListenerImpl"/&28&29&&&&&!-- the default ConnectionFactory --&30&&&&&bean id="jdkSerializer" class="org.springframework.data.redis.serializer.JdkSerializationRedisSerializer" /&31&32&&&&&redis:listener-container&33&&&&&&&&&!-- the method attribute can be skipped as the default method name is "handleMessage" --&34&&&&&&&&&redis:listener ref="listener" serializer="jdkSerializer" method="handleMessage" topic="java" /&35&&&&&/redis:listener-container&36&/beans& 如上面的配置, jdkSerializer是jdk默认的序列化的实现,当然还有很多其他序列化Java对象的方法,这里使用jdk默认实现.
Method属性是配置订阅系统接收消息的方法,默认也是"handleMessage"
topic就是订阅的channel频道,是有发布到java这个channel的消息才会被接收.
01public static void main(String[] args) {02&&&&&&&&new ClassPathXmlApplicationContext("pubsubAppContext1.xml");;03&&&&&&&&while (true) { //这里是一个死循环,目的就是让进程不退出,用于接收发布的消息04&&&&&&&&&&&&try {05&&&&&&&&&&&&&&&&System.out.println("current time: " + new Date());06&07&&&&&&&&&&&&&&&&Thread.sleep(3000);08&&&&&&&&&&&&} catch (InterruptedException e) {09&&&&&&&&&&&&&&&&e.printStackTrace();10&&&&&&&&&&&&}11&&&&&&&&}12&&&&} OK,启动了订阅系统后,我们就可以发布消息,测试类如:
01@Test02&&&&public void testPublishMessage() throws Exception {03&&&&&&&&String msg = "Hello, Redis!";04&&&&&&&&redisDAO.sendMessage("java", msg); //发布字符串消息05&06&07&&&&&&&&RedisTestBean bean = new RedisTestBean("123456");08&&&&&&&&bean.setName("Redis");09&&&&&&&&bean.setOld((byte)2);10&&&&&&&&bean.setSeliry((short)40);11&&&&&&&&bean.setManbers(new String[]{"234567", "3456789"});12&&&&&&&&redisDAO.sendMessage("java", bean); //发布一个普通的javabean消息13&14&15&&&&&&&&Integer[] values = new Integer[]{21341,123123,12323};16&&&&&&&&redisDAO.sendMessage("java", values);& //发布一个数组消息17&&&&} 如测试,我连续发布了3条消息,都是不同的数据类型.订阅端输出如:
1current time: Fri Oct 26 20:38:31 CST 20122[2, 12323]3java.lang.String@379faa8c[value={H,e,l,l,o,,, ,R,e,d,i,s,!},hash=]4net.dredis.entity.RedisTestBean@7dee05dc[uid=123456,name=Redis,seliry=40,old=2,manbers={6789}]5current time: Fri Oct 26 20:38:34 CST 20126current time: Fri Oct 26 20:38:37 CST 2012 OK他接收到了这3条消息,而且和预期一样.
对于Spring还有传统风格的配置方式,实现的功能和前面一模一样.
01&?xml version="1.0" encoding="UTF-8"?&02&beans xmlns="http://www.springframework.org/schema/beans"03&&&&&&&xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"04&&&&&&&xmlns:context="http://www.springframework.org/schema/context"05&&&&&&&xmlns:p="http://www.springframework.org/schema/p"06&07&&&&&&&xsi:schemaLocation="http://www.springframework.org/schema/beans08&&&&&&&http://www.springframework.org/schema/beans/spring-beans-3.0.xsd09&&&&&&&http://www.springframework.org/schema/context10&&&&&&&http://www.springframework.org/schema/context/spring-context-3.0.xsd"&11&12&&&&&bean id="jedisConnectionFactory" class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory"13&&&&&&&&&&p:hostName="localhost" p:port="6379" p:usePool="true"&14&&&&&/bean&15&16&&&&&!-- redis template definition --&17&&&&&bean id="redisTemplate" class="org.springframework.data.redis.core.RedisTemplate"18&&&&&&&&&&p:connectionFactory-ref="jedisConnectionFactory"/&19&20&&&&&bean id="redisDAO" class="net.dredis.dao.impl.RedisDAOImpl"&21&&&&&&&&&property name="redisTemplate" ref="redisTemplate" /&22&&&&&/bean&23&24&&&&&bean id="serialization" class="org.springframework.data.redis.serializer.JdkSerializationRedisSerializer" /&25&26&&&&&bean id="messageDelegateListener" class="net.dredis.listener.impl.MessageDelegateListenerImpl" /&27&&&&&28&&&&&bean id="messageListener" class="org.springframework.data.redis.listener.adapter.MessageListenerAdapter"&29&&&&&&&&&property name="delegate" ref="messageDelegateListener" /&30&&&&&&&&&property name="serializer" ref="serialization" /&31&&&&&/bean&32&33&&&&&bean id="redisContainer" class="org.springframework.data.redis.listener.RedisMessageListenerContainer"&34&&&&&&&&&property name="connectionFactory" ref="jedisConnectionFactory"/&35&&&&&&&&&property name="messageListeners"&36&&&&&&&&&&&&&!-- map of listeners and their associated topics (channels or/and patterns) --&37&&&&&&&&&&&&&map&38&&&&&&&&&&&&&&&&&entry key-ref="messageListener"&39&&&&&&&&&&&&&&&&&&&&&bean class="org.springframework.data.redis.listener.ChannelTopic"&40&&&&&&&&&&&&&&&&&&&&&&&&&constructor-arg value="java" /&41&&&&&&&&&&&&&&&&&&&&&/bean&42&&&&&&&&&&&&&&&&&/entry&43&&&&&&&&&&&&&/map&44&&&&&&&&&/property&45&&&&&/bean&46&/beans&
TA的最新馆藏[转]&
喜欢该文的人也喜欢spring-redis实现订阅发布
chengxuyuan
发布时间: 11:50:14
&&&&&&& &dependency&
&&&&&&&&&&& &groupId&org.springframework.data&/groupId&
&&&&&&&&&&& &artifactId&spring-data-redis&/artifactId&
&&&&&&&&&&& &version&1.0.3.RELEASE&/version&
&&&&&&& &/dependency&
生产端代码: 接口省略
import java.io.S
import org.springframework.data.redis.core.RedisT
public class RedisDAOImpl implements RedisDAO{
private RedisTemplate&String, Object& redisTemplate =
public RedisDAOImpl() {
public void sendMessage(String channel, Serializable message) {
redisTemplate.convertAndSend(channel, message);
public RedisTemplate getRedisTemplate() {
return redisT
public void setRedisTemplate(RedisTemplate redisTemplate) {
this.redisTemplate = redisT
客户端代码:用于监听redis
import com.sun.tools.javac.util.L
import com.sun.xml.internal.xsom.impl.scd.I
import org..commons.lang.builder.ToStringB
import java.io.S
import java.util.A
public class MessageDelegateListenerImpl implements MessageDelegateListener {
public void handleMessage(Serializable message) {
//什么都不做,只输出
if(message == null){
System.out.println(&null&);
} else if(message.getClass().isArray()){
System.out.println(Arrays.toString((Object[]) message));
} else if(message instanceof List&?&) {
System.out.println(message);
} else if(message instanceof Iterators.Map&? , ?&) {
System.out.println(message);
System.out.println(ToStringBuilder.reflectionToString(message));
System.out.println(message);
先启消费端,消费端测试类:
import org.junit.B
import org.springframework.context.ApplicationC
import org.springframework.context.support.ClassPathXmlApplicationC
import java.util.D
public class TestRedisConsumer {
private MessageDelegateListenerImpl messageDelegateListener=
public void setUp() throws Exception {
ApplicationContext applicationContext = new ClassPathXmlApplicationContext(&spring-consumer-test.xml&);
messageDelegateListener = (MessageDelegateListenerImpl) applicationContext.getBean(&messageDelegateListener&);
public static void main(String[] args) {
new ClassPathXmlApplicationContext(&spring-consumer-test.xml&);
System.out.println(&消费者1&);
while (true) { //这里是一个死循环,目的就是让进程不退出,用于接收发布的消息
Thread.sleep(3000);
} catch (InterruptedException e) {
e.printStackTrace();
生产端测试类:
import service.weibo.impl.TencentOauthV1BackgroundServiceI
import service.weibo.impl.TencentOauthV1ForegroundServiceI
import org.junit.B
import org.junit.T
import org.springframework.context.ApplicationC
import org.springframework.context.support.ClassPathXmlApplicationC
public class TestRedisProduce {
private RedisDAOImpl redisDAO=
public void setUp() throws Exception {
ApplicationContext applicationContext = new ClassPathXmlApplicationContext(&spring-service-test.xml&);
redisDAO = (RedisDAOImpl) applicationContext.getBean(&redisDAO&);
public void testPublishMessage() throws Exception {
String msg = &Hello, Redis!&;
redisDAO.sendMessage(&java&, msg); //发布字符串消息
Integer[] values = new Integer[]{,12323};
redisDAO.sendMessage(&java&, values);
//发布一个数组消息
生产端xml配置:
&?xml version=&1.0& encoding=&UTF-8&?&
&beans xmlns=&http://www.springframework.org/schema/beans&
xmlns:xsi=&http://www.w3.org/2001/XMLSchema-instance&
xmlns:context=&http://www.springframework.org/schema/context&
xmlns:redis=&http://www.springframework.org/schema/redis&
xmlns:p=&http://www.springframework.org/schema/p&
xsi:schemaLocation=&http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/redis
http://www.springframework.org/schema/redis/spring-redis-1.0.xsd&&
&bean id=&redisConnectionFactory& class=&org.springframework.data.redis.connection.jedis.JedisConnectionFactory&
p:hostName=&10.25.172.174& p:port=&6379& p:usePool=&true&&
&!-- redis template definition --&
&bean id=&redisTemplate& class=&org.springframework.data.redis.core.RedisTemplate&
p:connectionFactory-ref=&redisConnectionFactory&/&
&bean id=&redisDAO& class=&jredis.RedisDAOImpl&&
&property name=&redisTemplate& ref=&redisTemplate& /&
&bean id=&listener& class=&jredis.MessageDelegateListenerImpl&/&
&!-- the default ConnectionFactory --&
&bean id=&jdkSerializer& class=&org.springframework.data.redis.serializer.JdkSerializationRedisSerializer& /&
&redis:listener-container&
&!-- the method attribute can be skipped as the default method name is &handleMessage& --&
&redis:listener ref=&listener& serializer=&jdkSerializer& method=&handleMessage& topic=&java& /&
发布频道的名称--&
&/redis:listener-container&
消费端XML配置:
&?xml version=&1.0& encoding=&UTF-8&?&
&beans xmlns=&http://www.springframework.org/schema/beans&
xmlns:xsi=&http://www.w3.org/2001/XMLSchema-instance&
xmlns:context=&http://www.springframework.org/schema/context&
xmlns:p=&http://www.springframework.org/schema/p&
xsi:schemaLocation=&http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd&&
&bean id=&jedisConnectionFactory& class=&org.springframework.data.redis.connection.jedis.JedisConnectionFactory&
p:hostName=&10.25.172.174& p:port=&6379& p:usePool=&true&&
&!-- redis template definition --&
&bean id=&redisTemplate& class=&org.springframework.data.redis.core.RedisTemplate&
p:connectionFactory-ref=&jedisConnectionFactory&/&
&bean id=&redisDAO& class=&jredis.RedisDAOImpl&&
&property name=&redisTemplate& ref=&redisTemplate& /&
&bean id=&serialization& class=&org.springframework.data.redis.serializer.JdkSerializationRedisSerializer& /&
&bean id=&messageDelegateListener& class=&jredis.MessageDelegateListenerImpl& /&
&bean id=&messageListener& class=&org.springframework.data.redis.listener.adapter.MessageListenerAdapter&&
&property name=&delegate& ref=&messageDelegateListener& /&
&property name=&serializer& ref=&serialization& /&
&bean id=&redisContainer& class=&org.springframework.data.redis.listener.RedisMessageListenerContainer&&
&property name=&connectionFactory& ref=&jedisConnectionFactory&/&
&property name=&messageListeners&&
&!-- map of listeners and their associated topics (channels or/and patterns) --&
&entry key-ref=&messageListener&&
&bean class=&org.springframework.data.redis.listener.ChannelTopic&&
&constructor-arg value=&java& /&
&!-- 这里配置消费端需要订阅的频道,可以是多个。该一例子订阅JAVA这个频道
&/property&
&/beans&缺点:
因为spring-redis是基于客户端的,所以如果将客户端进行分布式部署,部署几个实例就有几个实例收到相同的消息。大多数情况我们并不需要如此。我们只需要其中的一个实例处理该条消息即可。这种情况,redis有没有提供处理办法呢?本人还没有找到,欢迎大家提供方案。
版权声明:本文为博主原创文章,未经博主允许不得转载。
来源:http://blog.csdn.net/chengxuyuan/article/details/910JAVA(172)
Redis是一个key-value的存储系统,提供的key-value类似与Memcached而数据结构又多于memcached,而且性能优异.广泛用于缓存,临时存储等.而我今天&这个例子是使用Redis实现一个订阅/发布系统,而不是如何使用它存储key-value的数据.&
Redis是天生支持订阅/发布的,不是我牵强附会拼凑而实现这样的效果,如果真是这样性能没法保证,而且要实现订阅/发布这样的系统是有很多解决方案的.&
下载,安装和配置Redis
Spring一直秉承不发明轮子的,对于很多其他技术都是提供一个模板:Template,如JDBC-JdbcTemplate,JMSTemplate等,Redis他也提供RedisTemplate,有了这个RedisTemplate你可以做任何事,存取key-value,订阅,发布等都通过这个对象实现.
实现一个RedisDAO,接口我不贴了
public class RedisDAOImpl implements RedisDAO {
private RedisTemplate&String, Object& redisTemplate =
public RedisDAOImpl() {
public void sendMessage(String channel, Serializable message) {
redisTemplate.convertAndSend(channel, message);
public RedisTemplate getRedisTemplate() {
return redisT
public void setRedisTemplate(RedisTemplate redisTemplate) {
this.redisTemplate = redisT
可以看到,通过这个 sendMessage方法,我可以把一条可序列化的消息发送到channel频道,订阅者只要订阅了这个channel,他就会接收发布者发布的消息.&
当然有了发布消息的sendMessage也得有个接收消息的Listener,用于接收订阅到的消息.&
public class MessageDelegateListenerImpl implements MessageDelegateListener {
public void handleMessage(Serializable message) {
//什么都不做,只输出
if(message == null){
System.out.println(&null&);
} else if(message.getClass().isArray()){
System.out.println(Arrays.toString((Object[])message));
} else if(message instanceof List&?&) {
System.out.println(message);
} else if(message instanceof Map&? , ?&) {
System.out.println(message);
System.out.println(ToStringBuilder.reflectionToString(message));
好了,有上面的两个类,加上Spring基本上就可以工作了.当然还得启动Redis.&
Spring Schema:
&?xml version=&1.0& encoding=&UTF-8&?&
&beans xmlns=&http://www.springframework.org/schema/beans&
xmlns:xsi=&http://www.w3.org/2001/XMLSchema-instance&
xmlns:context=&http://www.springframework.org/schema/context&
xmlns:redis=&http://www.springframework.org/schema/redis&
xmlns:p=&http://www.springframework.org/schema/p&
xsi:schemaLocation=&http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/redis
http://www.springframework.org/schema/redis/spring-redis-1.0.xsd&&
&bean id=&redisConnectionFactory& class=&org.springframework.data.redis.connection.jedis.JedisConnectionFactory&
p:hostName=&localhost& p:port=&6379& p:usePool=&true&&
&!-- redis template definition --&
&bean id=&redisTemplate& class=&org.springframework.data.redis.core.RedisTemplate&
p:connectionFactory-ref=&redisConnectionFactory&/&
&bean id=&redisDAO& class=&net.dredis.dao.impl.RedisDAOImpl&&
&property name=&redisTemplate& ref=&redisTemplate& /&
&bean id=&listener& class=&net.dredis.listener.impl.MessageDelegateListenerImpl&/&
&!-- the default ConnectionFactory --&
&bean id=&jdkSerializer& class=&org.springframework.data.redis.serializer.JdkSerializationRedisSerializer& /&
&redis:listener-container&
&!-- the method attribute can be skipped as the default method name is &handleMessage& --&
&redis:listener ref=&listener& serializer=&jdkSerializer& method=&handleMessage& topic=&java& /&
&/redis:listener-container&
如上面的配置, jdkSerializer是jdk默认的序列化的实现,当然还有很多其他序列化Java对象的方法,这里使用jdk默认实现.&
Method属性是配置订阅系统接收消息的方法,默认也是&handleMessage&&
topic就是订阅的channel频道,是有发布到java这个channel的消息才会被接收.&
public static void main(String[] args) {
new ClassPathXmlApplicationContext(&pubsubAppContext1.xml&);;
while (true) { //这里是一个死循环,目的就是让进程不退出,用于接收发布的消息
System.out.println(&current time: & + new Date());
Thread.sleep(3000);
} catch (InterruptedException e) {
e.printStackTrace();
OK,启动了订阅系统后,我们就可以发布消息,测试类如:&
public void testPublishMessage() throws Exception {
String msg = &Hello, Redis!&;
redisDAO.sendMessage(&java&, msg); //发布字符串消息
RedisTestBean bean = new RedisTestBean(&123456&);
bean.setName(&ZhenQin&);
bean.setOld((byte)23);
bean.setSeliry((short)4000);
bean.setManbers(new String[]{&234567&, &3456789&});
redisDAO.sendMessage(&java&, bean); //发布一个普通的javabean消息
Integer[] values = new Integer[]{,12323};
redisDAO.sendMessage(&java&, values);
//发布一个数组消息
如测试,我连续发布了3条消息,都是不同的数据类型.订阅端输出如:
current time: Fri Oct 26 20:38:31 CST 2012
[2, 12323]
java.lang.String@379faa8c[value={H,e,l,l,o,,, ,R,e,d,i,s,!},hash=]
net.dredis.entity.RedisTestBean@7dee05dc[uid=123456,name=ZhenQin,seliry=4000,old=23,manbers={6789}]
current time: Fri Oct 26 20:38:34 CST 2012
current time: Fri Oct 26 20:38:37 CST 2012
OK他接收到了这3条消息,而且和预期一样.&
对于Spring还有传统风格的配置方式,实现的功能和前面一模一样.&
&?xml version=&1.0& encoding=&UTF-8&?&
&beans xmlns=&http://www.springframework.org/schema/beans&
xmlns:xsi=&http://www.w3.org/2001/XMLSchema-instance&
xmlns:context=&http://www.springframework.org/schema/context&
xmlns:p=&http://www.springframework.org/schema/p&
xsi:schemaLocation=&http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd&&
&bean id=&jedisConnectionFactory& class=&org.springframework.data.redis.connection.jedis.JedisConnectionFactory&
p:hostName=&localhost& p:port=&6379& p:usePool=&true&&
&!-- redis template definition --&
&bean id=&redisTemplate& class=&org.springframework.data.redis.core.RedisTemplate&
p:connectionFactory-ref=&jedisConnectionFactory&/&
&bean id=&redisDAO& class=&net.dredis.dao.impl.RedisDAOImpl&&
&property name=&redisTemplate& ref=&redisTemplate& /&
&bean id=&serialization& class=&org.springframework.data.redis.serializer.JdkSerializationRedisSerializer& /&
&bean id=&messageDelegateListener& class=&net.dredis.listener.impl.MessageDelegateListenerImpl& /&
&bean id=&messageListener& class=&org.springframework.data.redis.listener.adapter.MessageListenerAdapter&&
&property name=&delegate& ref=&messageDelegateListener& /&
&property name=&serializer& ref=&serialization& /&
&bean id=&redisContainer& class=&org.springframework.data.redis.listener.RedisMessageListenerContainer&&
&property name=&connectionFactory& ref=&jedisConnectionFactory&/&
&property name=&messageListeners&&
&!-- map of listeners and their associated topics (channels or/and patterns) --&
&entry key-ref=&messageListener&&
&bean class=&org.springframework.data.redis.listener.ChannelTopic&&
&constructor-arg value=&java& /&
&/property&
&&相关文章推荐
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:119201次
积分:1955
积分:1955
排名:第19863名
原创:28篇
转载:314篇
(1)(1)(1)(7)(62)(37)(27)(8)(9)(19)(24)(35)(7)(3)(20)(9)(12)(41)(14)(1)(2)(1)(2)}

我要回帖

更多关于 setmessagelistener 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信