Closed fuzsh closed 4 years ago
It depends on what you want the consumer to do. Here's a minimal simple consumer example to look at:
https://github.com/nsqio/nsq/blob/master/apps/nsq_tail/nsq_tail.go
That registers a handler function which is called for each message, and then waits for a signal to exit.
If you want these messages to be served to http clients, that is awkward, but possible ...
@ploxiln special thanks, i want my consumers to update db (arango db cluster) ...
OK, that's the simple standard case. Just do the db update in the handler function.
I created a route for http request that handles all incoming requests then i push them on queue by
producer.Publish()
method, then return status code 200 to user. on the other side (consumer) what is the best approach to handle ? waitGroup with large number like wg.Add(100000) or infinite loop ? or .. ?can you help me with example ...?
refer to ex:
it close and i want to run always ....