Claus Ibsen created CAMEL-27716:
-----------------------------------

             Summary: camel-hivemq: toD topic replace, out-of-order consumer, 
MQTT 5 cleanStart, labels, doc
                 Key: CAMEL-27716
                 URL: https://issues.apache.org/jira/browse/CAMEL-27716
             Project: Camel
          Issue Type: Bug
            Reporter: Claus Ibsen
             Fix For: 4.24.0


Found while improving the option descriptions of camel-hivemq for CAMEL-23832 
(commit 
https://github.com/apache/camel/commit/2dc3c6d16afe8bc11ec764caf0aded496582337b).
These are separate problems of the component; the descriptions commit only 
documents the current behavior.

h4. 1. toD fails when the topic is part of the "hivemq:" scheme prefix
{{HiveMQSendDynamicAware.resolveStaticUri()}} builds the static URI with 
{{StringHelper.replaceFirst(entry.getUri(), topic, originalTopic)}}, which 
replaces the first occurrence of the topic anywhere in the URI, not the topic 
path.
With {{toD("hivemq:$\{header.t\}")}} and the header {{t}} set to {{hivemq}} (or 
{{mq}}, {{hive}}, {{q}}, ...), the scheme is replaced instead: the static URI 
becomes {{$\{header.t\}://hivemq}}, no component resolves it and the exchange 
fails.
Replace only the path after the scheme, for example by cutting the URI after 
{{hivemq:}} (or {{hivemq://}}) before the replace.

h4. 2. The consumer processes the messages of a topic out of order
{{HiveMQConsumer.onMessage()}} submits each message to a thread pool from 
{{newDefaultThreadPool}} (10 to 20 threads), so several messages of the same 
topic are routed at the same time, and the route sees them in another order 
than the broker delivered them.
MQTT keeps the order of the messages of a topic, and there is no option to keep 
it or to size the pool.
Process the messages in order by default (one thread per consumer, as the pool 
is needed for the graceful stop of CAMEL-25293), or add an option for the 
number of threads.

h4. 3. cleanStart=false has no effect with MQTT 5
{{Mqtt5ClientAdapter.connect()}} sends CONNECT with {{cleanStart(cleanStart)}} 
but never sets a session expiry interval, so the default of 0 applies and the 
broker removes the session when the connection closes.
With MQTT 5, the default {{mqttVersion}}, {{cleanStart=false}} therefore keeps 
no subscriptions or queued messages. This is documented (CAMEL-25030), but the 
option cannot do what its name says.
Add a {{sessionExpiryInterval}} option, used with MQTT 5.

h4. 4. The retained option and the headers have no consumer/producer label
In {{HiveMQConfiguration}}, {{retained}} is read only by 
{{HiveMQProducer.process()}} but has no {{producer}} label, so it is listed 
among the common options.
In {{HiveMQConstants}}, {{CamelHiveMQTopic}} is set only by the consumer and 
{{CamelHiveMQOverrideTopic}} is read only by the producer, but neither has a 
{{label}} ({{consumer}} and {{producer}}).

h4. 5. The doc page says that the client library generates the client identifier
The "Client identifier" section of {{hivemq-component.adoc}} says that without 
{{clientId}} "the HiveMQ client library generates a unique identifier per 
connection".
The library sends an empty client identifier 
({{MqttClientIdentifierImpl.REQUEST_CLIENT_IDENTIFIER_FROM_SERVER}}) and the 
broker assigns one. With MQTT 3.1.1 and {{cleanStart=false}} the broker rejects 
such a connection, which the page does not say.
Correct the sentence.

_Claude Code on behalf of davsclaus_



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to