producter_test.go 461 B

123456789101112131415161718192021222324252627
  1. package rabbitMQ
  2. import (
  3. "testing"
  4. )
  5. func TestNewProducter(t *testing.T) {
  6. exchange := Exchange{
  7. Name: "gt.dc.event",
  8. Type: "fanout", // 广播
  9. QueueName: "step_change",
  10. Key: "UF-4001A",
  11. Dns: "amqp://admin:devmq*1120@47.96.12.136:5672/",
  12. }
  13. got, err := NewProducter(exchange)
  14. t.Log(got, err)
  15. send := got.Publisher("step_change", []byte(`{"device_code":"UF_4001A"}`))
  16. t.Log(send)
  17. if got != nil {
  18. got.Close()
  19. }
  20. }