示例#1
0
文件: main.go 项目: RunCross/moonmq
func main() {
	flag.Parse()

	cfg := client.NewDefaultConfig()
	cfg.BrokerAddr = *addr

	c, err := client.NewClientWithConfig(cfg)
	if err != nil {
		panic(err)
	}
	defer c.Close()

	var conn *client.Conn
	conn, err = c.Get()
	if err != nil {
		panic(err)
	}

	defer conn.Close()

	var ch *client.Channel
	ch, err = conn.Bind(*queue, "", true)

	msg := ch.GetMsg()
	println("get msg: ", string(msg))
}
示例#2
0
文件: main.go 项目: RunCross/moonmq
func main() {
	flag.Parse()

	cfg := client.NewDefaultConfig()
	cfg.BrokerAddr = *addr

	c, err := client.NewClientWithConfig(cfg)
	if err != nil {
		panic(err)
	}
	defer c.Close()

	_, err = c.PublishFanout(*queue, []byte(*msg))
	if err != nil {
		panic(err)
	}
}