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 2021/04/07 05:22:56 UTC
[camel] branch master updated: CAMEL-16462: camel-core - Optimize
RecipientList EIP for default delimiter usage
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/master by this push:
new 54809d7 CAMEL-16462: camel-core - Optimize RecipientList EIP for default delimiter usage
54809d7 is described below
commit 54809d740ed4982683225a5db56c4e13b24448f9
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Wed Apr 7 07:22:20 2021 +0200
CAMEL-16462: camel-core - Optimize RecipientList EIP for default delimiter usage
---
.../apache/camel/processor/MulticastProcessor.java | 4 ++--
.../org/apache/camel/processor/RecipientList.java | 24 ++++++++++++++++------
.../camel/processor/RecipientListProcessor.java | 2 +-
3 files changed, 21 insertions(+), 9 deletions(-)
diff --git a/core/camel-core-processor/src/main/java/org/apache/camel/processor/MulticastProcessor.java b/core/camel-core-processor/src/main/java/org/apache/camel/processor/MulticastProcessor.java
index d9390cc..6f35e5f 100644
--- a/core/camel-core-processor/src/main/java/org/apache/camel/processor/MulticastProcessor.java
+++ b/core/camel-core-processor/src/main/java/org/apache/camel/processor/MulticastProcessor.java
@@ -229,8 +229,8 @@ public class MulticastProcessor extends AsyncProcessorSupport
this.shareUnitOfWork = shareUnitOfWork;
this.parallelAggregate = parallelAggregate;
this.stopOnAggregateException = stopOnAggregateException;
- if (this instanceof Splitter) {
- // not supported for splitter
+ if (this instanceof Splitter || this instanceof RecipientListProcessor) {
+ // not supported for splitter/recipient-list
this.processorExchangeFactory = null;
} else {
this.processorExchangeFactory = camelContext.adapt(ExtendedCamelContext.class)
diff --git a/core/camel-core-processor/src/main/java/org/apache/camel/processor/RecipientList.java b/core/camel-core-processor/src/main/java/org/apache/camel/processor/RecipientList.java
index b5713e2..c45167a 100644
--- a/core/camel-core-processor/src/main/java/org/apache/camel/processor/RecipientList.java
+++ b/core/camel-core-processor/src/main/java/org/apache/camel/processor/RecipientList.java
@@ -16,6 +16,7 @@
*/
package org.apache.camel.processor;
+import java.util.Arrays;
import java.util.Collection;
import java.util.Iterator;
import java.util.concurrent.ExecutorService;
@@ -190,12 +191,23 @@ public class RecipientList extends AsyncProcessorSupport implements IdAware, Rou
* Sends the given exchange to the recipient list
*/
public boolean sendToRecipientList(Exchange exchange, Object recipientList, AsyncCallback callback) {
- Iterator<?> iter;
-
- if (delimiter != null && delimiter.equalsIgnoreCase(IGNORE_DELIMITER_MARKER)) {
- iter = ObjectHelper.createIterator(recipientList, null);
- } else {
- iter = ObjectHelper.createIterator(recipientList, delimiter);
+ Iterator<?> iter = null;
+
+ if (recipientList instanceof String && delimiter != null && !delimiter.equalsIgnoreCase(IGNORE_DELIMITER_MARKER)) {
+ // optimize for fast iterator
+ String str = (String) recipientList;
+ if (delimiter.length() == 1) {
+ int count = StringHelper.countChar(str, delimiter.charAt(0)) + 1;
+ String[] parts = StringHelper.splitOnCharacter(str, delimiter, count);
+ iter = Arrays.asList((Object[]) parts).iterator();
+ }
+ }
+ if (iter == null) {
+ if (delimiter != null && delimiter.equalsIgnoreCase(IGNORE_DELIMITER_MARKER)) {
+ iter = ObjectHelper.createIterator(recipientList, null);
+ } else {
+ iter = ObjectHelper.createIterator(recipientList, delimiter);
+ }
}
RecipientListProcessor rlp = new RecipientListProcessor(
diff --git a/core/camel-core-processor/src/main/java/org/apache/camel/processor/RecipientListProcessor.java b/core/camel-core-processor/src/main/java/org/apache/camel/processor/RecipientListProcessor.java
index 4d9f76f..e1dacf3 100644
--- a/core/camel-core-processor/src/main/java/org/apache/camel/processor/RecipientListProcessor.java
+++ b/core/camel-core-processor/src/main/java/org/apache/camel/processor/RecipientListProcessor.java
@@ -241,7 +241,7 @@ public class RecipientListProcessor extends MulticastProcessor {
int index, Endpoint endpoint, Producer producer,
Exchange exchange, ExchangePattern pattern, boolean prototypeEndpoint) {
// copy exchange, and do not share the unit of work
- Exchange copy = processorExchangeFactory.createCorrelatedCopy(exchange, false);
+ Exchange copy = ExchangeHelper.createCorrelatedCopy(exchange, false);
// if we share unit of work, we need to prepare the child exchange
if (isShareUnitOfWork()) {