You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2023/01/03 15:37:32 UTC

[camel] branch main updated: camel-plc4x: Added timeout to future in process() method of Plc4XProducer and fixed deprecated Camel methods (#8968)

This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/main by this push:
     new 52b528ceca1 camel-plc4x: Added timeout to future in process() method of Plc4XProducer and fixed deprecated Camel methods (#8968)
52b528ceca1 is described below

commit 52b528ceca1faf6d9a9e9ff4725defcca4b33beb
Author: Stein Overtoom <st...@overtoom.email>
AuthorDate: Tue Jan 3 16:37:24 2023 +0100

    camel-plc4x: Added timeout to future in process() method of Plc4XProducer and fixed deprecated Camel methods (#8968)
    
    Co-authored-by: Stein Overtoom <st...@triopsys.nl>
---
 .../java/org/apache/camel/component/plc4x/Plc4XProducer.java     | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/components/camel-plc4x/src/main/java/org/apache/camel/component/plc4x/Plc4XProducer.java b/components/camel-plc4x/src/main/java/org/apache/camel/component/plc4x/Plc4XProducer.java
index 9db0c6db4d7..f73d867f1da 100644
--- a/components/camel-plc4x/src/main/java/org/apache/camel/component/plc4x/Plc4XProducer.java
+++ b/components/camel-plc4x/src/main/java/org/apache/camel/component/plc4x/Plc4XProducer.java
@@ -18,6 +18,7 @@ package org.apache.camel.component.plc4x;
 
 import java.util.Map;
 import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicInteger;
 
 import org.apache.camel.AsyncCallback;
@@ -78,9 +79,9 @@ public class Plc4XProducer extends DefaultAsyncProducer {
         int currentlyOpenRequests = openRequests.incrementAndGet();
         try {
             log.debug("Currently open requests including {}:{}", exchange, currentlyOpenRequests);
-            Object plcWriteResponse = completableFuture.get();
+            Object plcWriteResponse = completableFuture.get(5000, TimeUnit.MILLISECONDS);
             if (exchange.getPattern().isOutCapable()) {
-                Message out = exchange.getOut();
+                Message out = exchange.getMessage();
                 out.copyFrom(exchange.getIn());
                 out.setBody(plcWriteResponse);
             } else {
@@ -96,10 +97,10 @@ public class Plc4XProducer extends DefaultAsyncProducer {
     public boolean process(Exchange exchange, AsyncCallback callback) {
         try {
             process(exchange);
-            Message out = exchange.getOut();
+            Message out = exchange.getMessage();
             out.copyFrom(exchange.getIn());
         } catch (Exception e) {
-            exchange.setOut(null);
+            exchange.setMessage(null);
             exchange.setException(e);
         }
         callback.done(true);