RabbitMQ MQTT插件:消息不显示在队列中

ykejflvf  于 2023-03-18  发布在  RabbitMQ
关注(0)|答案(1)|浏览(309)

我尝试实现一个基于RabbitMQ集群的解决方案,集群由3个节点组成,HAProxy负载均衡器暴露端口1883,以便接收MQTT连接,并按照循环策略将其重定向到其中一个RabbitMQ节点。然后,我编写了两个简单的Python客户端,分别是发布者和订阅者。我启用了RabbitMQ MQTT插件,并创建了一个队列 myqueue,它通过路由键 my/routing/keyamq.topic exchange绑定,这也是两个客户端发送和接收消息的主题。
如果我启动发布器,我可以在RabbitMQ管理 Jmeter 板上看到消息速率图上升,但是如果我尝试从队列中获取消息,我会看到 Queue is empty 弹出窗口。
有人帮忙吗?

rn0zuynd

rn0zuynd1#

这是从RabbitMQ节点导出的配置。

{
  "rabbit_version": "3.8.9",
  "rabbitmq_version": "3.8.9",
  "product_name": "RabbitMQ",
  "product_version": "3.8.9",
  "users": [
    {
      "name": "guest",
      "password_hash": "gkUcvdz4jM11hmZVw9GZkJB3QwqlMefasAtEVPZu1uevVgkY",
      "hashing_algorithm": "rabbit_password_hashing_sha256",
      "tags": "administrator"
    }
  ],
  "vhosts": [{ "name": "/" }],
  "permissions": [
    {
      "user": "guest",
      "vhost": "/",
      "configure": ".*",
      "write": ".*",
      "read": ".*"
    }
  ],
  "topic_permissions": [],
  "parameters": [],
  "global_parameters": [
    { "name": "cluster_name", "value": "rabbit@rabbit1" },
    {
      "name": "internal_cluster_id",
      "value": "rabbitmq-cluster-id-9aELuZUOj0hANyiY-hbyCA"
    }
  ],
  "policies": [],
  "queues": [
    {
      "name": "mqtt-subscription-consumerqos1",
      "vhost": "/",
      "durable": true,
      "auto_delete": false,
      "arguments": { "x-expires": 86400000 }
    },
    {
      "name": "mqtt-subscription-publisherqos1",
      "vhost": "/",
      "durable": true,
      "auto_delete": false,
      "arguments": { "x-expires": 86400000 }
    }
  ],
  "exchanges": [],
  "bindings": [
    {
      "source": "amq.topic",
      "vhost": "/",
      "destination": "mqtt-subscription-consumerqos1",
      "destination_type": "queue",
      "routing_key": "my.routing.key",
      "arguments": {}
    }
  ]
}

这是发布者和订阅者的源代码。
x一个一个一个一个x一个一个二个x
现在我可以发布消息并在队列中看到它,但前提是我使用默认队列,在RabbitMQ MTT插件中,该队列的名称为 mqtt-subscription-。如果我定义了一个自定义队列,则消息显然不会存储在其中。

相关问题