package main

import (
	"log"

	"git.mills.io/prologic/msgbus"
)

func main() {
	m, err := msgbus.NewMessageBus()
	if err != nil {
		log.Fatal(err)
	}

	t := m.NewTopic("foo")
	m.Put(m.NewMessage(t, []byte("Hello World!")))

	msg, ok := m.Get(t)
	if !ok {
		log.Printf("No more messages in queue: foo")
		return
	}

	log.Printf(
		"Received message: id=%d topic=%s payload=%s",
		msg.ID, msg.Topic.Name, msg.Payload,
	)
}
