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

Redis message ID #60

Open
sajjadrad opened this issue Feb 8, 2020 · 4 comments
Open

Redis message ID #60

sajjadrad opened this issue Feb 8, 2020 · 4 comments

Comments

@sajjadrad
Copy link

XAck method need message ID to delete, but message ID doesn't pass to client in XAdd method and "*" set as steam ID as default.

Also XAdd method return StringCmd struct that contains stream ID as val property. You can return stream ID (which generated by Redis client) with error in redis queue Add method to use it for deleting message from stream.

@vmihailenco
Copy link
Owner

vmihailenco commented Feb 8, 2020

I can't say I follow what you are trying to say. msg.ID is set in https://github.com/vmihailenco/taskq/blob/master/redisq/queue.go#L408

@sajjadrad
Copy link
Author

sajjadrad commented Feb 9, 2020

I want to delete a message to prevent consuming, but for call Delete method I need to pass message ID which you didn't set on XAdd method here:
https://github.com/vmihailenco/taskq/blob/master/redisq/queue.go#L168

Redis client XAdd method return generated unique ID in response.

queue.add method accept message as reference so you can set returned generated ID on message ID to updated passed message object:

stringCmd := pipe.XAdd(&redis.XAddArgs{
	Stream: q.stream,
	Values: map[string]interface{}{
		"body": body,
	},
})

msg.ID = stringCmd.Val()

return stringCmd.Err()

My problem is that I can't access message ID after adding it to queue for use it to delete message in future before consuming.

@mwieser
Copy link
Contributor

mwieser commented Jan 13, 2021

Running into the same problem. I agree with @sajjadrad that the msg.ID should be the one created by redis, otherwise the delete does not work.

@subomi
Copy link
Contributor

subomi commented Oct 12, 2021

Ah. Just seeing this. I am guessing this is related to #143 ?

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

4 participants