taskq icon indicating copy to clipboard operation
taskq copied to clipboard

Redis message ID

Open sajjadrad opened this issue 5 years ago • 4 comments

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.

sajjadrad avatar Feb 08 '20 13:02 sajjadrad

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

vmihailenco avatar Feb 08 '20 15:02 vmihailenco

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.

sajjadrad avatar Feb 09 '20 12:02 sajjadrad

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.

mwieser avatar Jan 13 '21 13:01 mwieser

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

subomi avatar Oct 12 '21 16:10 subomi