Difference between channel & topic

2,335 views
Skip to first unread message

Ajay Bodhe

unread,
Jun 19, 2015, 10:30:14 AM6/19/15
to nsq-...@googlegroups.com
Hello,
What is the difference between channel & topic in NSQ?
Also in activemq topic enables publishing same message to multiple consumers & queue enables publishing one message to only one consumer.
How to simulate queue & topic kind of activemq behaviour in NSQ?

Shane Hansen

unread,
Jun 19, 2015, 11:47:12 AM6/19/15
to Ajay Bodhe, nsq-...@googlegroups.com
A Topic is a specific stream of info or type of info (like visits or impressions).
A Channel is basically an individual consumer of that stream that gets it's own copy. So you could have a backup channel on the visits topic for archival along with a "api" channel for further processing. The "backup" and "api" consumers would receive independent copies of the data.

If you want multiple consumers to get the same message, use a different channel name. If you want to "load balance" among multiple consumers, use the same channel name.

Ajay Bodhe

unread,
Jun 21, 2015, 12:56:35 PM6/21/15
to nsq-...@googlegroups.com
Thanks Shane.
Can you point me to sample example to achieve single topic single channel pub-sub model?

Ajay Bodhe

unread,
Jun 22, 2015, 3:32:22 AM6/22/15
to nsq-...@googlegroups.com
Also from here:
http://nsq.io/overview/quick_start.html
 I see consumers are separated from nsqd by connecting them to nsqlookupd
Can producers be separated from nsqd as well? Otherwise how can you load balance producers across nsqd?



On Friday, 19 June 2015 20:00:14 UTC+5:30, Ajay Bodhe wrote:

Matt Reiferson

unread,
Jun 22, 2015, 11:10:07 AM6/22/15
to Ajay Bodhe, nsq-...@googlegroups.com
Ajay,

A single topic can "pub-sub" to multiple channels, it's not possible with a single channel on a single topic.

Producers can be deployed separately from nsqd, but nsqlookupd was not designed to facilitate producer-side discovery.  If you're publishing over HTTP you could setup a load balancer in front of the nsqd (between the producers).

Hope this helps.

Regards,

Matt

Ajay Bodhe

unread,
Jun 22, 2015, 11:19:07 AM6/22/15
to Matt Reiferson, nsq-...@googlegroups.com

Yes it does help thank you.

Ajay Bodhe

unread,
Jun 22, 2015, 2:51:11 PM6/22/15
to nsq-...@googlegroups.com
HI Matt/Shane,
I have written a test client referring nsq-pubsub, but I am getting following error on nsqd
can you please help with debugging? I am attaching code as well.

ajay-HP-ProBook-4445s:nsqd# nsqd
[nsqd] 2015/06/23 00:13:36.913012 nsqd v0.3.5 (built w/go1.4.2)
[nsqd] 2015/06/23 00:13:36.913174 ID: 382
[nsqd] 2015/06/23 00:13:36.913639 TOPIC(test): created
[nsqd] 2015/06/23 00:13:36.915010 TOPIC(test): new channel(test)
[nsqd] 2015/06/23 00:13:36.920912 TOPIC(testTopic): created
[nsqd] 2015/06/23 00:13:36.924562 TOPIC(testTopic): new channel(testChannel)
[nsqd] 2015/06/23 00:13:36.924608 NSQ: persisting topic/channel metadata to nsqd.382.dat
[nsqd] 2015/06/23 00:13:36.925070 DISKQUEUE(testTopic:testChannel): readOne() opened testTopic:testChannel.diskqueue.000000.dat
[nsqd] 2015/06/23 00:13:36.969223 TCP: listening on [::]:4150
[nsqd] 2015/06/23 00:13:36.969292 HTTP: listening on [::]:4151
[nsqd] 2015/06/23 00:13:49.239614 TCP: new client(127.0.0.1:59257)
[nsqd] 2015/06/23 00:13:49.239715 CLIENT(127.0.0.1:59257): desired protocol magic '  V2'
[nsqd] 2015/06/23 00:13:49.240426 [127.0.0.1:59257] IDENTIFY: {ShortID:ajay-HP-ProBook-4445s LongID:ajay-HP-ProBook-4445s ClientID:ajay-HP-ProBook-4445s Hostname:ajay-HP-ProBook-4445s HeartbeatInterval:30000 OutputBufferSize:16384 OutputBufferTimeout:250 FeatureNegotiation:true TLSv1:false Deflate:false DeflateLevel:6 Snappy:false SampleRate:0 UserAgent:nsq_pubsub/0.3.6-alpha go-nsq/1.0.5-alpha MsgTimeout:0}
[nsqd] 2015/06/23 00:14:49.241205 PROTOCOL(V2): [127.0.0.1:59257] exiting ioloop
[nsqd] 2015/06/23 00:14:49.241265 ERROR: client(127.0.0.1:59257) - failed to read command - read tcp 127.0.0.1:59257: i/o timeout
[nsqd] 2015/06/23 00:14:49.241279 PROTOCOL(V2): [127.0.0.1:59257] exiting messagePump



On Friday, 19 June 2015 20:00:14 UTC+5:30, Ajay Bodhe wrote:
nsqpub.go

Matt Reiferson

unread,
Jun 22, 2015, 4:35:36 PM6/22/15
to Ajay Bodhe, nsq-...@googlegroups.com
That error is probably benign, you might be closing the process that was consuming?

On Mon, Jun 22, 2015 at 11:51 AM, Ajay Bodhe <ajay...@gmail.com> wrote:
Reply all
Reply to author
Forward
0 new messages