nsqio / go-nsq

The official Go package for NSQ
MIT License
2.59k stars 444 forks source link

About creating a new producer #280

Closed stair-go closed 3 years ago

stair-go commented 4 years ago

Why not provide a

NewProducerByLookup (lookupdaddrs [] string, config config) ( producer, error)

and when the connected nsqd is hung up and then connected to a new nsqd, I think this scenario should be more common~hh

stair-go commented 4 years ago

I think the design principle of NSQ is related. For example, if one MSG is sent to another nsqd without the topic, if there are multiple consumers subscribing to it, the message may be lost, but we can provide users with more choices?

cocktail18 commented 3 years ago

I am puzzled with it too

ploxiln commented 3 years ago

Producers should not use nsqlookupd. Consumers use nsqlookupd. Producers might always publish to localhost, or they might publish to a configured pool of nsqd (which might be behind a load balancer, or contacted directly with logic like https://github.com/nsqio/go-nsq/pull/311). Then, consumers user nsqlookupd to find where producers put messages.

ploxiln commented 3 years ago

You can find an example of "publish to localhost, consumers use nsqlookupd" near the bottom of this page: https://nsq.io/deployment/topology_patterns.html#distributed-systems