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.

Reply via email to