Real-time Distributed Messaging On FreeBSD With NSQ

freebsd nsq distributed

How To Install NSQ?

Install NSQ by port mechanism:
# cd /usr/ports/net/nsq
# make install clean
Install NSQ by package manager:
# pkg install nsq

Create Local NSQ Cluster

The following commands run a small NSQ cluster on your local machine and send messages and archiving messages to disk.
issue nsqlookupd:
# nsqlookupd
in another shell, start nsqd:
# nsqd –lookupd-tcp-address=
in another shell, start nsqadmin:
# nsqadmin –lookupd-http-address=
publish an initial message (creates the topic in the cluster, too):
# curl -d ‘BSDMAG MSG 1’ ‘’

when you send a message to a topic for the first time, a topic will be created.
-d (HTTP) Sends the specified data in a POST request to the HTTP server, in the same way, that a browser does when a user has filled in an HTML form and presses the submit button.
finally, in another shell, start nsq_to_file:
# nsq_to_file –topic= bsdmag –output-dir=/tmp –lookupd-http-address=
nsq_to_file acts as a client and copy messages from memory to disk.
publish more messages to nsqd:
# curl -d ‘BSDMAG MSG 2’ ‘’
# curl -d ‘BSDMAG MSG 3’ ‘’
to verify things worked as expected, in a web browser open to view the nsqadmin UI and see statistics. Also, check the contents of the log files (test.*.log) written to /tmp.
The important lesson here is that nsq_to_file (the client) is not explicitly told where the test topic is produced, it retrieves this information from nsqlookupd and, despite the timing of the connection, no messages are lost.

You can get full edition at:

enter image description here