You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by gmh <go...@gmail.com> on 2014/12/11 20:34:43 UTC
HMSET problem with Camel Spring Redis component
Hi,
I have questions regarding the camel-spring-redis component.
I have a rabbitmq producer that send out a json.
>From other people's suggestions I took the json and converts into a Map
which I can then use simple expression language.
Below is my configuration:
<route id="oplogconsumer:insert:redis">
<from
uri="spring-amqp:mongo-tail:mongo-insert:i?autodelete=false&durable=true&type=direct"
/>
<unmarshal>
<json library="Jackson"/>
</unmarshal>
<log message="Insert Operation: Message available on a RabbitMQ
Queue" />
<to uri="stream:out" />
<setHeader
headerName="CamelRedis.Key"><simple>${body[type]}</simple></setHeader>
<setHeader
headerName="CamelRedis.Value"><simple>${body[${body[id]}]}</simple></setHeader>
<to
uri="spring-redis://localhost:6379?command=HMSET&serializer=#redisserializer"/>
Below is the Exchange when I sent the data:
Exchange
---------------------------------------------------------------------------------------------------------------------------------------
Exchange[
Id ID-MRT-GMH1119-59671-1418324483776-0-2
ExchangePattern InOptionalOut
Headers
{breadcrumbId=ID-MRT-GMH1119-59671-1418324483776-0-1,
CamelRedelivered=false, CamelRedeliveryCounter=0, CamelRedis.Key=tags,
CamelRedis.Value={createdOn=2014-11-24T10:13:21.444Z, modifiedOn=null,
attributes=[{name=Crib 1, value=Inventory}, {name=Access, value=Level1}],
tagId=testme8}, contentEncoding=null, contentType=null, correlationId=null,
expiration=null, messageId=null, priority=null, replyTo=null, type=null}
BodyType java.util.HashMap
Body {id=testme8,
testme8={createdOn=2014-11-24T10:13:21.444Z, modifiedOn=null,
attributes=[{name=Crib 1, value=Inventory}, {name=Access, value=Level1}],
tagId=testme8}, op=i, objectId=5489ea111c64c229e3627bdc, type=tags}
]
Stacktrace
java.lang.NullPointerException
at
org.springframework.data.redis.core.DefaultHashOperations.putAll(DefaultHashOperations.java:115)
at
org.apache.camel.component.redis.RedisClient.hmset(RedisClient.java:45)
at
org.apache.camel.component.redis.CommandDispatcher.execute(CommandDispatcher.java:136)
at
org.apache.camel.component.redis.RedisProducer.process(RedisProducer.java:35)
So it looks the key or the map is not set correctly.
According to http://camel.apache.org/redis.html, here is how I should the
HMSET opertaion
HMSET Set multiple hash fields to multiple values CamelRedis.Key (String),
CamelRedis.Values(Map<String, Object>) void
In the code above I have unmarshalled the json into a map so why am I
getting this exception?
Any thoughts or suggestions?
Gordon
--
View this message in context: http://camel.465427.n5.nabble.com/HMSET-problem-with-Camel-Spring-Redis-component-tp5760598.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: HMSET problem with Camel Spring Redis component
Posted by gmh <go...@gmail.com>.
Okay I did something stupid..
Instead of <setHeader headerName="CamelRedis.Values"> I did <setHeader
headerName="CamelRedis.Value"> for hmset
But now I am having a really strange exception:
Stacktrace
---------------------------------------------------------------------------------------------------------------------------------------
java.lang.ClassCastException: java.util.ArrayList cannot be cast to
java.lang.String
at
org.springframework.data.redis.serializer.StringRedisSerializer.serialize(StringRedisSerializer.java:32)
at
org.springframework.data.redis.core.AbstractOperations.rawHashValue(AbstractOperations.java:145)
at
org.springframework.data.redis.core.DefaultHashOperations.putAll(DefaultHashOperations.java:124)
at
org.apache.camel.component.redis.RedisClient.hmset(RedisClient.java:45)
at
org.apache.camel.component.redis.CommandDispatcher.execute(CommandDispatcher.java:136)
at
org.apache.camel.component.redis.RedisProducer.process(RedisProducer.java:35)
at
org.apache.camel.util.AsyncProcessorConverterHelper$ProcessorToAsyncProcessorBridge.process(AsyncProcessorConverterHelper.java:61)
I tired to use other serializer but StringRedisSerializer will prevent wired
characters been inserted in the key when I did hmset so I had to do
<to
uri="spring-redis://localhost:6379?command=HMSET&serializer=#redisserializer"/>
Help!
Gordon
--
View this message in context: http://camel.465427.n5.nabble.com/HMSET-problem-with-Camel-Spring-Redis-component-tp5760598p5760604.html
Sent from the Camel - Users mailing list archive at Nabble.com.