Redis has very good implementation for PUBSUB where a message published on a channel will be received by multiple receivers registered for the topic.
What is the ideal way to implement point-to-point (i.e. queue) semantics where e.g. multiple receivers are registered with a single queue and as soon as a message is pushed to the queue it will be processed by only 1 receiver (listener)? Any Java reference example would help.
Here the idea is to a read huge file containing transaction records and hence each transaction should be processed only once.
I could see Redis Streams is advised, but I do not see a sound Java reference implementation
2
Answers
Note that there is no direct implementation like for PUBSUB topic . Another reason to use Queue here is that there is no Durable Subscription in Publish Subscribve as well i.e. when subscriber is not up when the message sent your message will be lost. but below Queue implementation would save bit here.
Final Answer
LPUSH TEST_QUEUE Test message LLEN TEST_QUEUE BRPOP TEST_QUEUE 0
Java Implementation
Just use
LPUSH msgqueue
to put items in the the list and have all clients do: