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

Delete message on receive #22

Closed
fiznool opened this issue Feb 23, 2016 · 7 comments
Closed

Delete message on receive #22

fiznool opened this issue Feb 23, 2016 · 7 comments

Comments

@fiznool
Copy link

fiznool commented Feb 23, 2016

Thanks for a great queue library!

For my application, I'm looking to delete a message as it is received. I can currently do this by issuing a deleteMessage straight after a receiveMessage, but I'd like to go one step further and add support for this in the receiveMessage lua script, so that the delete happens atomically.

I was wondering whether you'd accept a PR which implements this functionality.

Here's what I'm thinking:

  • Allow a vt of -1 - this indicates that a message should be deleted when it is pulled off the queue.
  • Check if vt is -1 in the lua script - if so, run the zrem and hdel operations to delete the message.

If reusing the vt variable isn't desirable, perhaps a new option could be used instead, for example remove_on_receive.

@smrchy
Copy link
Owner

smrchy commented Feb 24, 2016

This is a good enhancement. I will implement it hopefully this week.

@smrchy
Copy link
Owner

smrchy commented Feb 25, 2016

I added a 'popMessage' method.

Docs: https://github.com/smrchy/rsmq#popmessage

Hope this does what you need.

@fiznool
Copy link
Author

fiznool commented Feb 25, 2016

Marvellous. I'll test this out right away. Thanks for the speedy implementation!

@smrchy
Copy link
Owner

smrchy commented Feb 29, 2016

Please close this issue if it works for you.

@fiznool
Copy link
Author

fiznool commented Mar 2, 2016

Works great, thanks!

@fiznool fiznool closed this as completed Mar 2, 2016
@markotom
Copy link

markotom commented Apr 16, 2016

Is it a good approach to set a TTL to each message?

@smrchy
Copy link
Owner

smrchy commented Apr 18, 2016

If you need a TTL (only valid till some_timestamp) then you should probably add this from within your application. Just add a ttl to your message payload. If the ttl is reached just delete the message and don't work on it.

A TTL feature for RSMQ is not planned as this would make regular housekeeping necessary which is something i'd like to avoid.

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

No branches or pull requests

4 participants