|
- package test
-
- import (
- "applet/app/utils"
- "code.fnuoos.com/go_rely_warehouse/zyos_go_mq.git/rabbit"
- "testing"
- "time"
- )
-
- const WorkQueueName = "test_work_queue"
-
- /**
- TODO:: 公平分发模式下的发送端和接收端(一个发动端,多个接受端)
- */
- func TestWorkSend(t *testing.T) {
- // 推入rabbitMq
- ch, err := rabbit.Cfg.Pool.GetChannel()
- if err != nil {
- t.Error(err)
- }
- defer ch.Release()
- var message struct {
- MessageType string `json:"message_type"`
- Data int `json:"data"`
- }
- message.MessageType = "test"
- message.Data = 1
- for message.Data < 10 {
- ch.Publish(WorkQueueName+"_processor", utils.SerializeStr(message), "")
- message.Data += 1
- time.Sleep(time.Second * 5)
- }
- }
|