Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom keys or pattern keys #78

Closed
nomi-ramzan opened this issue Jun 28, 2018 · 7 comments
Closed

Custom keys or pattern keys #78

nomi-ramzan opened this issue Jun 28, 2018 · 7 comments

Comments

@nomi-ramzan
Copy link

nomi-ramzan commented Jun 28, 2018

Is there any way to create or define custom task key or define pattern/prefix for each task ?
For examples app1:user1:jobtypeA:{serial} where serial can be a hash like before or any integer number
Thank you

@nomi-ramzan
Copy link
Author

my solution is failing on deleteMessage function because of RegExp /^([a-zA-Z0-9:]){32}$/ used at this validation.

@smrchy
Copy link
Owner

smrchy commented Jul 2, 2018

Your solutions messes with the ordering of the messages which should not happen.

The message ids generated should really not matter to your application. You will receive the ID on a sendMessage and use it to delete / finish the message. Why would you need custom ids here?

@nomi-ramzan
Copy link
Author

if i want to query on tasks like in my example above

app1:user1:jobtypeA:{serial}

I can query how many tasks are pending for app1 or app1:user1 in this case how can i query these tasks ?

@smrchy
Copy link
Owner

smrchy commented Jul 2, 2018

You can't and you should not!

If you need that functionality you should

  • use different queues - e.g one for each app.
  • use some other tool to keep track of your messages (a database)

Let's say you need to get all messages for user1 because the user gets deleted and you need to delete all his messages. Then your application should simply discard every message for user1. That's way more elegant than finding all messages and delete them.

RSMQ is a message queue. And should be used as a message queue. It's not a database that listens to queries (all messages where x=y) or something like that.

@nomi-ramzan
Copy link
Author

nomi-ramzan commented Jul 2, 2018

Thank you for explanation. But don't you think this can help users to track or at least get the idea like user1:app1 has 10 task pending tasks and user1:app2 has 20 tasks pending. even little bit more complex can be user1:app1:tasktype1 and user1:app1:tasktype2 ? if I will use your technique there will be many active queues and on user deletion i need to scan all queues related to one user and than have to delete them. what do you think about it ?

@smrchy
Copy link
Owner

smrchy commented Jul 5, 2018

I sure see that this might help in your described case. But this is not what this project is about. The S in RSMQ stands for simple. If i would create all of your mentioned query capabilities i would have to make a lot of changes for this specific case and the data structures in Redis would become a lot more complicated. Something i'm sure must be avoided.
I am sure in your specific case there is a way to solve your problem in a more elegant way than to add complexity to this module. I doubt you should query a message queue for this.

@nomi-ramzan
Copy link
Author

Thank you for your time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants