Created
April 10, 2017 21:17
-
-
Save CodingMinds/e764f8c5c0d256b49251bb2cdf589de4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"log" | |
"time" | |
"github.com/bitly/go-nsq" | |
) | |
const ( | |
addr = "127.0.0.1:4150" | |
topic = "ex_topic" | |
message = "ex_body" | |
) | |
func main() { | |
config := nsq.NewConfig() | |
producer, err := nsq.NewProducer(addr, config) | |
if err != nil { | |
log.Fatal(err) | |
} | |
err = producer.Publish(topic, []byte(message)) | |
if err != nil { | |
log.Fatal(err) | |
} | |
producer.Stop() | |
time.Sleep(3 * time.Second) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment