6
0
mirror of https://git.mills.io/prologic/msgbus.git synced 2024-06-29 18:21:44 +00:00
prologic-msgbus/examples/hello.go

25 lines
370 B
Go
Raw Normal View History

package main
import (
"log"
"github.com/prologic/msgbus"
)
func main() {
m := msgbus.New(nil)
2017-08-14 07:34:12 +00:00
t := m.NewTopic("foo")
m.Put(m.NewMessage(t, []byte("Hello World!")))
2017-08-14 07:34:12 +00:00
msg, ok := m.Get(t)
if !ok {
log.Printf("No more messages in queue: foo")
2017-08-14 07:34:12 +00:00
return
}
2017-08-14 07:34:12 +00:00
log.Printf(
2018-05-01 06:07:27 +00:00
"Received message: id=%d topic=%s payload=%s",
msg.ID, msg.Topic.Name, msg.Payload,
2017-08-14 07:34:12 +00:00
)
}