rabbitmq_test.go 859 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. package msgQueue
  2. import (
  3. "sparrow/pkg/protocol"
  4. "sparrow/pkg/queue"
  5. "sparrow/pkg/server"
  6. "testing"
  7. )
  8. func TestNewRabbitMqProducer(t *testing.T) {
  9. server.InitLog("test", "debug")
  10. admin := NewRabbitMessageQueueAdmin(&RabbitMqSettings{
  11. Host:"amqp://guest:guest@localhost:5672/",
  12. }, nil)
  13. producer := NewRabbitMqProducer(admin, "test.lijian")
  14. tpi :=&queue.TopicPartitionInfo{
  15. Topic: "ruleengine",
  16. TenantId: "111",
  17. Partition: 1,
  18. MyPartition: false,
  19. }
  20. msg, err := queue.NewGobQueueMessage(&protocol.Message{
  21. QueueName: "111",
  22. Id: "1111",
  23. Ts: nil,
  24. Type: "1213",
  25. Data: "123213",
  26. RuleChanId: "123",
  27. RuleNodeId: "123123",
  28. Callback: nil,
  29. MetaData: nil,
  30. Originator: "",
  31. })
  32. if err != nil {
  33. t.Error(err)
  34. }
  35. err = producer.Send(tpi, msg, nil)
  36. if err != nil {
  37. t.Error(err)
  38. }
  39. }