This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch camel-2.x in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/camel-2.x by this push: new cf0b903 CAMEL-14224: Fix camel-websocket sendToAll to be faster. Thanks to Michael Elbaz for reporting. cf0b903 is described below commit cf0b90364a7b91699a741aa78405e5bae2d8a41c Author: Claus Ibsen <claus.ib...@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);