Hi bibryam

I thought to have done exactly what you suggest. From resources gathered
from the net I've found I should use the StringRedisSerializer (instead of
the default JdkSerializer), but still the strings saved in redis are
"dirty". Should I use another serializer to have plain strings in redis?

Ciao.
--Tommaso


bibryam wrote
> Hi Tommaso,
> 
> what you have seems correct.
> Basically you have to use the same serializer for publishing and reading
> data.
> If you are using camel producer/consumer for publishing and reading data,
> you don't have to specify anything, it will just work.
> 
> But if you are using a different client for reading data from redis, you
> have to find the appropriate serializer from Spring redis project and
> speficy that in the URI
> 
> HTH
> 
> 
> On 10 September 2013 09:43, Tommaso <

> mynos_main@

> > wrote:
> 
>> This is a question on stackoverflow as well:
>>
>> http://stackoverflow.com/questions/18698802/redis-wrong-serialization-using-the-camel-redis
>>
>> I'm playing with camel and redis. I have a very short route:
>>
>> from("timer://foo?period=5s")
>>
>> .to("
>> http://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/all_day.geojson";)
>>     .split().method(SplitFeatures.class,"splitMessage")
>>
>> .to("spring-redis://localhost:6379?command=SET&serializer=#serializer");
>>
>> Where splitMessage is the following:
>>
>>   public static List splitMessage(@Body String body) throws IOException {
>>     List answer = new ArrayList();
>>     JsonParser parser=new JsonParser();
>>     JsonObject jo=   (JsonObject)parser.parse(body);
>>
>>     // I care only for the features array
>>     JsonArray features=jo.get("features").getAsJsonArray();
>>
>>     for (JsonElement feature: features) {
>>          Message msg=new DefaultMessage();
>>          JsonObject jof=feature.getAsJsonObject();
>>
>>          // get the key
>>          String id=jof.get("id").getAsString().toString();
>>
>>          System.out.print(id);
>>          msg.setHeader(RedisConstants.KEY, id);
>>          msg.setHeader(RedisConstants.VALUE, jof.toString());
>>          answer.add(msg);
>>     }
>>     return answer;
>>   }
>>
>> Everything runs smoothly, but when I check the redis db I see that the
>> key
>> is: "\xac\xed\x00\x05t\x00\nci11361338"
>>
>> and the same prefix "\xac\xed\x00\x05t\x00" is in the value.
>>
>> Obviously the those printed by the System.out look fine.
>>
>> As you see I tried to add a serializer, a StringRedisSerializer that I
>> defined in the Main like this:
>>
>>   Main main = new Main();
>>   main.bind("serializer", new StringRedisSerializer());
>>
>> But the result is the same (also using GenericToStringSerializer).
>>
>> Is there something I'm missing?
>>
>>
>>
>> --
>> View this message in context:
>> http://camel.465427.n5.nabble.com/camel-redis-strings-serialization-tp5738994.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>
> 
> 
> 
> -- 
> Bilgin Ibryam
> 
> Apache Camel & Apache OFBiz committer
> Blog: ofbizian.com
> Twitter: @bibryam <https://twitter.com/bibryam>
> 
> Author of Instant Apache Camel Message Routing
> packtpub.com/apache-camel-message-routing/book<http://www.packtpub.com/apache-camel-message-routing/book>





--
View this message in context: 
http://camel.465427.n5.nabble.com/camel-redis-strings-serialization-tp5738994p5739023.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to