You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We have code implemented in MS.NET that uses .NET version of MessagePack library to serialize .NET class object into
bytes and then stores these bytes into Redis Cache.
Code in MS.NET to generate bytes which gets stored into Redis is -
public byte[] SerializeCompact(T thisObj)
{
var serializer = MessagePackSerializer.Get();
using(var byteStream = new MemoryStream())
{
serializer.pack(byteStream, thisObj);
return byteStream.ToArray();
}
}
I need to read these bytes and then deserialize it into JAVA Object (POJO).
I have added spring-boot-starter-data-redis, msgpack-core (0.9.3) & jackson-dataformat-msgpack(0.9.3) dependencies in the pom file.
I have defined connectionFactory and redisTemplate beans.
RedisTemplate<String, Object> redisTemplate = new RedisTemplate<String,Object>();
And I have disabled default serializers.
Given that the data get stored as byte[] from the above given .NET code, I am fetching the value from redis as below -
First of all the response bytes that I get in above mentioned JAVA code are different than the bytes that I get when I do similar operation from my MS.NET code. Not sure if this is somehow impacting the conversion/deseralization
Then I am doing standard ObjectMapper operation on the returned responseBytes... something like below -
ObjectMapper objectMapper = new MessagePackMapper();
Account account = objectMapper.readValue(responseBytes, Account.class);
Though this line of code does not throw any error, it does not set the object value either.
Point to note, when the object is stored into Redis, it only stores values of the properties and not like json or in typical key-value format.
How do you suggest I can move ahead in order to read the value and convert it into POJO?
Thanks
The text was updated successfully, but these errors were encountered:
The issue you reported was related to Redis cache and MS.NET version MessagePack, so I can't reproduce and look into it. Could you share a minimum code to reproduce the issue? Thanks.
We have code implemented in MS.NET that uses .NET version of MessagePack library to serialize .NET class object into
bytes and then stores these bytes into Redis Cache.
Code in MS.NET to generate bytes which gets stored into Redis is -
public byte[] SerializeCompact(T thisObj)
{
var serializer = MessagePackSerializer.Get();
using(var byteStream = new MemoryStream())
{
serializer.pack(byteStream, thisObj);
return byteStream.ToArray();
}
}
I need to read these bytes and then deserialize it into JAVA Object (POJO).
I have added spring-boot-starter-data-redis, msgpack-core (0.9.3) & jackson-dataformat-msgpack(0.9.3) dependencies in the pom file.
I have defined connectionFactory and redisTemplate beans.
RedisTemplate<String, Object> redisTemplate = new RedisTemplate<String,Object>();
And I have disabled default serializers.
Given that the data get stored as byte[] from the above given .NET code, I am fetching the value from redis as below -
byte[] responseBytes = (byte[])redisTemplate.opsForValue().get("my_key")
First of all the response bytes that I get in above mentioned JAVA code are different than the bytes that I get when I do similar operation from my MS.NET code. Not sure if this is somehow impacting the conversion/deseralization
Then I am doing standard ObjectMapper operation on the returned responseBytes... something like below -
ObjectMapper objectMapper = new MessagePackMapper();
Account account = objectMapper.readValue(responseBytes, Account.class);
Though this line of code does not throw any error, it does not set the object value either.
Point to note, when the object is stored into Redis, it only stores values of the properties and not like json or in typical key-value format.
How do you suggest I can move ahead in order to read the value and convert it into POJO?
Thanks
The text was updated successfully, but these errors were encountered: