taskq
taskq copied to clipboard
Redis message ID
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.
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
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.
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.
Ah. Just seeing this. I am guessing this is related to #143 ?