NSQ is a real-time message processing system developed by the well-known short-link service provider bitly with the Go language, which has the advantages of high performance, high reliability, ignoring single point of failure, and is a very good emerging Message Queuing solution.
Nsgs are easy to configure and deploy, all references are specified through the command line, compiled binaries, and no other dependencies. It also supports multiple message formats.
Introduction to NSQ See here: http://www.oschina.net/translate/day-22-a-journey-into-nsq
Official website: http://nsq.io/overview/quick_start.html
The API is better than before.
directly on the code.
PackageMainImport ( "GITHUB.COM/BITLY/GO-NSQ" "FMT" "Time") type Handle struct{Msgchan Chan*nsq. Message Stop Bool}func (H*handle) handlemsg (M *nsq. Message) Error {if!stop{H.msgchan<-m}returnNil}func (H*Handle) Process () {h.stop=false for{select{ CaseM: = <-h.msgchan:fmt. Println (String (m.body)); Case<-Time . After (time. Second):ifh.stop{Close (H.msgchan)return}}}}func (H*Handle) Stop () {h.stop=true}func Main () {config:=nsq. Newconfig () Consumer, err:= nsq. Newconsumer ("Test", "my", config)ifErr! =nil{Panic (Err)} h:=New(Handle) consumer. AddHandler (NSQ. Handlerfunc (h.handlemsg)) H.msgchan= Make (Chan *nsq. Message, 1024) Err= consumer. CONNECTTONSQD ("127.0.0.1:4150") ifErr! =nil{Panic (Err)} h.process ()}
nsg-0.3.0 API Changes