智慧食堂-队列消费项目
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

34 lines
714 B

  1. package test
  2. import (
  3. "applet/app/utils"
  4. "code.fnuoos.com/go_rely_warehouse/zyos_go_mq.git/rabbit"
  5. "testing"
  6. "time"
  7. )
  8. const WorkQueueName = "test_work_queue"
  9. /**
  10. TODO:: 公平分发模式下的发送端和接收端(一个发动端,多个接受端)
  11. */
  12. func TestWorkSend(t *testing.T) {
  13. // 推入rabbitMq
  14. ch, err := rabbit.Cfg.Pool.GetChannel()
  15. if err != nil {
  16. t.Error(err)
  17. }
  18. defer ch.Release()
  19. var message struct {
  20. MessageType string `json:"message_type"`
  21. Data int `json:"data"`
  22. }
  23. message.MessageType = "test"
  24. message.Data = 1
  25. for message.Data < 10 {
  26. ch.Publish(WorkQueueName+"_processor", utils.SerializeStr(message), "")
  27. message.Data += 1
  28. time.Sleep(time.Second * 5)
  29. }
  30. }