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

nsq on client side (consumer) #306

Closed
fuzsh opened this issue Aug 13, 2020 · 3 comments
Closed

nsq on client side (consumer) #306

fuzsh opened this issue Aug 13, 2020 · 3 comments
Labels

Comments

@fuzsh
Copy link

fuzsh commented Aug 13, 2020

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:

// Gracefully stop the consumer.
consumer.Stop()

it close and i want to run always ....

@ploxiln
Copy link
Member

ploxiln commented Aug 14, 2020

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 ...

@fuzsh
Copy link
Author

fuzsh commented Aug 14, 2020

@ploxiln special thanks,
i want my consumers to update db (arango db cluster) ...

@ploxiln
Copy link
Member

ploxiln commented Aug 14, 2020

OK, that's the simple standard case. Just do the db update in the handler function.

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

2 participants