This Example shows an asynchronous subscriber.
()
| 81 | |
| 82 | // This Example shows an asynchronous subscriber. |
| 83 | func ExampleConn_Subscribe() { |
| 84 | nc, _ := nats.Connect(nats.DefaultURL) |
| 85 | defer nc.Close() |
| 86 | |
| 87 | nc.Subscribe("foo", func(m *nats.Msg) { |
| 88 | fmt.Printf("Received a message: %s\n", string(m.Data)) |
| 89 | }) |
| 90 | } |
| 91 | |
| 92 | func ExampleConn_ForceReconnect() { |
| 93 | nc, _ := nats.Connect(nats.DefaultURL) |