https://github.com/oothan/go-nsq-test
https://github.com/oothan/go-nsq-test
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/oothan/go-nsq-test
- Owner: oothan
- Created: 2022-09-07T04:00:23.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2022-09-07T07:58:14.000Z (almost 4 years ago)
- Last Synced: 2024-12-31T12:37:20.246Z (over 1 year ago)
- Language: Go
- Size: 3.91 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
NSQ demo repo to try out messaging with NSQ & Go
## Run NSQ with Docker Compose
Start NSQ (the patterns below will integrate with this cluster)
docker-compose -f docker-compose-nsq.yml up
Browse to the admin UI: http://localhost:4171/
## Examples
build a docker container with our consumer app in it
docker build -t nsq-consumer -f Dockerfile-consumer .
### Worker
Start the docker compose example with 2 subscribers to the foo channel
docker-compose -f docker-compose-worker.yml up
Publish a few messages:
go run cmd/producer/producer.go -topic email -message "hello world"
go run cmd/producer/producer.go -topic email -message "hello world"
go run cmd/producer/producer.go -topic email -message "hello world"
go run cmd/producer/producer.go -topic email -message "hello world"
Each message gets processed by one or the other consumer, but is only received once.
### Pub Sub
Start the docker compose example with 2 subscribers to the foo channel, and 2 to the bar channel
docker-compose -f docker-compose-pub-sub.yml up
Publish a few messages:
go run cmd/producer/producer.go -topic orders_placed -message "order 123"
go run cmd/producer/producer.go -topic orders_placed -message "order 124"
go run cmd/producer/producer.go -topic orders_placed -message "order 125"
go run cmd/producer/producer.go -topic orders_placed -message "order 126"
Each channel gets its own copy of each message, but is only delivered to one consumer for each channel