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

Is Message.ID unique id ? #250

Closed
lougxing opened this issue Mar 8, 2019 · 4 comments
Closed

Is Message.ID unique id ? #250

lougxing opened this issue Mar 8, 2019 · 4 comments
Labels

Comments

@lougxing
Copy link

lougxing commented Mar 8, 2019

type Message struct {
	ID        MessageID
        Body []byte
....
}

Is Message.ID global unique id ?  Is it used as a key in map/redis ?

@mreiferson
Copy link
Member

mreiferson commented Mar 8, 2019

If your cluster is configured to ensure that --node-id for each nsqd is unique, then yes, MessageID values should be globally unique.

However, I wouldn't rely on this and would recommend you instead include your own identifiers in your message bodies that you ensure are globally unique.

@ploxiln
Copy link
Member

ploxiln commented Mar 8, 2019

Some further notes:

The nsq MessageID is currently only unique within a topic (and only if nsqd node IDs are different), other topics can easily have a message with the same MessageID.

We only really want to promise that a MessageID will be unique for a particular connection between an nsq consumer and an nsqd. The only use of the MessageID should be for finishing or re-queuing a message. We want to be able to change the way these IDs are generated in the future, to be more efficient, and maybe robust against time going backwards, though I'm not sure if we will ...

@mreiferson
Copy link
Member

The nsq MessageID is currently only unique within a topic

Ahh right, forgot about this!

@lougxing
Copy link
Author

thanks.

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

No branches or pull requests

3 participants