Oct. 31, 2017, 10:41 a.m.
Posted by soar

Better nsq_tail

I've used NSQ for one of our projects - It is very cool system for handling messaging queues. But I had a very annoying problem - We have more than 5 queues and for each I should start new container of nsq_tail:

version: '3.2'
services:
  nsqtail:
    image: nsqio/nsq
    command: /nsq_tail --topic=mytopic1 --lookupd-http-address=nsqlookupd:4161
  nsqtail2:
    image: nsqio/nsq
    command: /nsq_tail --topic=mytopic2 --lookupd-http-address=nsqlookupd:4161
  nsqtail3:
    image: nsqio/nsq
    command: /nsq_tail --topic=mytopic3 --lookupd-http-address=nsqlookupd:4161
...

I know that Docker is "lightweight" system... But not lightweight-enough for running too many containers for simple tasks. So my idea was to make nsq_tail listen for multiple topics at once and write all messages from them. Now I can do simply:

version: '3.2'
services:
  nsqtail:
    image: soarname/nsq
    command: /nsq_tail --topic=topic1 --topic=topic2 --topic=topic3 --lookupd-http-address=nsqlookupd:4161

And then in logs I see:

nsqtail_1     | topic1 | test-message-1
nsqtail_1     | topic2 | test-message-2
nsqtail_1     | topic3 | test-message-3

So, if you want use this improvement - just pull my automatically built image from Docker Hub: soarname/nsq or vote for my Pull Request #957.

Comments