【问题标题】:Apache Camel PAHO MQTT component does not receive messages after disconnectingApache Camel PAHO MQTT 组件断开连接后收不到消息
【发布时间】:2020-09-21 23:18:52
【问题描述】:

我在这里看到了同样的问题,但不明白如何根据响应解决此问题。

Camel PAHO routes not receiving offline messages while connecting back

是否可以在 paho 端点接收离线消息,如果可以,如何?这需要修改源代码吗?

我确认我在命令行中使用 mosquitto_sub 收到了离线消息。

这是我的端点配置:

<from uri="paho:JUNK?brokerUrl=tcp://localhost:1883?cleanSession=false&qos=2&clientId=camel_test" />

更多细节。似乎在断开骆驼客户端时,客户端首先取消订阅,这导致客户端在重新连接时无法接收离线消息。

Sep 21 06:33:40 me mosquitto.mosquitto[1290]: 1600684420: camel_test JUNK
Sep 21 06:33:40 me mosquitto.mosquitto[1290]: 1600684420: Sending UNSUBACK to camel_test
Sep 21 06:33:40 me mosquitto.mosquitto[1290]: 1600684420: Received DISCONNECT from camel_test
Sep 21 06:33:40 me mosquitto.mosquitto[1290]: 1600684420: Client camel_test disconnected.

mosquitto_sub 命令行客户端不会在断开连接时取消订阅,因此能够在重新连接时接收离线消息。

Sep 21 06:33:21 me mosquitto.mosquitto[1290]: 1600684400: Client ns_consumer disconnected.
Sep 21 06:42:23 me mosquitto.mosquitto[1290]: 1600684943: New client connected from ::1 as ns_consumer (p2, c0, k60).
Sep 21 06:42:23 me mosquitto.mosquitto[1290]: 1600684943: Sending CONNACK to ns_consumer (1, 0)
Sep 21 06:42:23 me mosquitto.mosquitto[1290]: 1600684943: Sending PUBLISH to ns_consumer (d0, q2, r0, m26, 'JUNK', ... (189 bytes))
Sep 21 06:42:23 me mosquitto.mosquitto[1290]: 1600684943: Received SUBSCRIBE from ns_consumer
Sep 21 06:42:23 me mosquitto.mosquitto[1290]: 1600684943: ns_consumer 2 JUNK
Sep 21 06:42:23 me mosquitto.mosquitto[1290]: 1600684943: Sending SUBACK to ns_consumer
Sep 21 06:42:23 me mosquitto.mosquitto[1290]: 1600684943: Sending PUBLISH to ns_consumer (d0, q2, r1, m27, 'JUNK', ... (189 bytes))
Sep 21 06:42:23 me mosquitto.mosquitto[1290]: 1600684943: Received PUBREC from ns_consumer (Mid: 26)
Sep 21 06:42:23 me mosquitto.mosquitto[1290]: 1600684943: Sending PUBREL to ns_consumer (m26)
Sep 21 06:42:23 me mosquitto.mosquitto[1290]: 1600684943: Received PUBREC from ns_consumer (Mid: 27)
Sep 21 06:42:23 me mosquitto.mosquitto[1290]: 1600684943: Sending PUBREL to ns_consumer (m27)
Sep 21 06:42:23 me mosquitto.mosquitto[1290]: 1600684943: Received PUBCOMP from ns_consumer (Mid: 26, RC:0)
Sep 21 06:42:23 me mosquitto.mosquitto[1290]: 1600684943: Received PUBCOMP from ns_consumer (Mid: 27, RC:0)

【问题讨论】:

  • 你用的是什么版本的骆驼?
  • 我使用的是 3.4.3 版。想知道这是否可能是由于客户端在断开连接时首先取消订阅?是否有解决此问题的更新版本?
  • 已验证在骆驼 3.5.0 中出现相同的取消订阅功能
  • 没关系...找出问题所在。 url 语法不正确,因此从未设置 cleanSession。

标签: apache-camel mqtt paho spring-camel


【解决方案1】:

问题是端点配置中的语法不正确,因此 cleanSession 从未通过参数设置并默认为 true。

<from uri="paho:JUNK?brokerUrl=tcp://localhost:1883?cleanSession=false&qos=2&clientId=camel_test" />

应该是

<from uri="paho:JUNK?brokerUrl=tcp://localhost:1883&cleanSession=false&qos=2&clientId=camel_test" />

【讨论】:

    猜你喜欢
    • 2021-10-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-09-11
    • 1970-01-01
    相关资源
    最近更新 更多