Im trying to access same redis instance from two microservices using spring-data-redis. I am having deserialization issues.
Imagine you have redis instance and two microservices are trying to access it. For simplicity sake, imagine a UserRepository class and a User class that is stored in redis.
Here is what Im seeing
1) If I write to redis from microservice A and call userRepository.findAll() from microservice A, everything works and the data returns.
2) If I write to redis from microservice B and call userRepository.findAll() from microservice B, everything works and the data returns.
3) If I write to redis from microservice A and call userRepository.findAll() from microservice B, it returns NULL.
The RedisHash class is shared by both microservices, each having it's own class. What I'm suspecting is the problem is the "_class" field that gets appended to the redis hash and when it tries to deserialize it, it gives it problems.
The @RedisHash are identical in fields but DIFFERENT in packages for both microservices.
Is there a way to resolve this by either removing _class or implementing custom serializers?
@Getter
@AllArgsConstructor
@RedisHash("user")
public class User implements Serializable {
@Id
String userId;
String jwtToken;
}
@Repository
public interface UserRepository extends CrudRepository<User, String> {
List<User> findAll();
}
To return data and not null