gnodet commented on code in PR #25767:
URL: https://github.com/apache/camel/pull/25767#discussion_r3863995694


##########
components/camel-paho-mqtt5/src/main/java/org/apache/camel/component/paho/mqtt5/PahoMqtt5Consumer.java:
##########
@@ -139,6 +141,23 @@ public void deliveryComplete(IMqttToken token) {
         }
     }
 
+    private void restartRouteAsync() {
+        Thread restartThread = new Thread(() -> {
+            try {
+                String routeId = getRoute().getRouteId();
+                LOG.info("Stopping route {} for restart after resubscribe 
failure", routeId);
+                
getEndpoint().getCamelContext().getRouteController().stopRoute(routeId);
+                LOG.info("Restarting route {}", routeId);
+                
getEndpoint().getCamelContext().getRouteController().startRoute(routeId);
+            } catch (Exception e) {
+                getExceptionHandler().handleException(
+                        "Failed to restart route after resubscribe failure", 
e);
+            }

Review Comment:
   Minor: `clientId` is `null` when an external client is provided via 
`setClient()` (since `clientId` is only assigned in the `client == null` branch 
of `doStart()`). This results in thread name `PahoMqtt5-RestartRoute-null`. 
Your own test exercises this exact path.
   
   Consider falling back to `getRoute().getRouteId()` or `client.getClientId()` 
for a more meaningful thread name.



##########
components/camel-paho-mqtt5/src/main/java/org/apache/camel/component/paho/mqtt5/PahoMqtt5Consumer.java:
##########
@@ -83,7 +83,9 @@ public void connectComplete(boolean reconnect, String 
serverURI) {
                         try {
                             client.subscribe(getEndpoint().getTopic(), 
getEndpoint().getConfiguration().getQos());
                         } catch (MqttException e) {
-                            LOG.error("MQTT resubscribe failed {}", 
e.getMessage(), e);
+                            LOG.error("MQTT resubscribe failed on reconnect, 
restarting route for recovery: {}",
+                                    e.getMessage());
+                            restartRouteAsync();
                         }

Review Comment:
   The exception stack trace is lost here. The original code passed `e` as the 
last SLF4J argument (`LOG.error("...", e.getMessage(), e)`), which tells SLF4J 
to append the full stack trace. The replacement drops it, so only the message 
string is logged — making root-cause diagnosis harder in production.
   
   Fix: add `, e` as the last argument:
   ```suggestion
                               LOG.error("MQTT resubscribe failed on reconnect, 
restarting route for recovery: {}",
                                       e.getMessage(), e);
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to