package main

import (
	"demo/rabbitmq/go-rabbitmq/ra"
	"encoding/json"
	"github.com/wagslane/go-rabbitmq"
)

func main() {

	conn, _ := rabbitmq.NewConn(
		ra.MQUrl,
		rabbitmq.WithConnectionOptionsLogging,
	)
	defer conn.Close()
	pub, err := ra.NewPublisher(conn)
	if err != nil {

	}
	defer pub.Close()
	//go func() {
	//	for i := 0; i < 100; i++ {
	//		fmt.Println("1:" + strconv.Itoa(i))
	//		ra.SendMessage(
	//			ra.Message{
	//				ID:     strconv.Itoa(i),
	//				Method: "test1",
	//				Body:   []byte(""),
	//			}, "1", pub)
	//	}
	//
	//}()
	//go func() {
	//
	//	for i := 0; i < 100; i++ {
	//		fmt.Println("2:" + strconv.Itoa(i))
	//		ra.SendMessage(
	//			ra.Message{
	//				ID:     strconv.Itoa(i),
	//				Method: "test2",
	//				Body:   []byte(""),
	//			}, "", pub)
	//	}
	//
	//}()
	//time.Sleep(time.Second * 10)

	var m = map[string]interface{}{
		"code":   200,
		"msg":    "success",
		"status": false,
	}
	b, _ := json.Marshal(m)
	ra.SendMessage(
		ra.Message{
			ID:     "ddf5379f-9299-405a-841b-01d19a4ea81d",
			Method: "createVM",
			Body:   b,
		}, "", pub)
}
