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 2019/12/04 11:49:35 UTC
[camel] branch camel-2.24.x updated: CAMEL-14224: Fix
camel-websocket sendToAll to be faster. Thanks to Michael Elbaz for
reporting.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch camel-2.24.x
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/camel-2.24.x by this push:
new e50b52e CAMEL-14224: Fix camel-websocket sendToAll to be faster. Thanks to Michael Elbaz for reporting.
e50b52e is described below
commit e50b52e2223d84e9e1602bbddba8730b1797aea4
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Wed Dec 4 12:47:51 2019 +0100
CAMEL-14224: Fix camel-websocket sendToAll to be faster. Thanks to Michael Elbaz for reporting.
---
.../component/websocket/WebsocketProducer.java | 23 +++++++++-------------
1 file changed, 9 insertions(+), 14 deletions(-)
diff --git a/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/WebsocketProducer.java b/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/WebsocketProducer.java
index 3392134..eb7eeea 100644
--- a/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/WebsocketProducer.java
+++ b/components/camel-websocket/src/main/java/org/apache/camel/component/websocket/WebsocketProducer.java
@@ -128,22 +128,17 @@ public class WebsocketProducer extends DefaultProducer implements WebsocketProdu
int timeout = endpoint.getSendTimeout();
while (!futures.isEmpty() && watch.taken() < timeout) {
// remove all that are done/cancelled
- for (Future future : futures) {
- if (future.isDone() || future.isCancelled()) {
- futures.remove(future);
- }
- // if there are still more then we need to wait a little bit before checking again, to avoid burning cpu cycles in the while loop
- if (!futures.isEmpty()) {
- long interval = Math.min(1000, timeout);
- log.debug("Sleeping {} millis waiting for sendToAll to complete sending with timeout {} millis", interval, timeout);
- try {
- Thread.sleep(interval);
- } catch (InterruptedException e) {
- handleSleepInterruptedException(e, exchange);
- }
+ futures.removeIf(future -> future.isDone() || future.isCancelled());
+ // if there are still more then we need to wait a little bit before checking again, to avoid burning cpu cycles in the while loop
+ if (!futures.isEmpty()) {
+ long interval = Math.min(1000, timeout);
+ log.debug("Sleeping {} millis waiting for sendToAll to complete sending with timeout {} millis", interval, timeout);
+ try {
+ Thread.sleep(interval);
+ } catch (InterruptedException e) {
+ handleSleepInterruptedException(e, exchange);
}
}
-
}
if (!futures.isEmpty()) {
exception = new WebsocketSendException("Failed to deliver message within " + endpoint.getSendTimeout() + " millis to one or more recipients.", exchange);