I am trying to add a specific pattern for my key in redis spring data listener but its not working. Can anybody help me to advice how can I achieve the listener only for a specific command?Below is my message listener container.
@Beanpublic RedisMessageListenerContainer redisMessageListenerContainer( RedisConnectionFactory connectionFactory, MyMessageListener myMessageListener) { RedisMessageListenerContainer listenerContainer = new RedisMessageListenerContainer(); listenerContainer.setConnectionFactory(connectionFactory); listenerContainer.addMessageListener(myMessageListener, new PatternTopic("__keyspace@*__:SampleProj:Message:*")); return listenerContainer; }
The above pattern works fine and I can get all the event messages in my messageListener
class. like all events: del, hset etc..Now I need to get the only the hset events for mykey and I follwed the commands as mentioned in https://redis.io/docs/manual/keyspace-notifications/ and couldnt succeed the expectations. Below are the patterns I tried.
new PatternTopic("__keyevent*:hset SampleProj:Message:*")new PatternTopic("__keyevent@*__:hset:SampleProj:Message:*"));new PatternTopic("__keyevent@*__:hset SampleProj:Message:*"));
Even with combined list:
Arrays.asList(new PatternTopic("__keyevent@*__:hset SampleProj:Message:"),new PatternTopic("__keyspace@*__:SampleProj:Message:* hset")));