mpneuried / rsmq-worker

Helper to simply implement a worker around RSMQ ( Redis Simple Message Queue )
MIT License
117 stars 24 forks source link

Conditional send / put if not exists #28

Open ckorakidis opened 7 years ago

ckorakidis commented 7 years ago

Hi,

Is there any way to put messages only if they don't exist (or replace them with the new ones if they already exist), where exists === (msg.message of the given exists on the queue requested to be sent)?

mpneuried commented 7 years ago

hi,

in general this is a question for the core rsmq, but your requirement is not possible with the current internal data strucktur.

The only option whould be to generate something like a md5 hash for each message by yourself and safe it as key/value( { "{ hash }": "{ message-id }" } ) within redis. With this store you could check if a message already exists.

ckorakidis commented 7 years ago

Hi, thanks for the response,

I thought about similar approaches but this would make things complex trying to make inserts both conditional and atomic. This is why I was thinking if that would be possible to be done in this level. Would you suggest me creating a ticket (possibly improvement) on rsmq core?