I'm trying to communicate with a NATs server in the cloud with the "github.com/nats-io/go-nats"
package.
I`m setting it up like this:
nc, err := nats.Connect(natsServerAddress)
if err != nil {
log.Fatal(err)
} else {
natsConn = nc
}
After that I'm subscribing to the queue:
natsConn.Subscribe(natsRawSimDataQueue, func(m *nats.Msg) {
fmt.Printf("Received a message: %s\n", string(m.Data))
})
My actual problem is, that the subscription doesn't seem to have an effect. By accident I found out that the subscription handler is triggered after I published at least one message. So when the subscriber's also a publisher it seems to work. Here's the code for the publishing:
// push data to NATS Queue
natsConn.Publish(natsRawSimDataQueue, []byte("{\"msg\": \"Hello Listener\"}"))
Does anybody know where this issue come from?