davsclaus commented on code in PR #27761:
URL: https://github.com/apache/camel/pull/27761#discussion_r4255596291


##########
components/camel-telegram/src/main/java/org/apache/camel/component/telegram/service/TelegramMessageHandler.java:
##########
@@ -63,18 +64,26 @@ public void sendMessage(Exchange exchange, AsyncCallback 
callback, T message) {
         builder.setHeader("Accept", "application/json");
 
         builder.POST(bodyPublisher.newPublisher());
-        try {
-            final TelegramAsyncHandler telegramAsyncHandler
-                    = new TelegramAsyncHandler(uri, resultClass, mapper, 
exchange, callback);
+        final TelegramAsyncHandler telegramAsyncHandler = new 
TelegramAsyncHandler(uri, resultClass, mapper, exchange);
+        final CompletableFuture<Object> response
+                = apiClient.client().sendAsync(builder.build(), 
HttpResponse.BodyHandlers.ofInputStream())
+                        
.thenApply(telegramAsyncHandler::handleCompressedResponse);
 
-            apiClient.client().sendAsync(builder.build(), 
HttpResponse.BodyHandlers.ofInputStream())
-                    
.thenApply(telegramAsyncHandler::handleCompressedResponse).get();
+        try {
+            // the calling thread waits for the answer, so a caller sends one 
message after the other
+            response.get();
         } catch (InterruptedException e) {
             Thread.currentThread().interrupt();
-            throw new RuntimeException(e);
+            // nobody waits for the answer any more: keep the stage from 
writing to the completed exchange later
+            response.cancel(true);

Review Comment:
   Not blocking this PR; tracked as a follow-up in CAMEL-25600.
   
   _Claude Code on behalf of @davsclaus._



-- 
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