骆驼redis组件redis 订阅发布原理频道不工作问题,怎么解决

骆驼redis组件订阅频道不工作
骆驼redis组件订阅频道不工作
I've a simple route that listens to a Redis channel. For some reason it's not working.
Here is my route. I verified that data is being published into the Redis channel and I can read it back using a normal Jedis subscriber. I'm running Camel inside Jetty and it is deployed as a war.
public class RedisSubscriberRoute extends RouteBuilder{
public void configure() throws Exception {
from("spring-redis://localhost:6379?command=SUBSCRIBE&channels=mychannel")
.process(new Processor() {
public void process(Exchange exchange) throws Exception {
String res = exchange.getIn().getBody().toString();
System.out.println("************ " + res);
exchange.getOut().setBody(res);
.to("log:foo");
UPDATE (10-May- AM EST): Adding version information
&properties&
&spring.version&3.2.2.RELEASE&/spring.version&
&camel.version&2.11.0&/camel.version&
&jetty.version&7.6.8.v&/jetty.version&
&/properties&
Redis server version is 2.6.11
The sample git project is here.
UPDATE 10-May- PM EST):
As suggested in the comments below I changed the version of the spring-data to 1.0.0.RELEASE. Looks like the message is getting to the subscriber but I'm still getting an exception.
java.lang.RuntimeException: org.springframework.data.redis.serializer.SerializationException: C nested exception is org.springframework.core.serializer.support.SerializationFailedException: Failed to deserialize payload. Is the byte array a result of corresponding serialization for DefaultDeserializer?; nested exception is java.io.StreamCorruptedException: invalid stream header:
at org.ponent.redis.RedisConsumer.onMessage(RedisConsumer.java:73)[camel-spring-redis-2.11.0.jar:2.11.0]
at org.springframework.data.redis.listener.RedisMessageListenerContainer.executeListener(RedisMessageListenerContainer.java:242)[spring-data-redis-1.0.0.RELEASE.jar:]
at org.springframework.data.redis.listener.RedisMessageListenerContainer.processMessage(RedisMessageListenerContainer.java:231)[spring-data-redis-1.0.0.RELEASE.jar:]
at org.springframework.data.redis.listener.RedisMessageListenerContainer$DispatchMessageListener$1.run(RedisMessageListenerContainer.java:726)[spring-data-redis-1.0.0.RELEASE.jar:]
at java.lang.Thread.run(Thread.java:680)[:1.6.0_45]
日40分11秒
There is something broken in the consumer with v 1.0.3.RELEASE, use 1.0.0.RELEASE instead.
The exception you are getting is something different: Camel producer uses Spring RedisTemplate, which in turn uses JdkSerializationRedisSerializer. To make it symetric, the consumer by default also uses JdkSerializationRedisSerializer to deserialize data. So if you are using Camel producer to publish data, it should work fine w/o hustle. But if you are publishing data to redis using other redis clients (or as in your case some other libraries) you have to use another serializer for the consumer. Long explanation, but to make it work is actually two lines:
from("spring-redis://localhost:6379?command=SUBSCRIBE&channels=mychannel&serializer=#serializer")
日40分11秒
Here is a summary of what I had to change to make this work.
As pointed out by @Bilgin Ibryam - you have to use the version 1.0.0.RELEASE of spring-data-redis (as on 11-May-2013)
&dependency&
&groupId&org.springframework.data&/groupId&
&artifactId&spring-data-redis&/artifactId&
&!-- IMPORTANT - as of 10-May-2013 the Redis Camel
component only works with version 1.0.0.RELASE --&
&version&1.0.0.RELEASE&/version&
&/dependency&
Other versions that I used in my
3.2.2.RELEASE
If you are publishing and consuming using the Camel Redis component you don't have to declare a different serializer. In my case I was publishing from python as well as plain old Java using Jedis. I had to
to include the serializer and define the serializer in my .
public void configure() throws Exception {
from("spring-redis://localhost:6379?command=SUBSCRIBE&channels=mychannel&serializer=#redisserializer")
.process(new Processor() {
public void process(Exchange exchange) throws Exception {
String res = exchange.getIn().getBody().toString();
System.out.println("************ " + res);
exchange.getOut().setBody(res);
.to("log:foo");
日40分11秒
& 2016 91R.NET 版权所有随笔 - 171
评论 - 1038当前访客身份:游客 [
当前位置:
在redis3.0的集群模式下用jedis管道的操作,经常报 Exception in thread "main" redis.clients.jedis...
这次的项目是类似论坛的模式,提出个问题,然后问题下有评论,表里是通过问题的id来关联评论表,要满足显示问题和问题下的评论的需求,不知道怎么把这些数据用什么...
java 操作redis,怎么让元素按照自己想要的顺序出现?
想统计Redis中,各个key被调用的次数,该怎么做 这样我可以清晰得看见,哪些key是常用的可能会有高并发,哪些key上线之后就没用过,可以删掉 更希望...
我现在在做redis的集群方案,初步的设想是三个主从的结构,一台master对应两台slave,使用redis的sentinel来监控主从关系。现在我可以...
早在去年已经出现MongoDB和Redis的Cacti模板,使用它,你可以对你的MongoDB和Redis服务进行流量监控。cacti的模板一直在更新,若...
公司需要用redis作数据缓存,我们就在内网做了一个测试。测试的过程为,开启redis服务器,然后开启一个写入数据的程序,不停地往redis内存中...
有没有人在实际项目上将redis运行在windows下面? 因为redis官方不支持win,github上面的ServiceStack是微软搞出来的。 不...
Redis是一个在互联网圈耳熟能详的内存数据库了,使用简单,并且查询效率非常的高。我们也在很多地方使用到Redis来应对低延时的需求,比如对移动互联网广告...
请教2个问题 1. redis 3.0 如果使用jedis的JedisCluster做服务端集群 ,是不是就不支持连接池了,没有一个类似J...
丰富的数据结构使得redis的设计非常的有趣。不像关系型数据库那样,DEV和DBA需要深度沟通,review每行sql语句,也不像memcached那样,...
redis节点有设置密码,然后在创建集群的时候没有设置密码的命令 ./redis-trib.rb create --replicas 1 127.0.0....
配置redis的sentinel,有身份验证的不成功? 已经按照文档说的在主从服务器都配置了requirepass和masterauth,不成功,一开启s...
使用ShardedJedisPool做redis集群的时候,出现了奇怪的问题,如果莫名的戳中了大家的笑点,请勿喷,我是redis新手,请大家多多见谅。 问...
现在懂hadoop mongodb
redis的专家比 能写一个子查询的都多。 大把大把的构架师 在ppt上堆叠一下hadoop, reids........
错误如下,不知道是什么原因呢。 Caused by: java.lang.NoClassDefFoundError: org/nustaq/seriali...
业务:请求过来先查询redis,redis没有 在查询mysql,然后将结果写入redis。 问题:如果每秒上万请求,让系统处于最优状态,该如何设计呢? ...
2015 年, UPYUN 举办了以 UPYUN Open Talk 技术沙龙 和 “ UPYUN 架构与运维大会”为代表的 19 场技术会议。并且开展了...
刚才 OSChina 挂了一小会,应用正常,是 Redis 报错。使用 redis-cli 可以连到 Redis 服务器,但是执行命令出错,报错信息:NO...
项目内存数据库使用的是redis,持久数据库使用的是mysql,如何确保在redis异常时,读取mysql中的数据,目前只想到在使用redis命令时加上t...
配置如下: &beans xmlns="http://www.springframework.org/schema/beans"
xmlns:x...
大家好,我在用redis做数据存储,我们的一个场景需要这样的功能,当有一条新的数据插入到redis里后,我有没有什么方法可以得知。
求高手解救。。安装redis集成用twemproxy这个组件, 执行autoreconf -fvi报如下错误 configure.ac:36: error...
项目里用zk做配置中心, 我想问问有经验的人,每次读取配置都是从zk里读取,这样从zk里更改了配置,可以实时的读取到最新配置 另一个是从zk里读取的配置,...
redis作为NoSQL数据库的一种应用,响应速度和命中率上还是比较高效的。项目中需要用集中式可横向扩展的缓存框架,做了一点调研,即便redis、memc...
问题描述: 咨询一个技术问题 redis处理 请求时候
业务处理 是利用回调函数
typedef void aeFileProc(struct aeE...
@红薯 你好,想跟你请教个问题:红薯哥,redis3.0
NOAUTH Authentication required.这个问题跟 redis 的版本有...
1.添加缓存的时候用ShardedJedisPool.为什么不用JedisPool。(网上例子) 2.这两个对象有什么区别。为什么很多例子都是JedisP...
@JFinal 你好,想跟你请教个问题: 我在使用jfinal2.0版本redis插件时遇到几个问题: 一.DbPro类的分页方法paginate,为了给...
请教一个问题,有两台机器redis A和B,数据使用都是先select 0后使用,在另外一台机器redis C上恢复,可以将A 的数据库还原到C的0号库...
这个项目从开始到现在已经断断续续开发大约快两年了,之前只在reddit的programming板块发布过,最近感觉完成度已经算比较高了,准备逐步公开。 需...
今天对 J2Cache 做了最基本的测试,代码已经开放出来,地址是 http://git.oschina.net/ld/J2Cache 补充为什么要做这个...
在CentOS7上安装完redis之后,执行make test命令,报了下面的错误,求高手指点下,什么原因,怎么解决!!!
redis里面的主从体系,Sentinel会检测如果主挂了,会选举一个新的从服务器为主节点,最后将旧的主节点设置为新的主服务器的从服务器,有个疑问是,如果...
tomcat突然挂了,重启的时候, 出现redis认证失败的异常, 之前一直没有动过redis的配置, 不知道为什么突然会报这个错误, 导致网站进不去. ...
我用Jedis的SharedJedisPool,配置为 MaxActive=500,MaxIdle=100,MaxWait=2000,testOnBorr...
各位好!本人在使用Redis当中遇到个疑问。 Redis服务正常,使用Redis-cli命令能够正常连接服务,并且通过client list 命令看到正常...
q.com/cn/articles/tq-why-choose-redis 说 “数据一致性问题 Memcached提供了c...
已经搞了一周了,网上的答案步骤都是千篇一律的,菜鸟我搞的也是一头雾水啊! 需求是:redis实现session共享! 操作步骤:根据网上的...
背景: 需求是:redis实现session共享! 操作步骤:根据网上的文章我去网上下载了三个jar包:commons-pool(1.X 2.X的都试过了...
找不到我想要的答案?}

我要回帖

更多关于 redis订阅和发布 的文章

更多推荐

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

点击添加站长微信