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 f6f3cc3 CAMEL-15769: disable split default delimiter (#4594)
f6f3cc3 is described below
commit f6f3cc36c0474d12aa52af1da04ba05c59cd736b
Author: Scott Carrier <[email protected]>
AuthorDate: Thu Nov 12 12:56:49 2020 -0500
CAMEL-15769: disable split default delimiter (#4594)
* CAMEL-15769: disable split default delimiter
* format new unit test java file
* Add fluent method for delimiter with javadoc
* committing generated sources from local build
---
.../org/apache/camel/catalog/models/split.json | 31 ++++-----
.../apache/camel/catalog/schemas/camel-spring.xsd | 8 +++
.../resources/org/apache/camel/model/split.json | 31 ++++-----
.../apache/camel/model/ProcessorDefinition.java | 18 ++++++
.../org/apache/camel/model/SplitDefinition.java | 24 +++++++
.../java/org/apache/camel/processor/Splitter.java | 39 ++++++++++-
.../org/apache/camel/reifier/SplitReifier.java | 19 ++++--
.../camel/processor/SplitWithDelimiterTest.java | 75 ++++++++++++++++++++++
.../java/org/apache/camel/xml/in/ModelParser.java | 1 +
9 files changed, 209 insertions(+), 37 deletions(-)
diff --git
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/models/split.json
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/models/split.json
index acf7a83..b2c01fa 100644
---
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/models/split.json
+++
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/models/split.json
@@ -11,20 +11,21 @@
"output": true
},
"properties": {
- "expression": { "kind": "expression", "displayName": "Expression",
"required": true, "type": "object", "javaType":
"org.apache.camel.model.language.ExpressionDefinition", "oneOf": [ "constant",
"exchangeProperty", "groovy", "header", "hl7terser", "joor", "jsonpath",
"language", "method", "mvel", "ognl", "ref", "simple", "spel", "tokenize",
"xpath", "xquery", "xtokenize" ], "deprecated": false, "autowired": false,
"secret": false, "description": "Expression of how to split the message [...]
- "parallelProcessing": { "kind": "attribute", "displayName": "Parallel
Processing", "required": false, "type": "boolean", "javaType":
"java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false,
"defaultValue": false, "description": "If enabled then processing each splitted
messages occurs concurrently. Note the caller thread will still wait until all
messages has been fully processed, before it continues. Its only processing the
sub messages from the splitter which [...]
- "strategyRef": { "kind": "attribute", "displayName": "Strategy Ref",
"required": false, "type": "string", "javaType": "java.lang.String",
"deprecated": false, "autowired": false, "secret": false, "description": "Sets
a reference to the AggregationStrategy to be used to assemble the replies from
the splitted messages, into a single outgoing message from the Splitter. By
default Camel will use the original incoming message to the splitter (leave it
unchanged). You can also use a POJO a [...]
- "strategyMethodName": { "kind": "attribute", "displayName": "Strategy
Method Name", "required": false, "type": "string", "javaType":
"java.lang.String", "deprecated": false, "autowired": false, "secret": false,
"description": "This option can be used to explicit declare the method name to
use, when using POJOs as the AggregationStrategy." },
- "strategyMethodAllowNull": { "kind": "attribute", "displayName": "Strategy
Method Allow Null", "required": false, "type": "boolean", "javaType":
"java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false,
"defaultValue": false, "description": "If this option is false then the
aggregate method is not used if there was no data to enrich. If this option is
true then null values is used as the oldExchange (when no data to enrich), when
using POJOs as the AggregationStr [...]
- "executorServiceRef": { "kind": "attribute", "displayName": "Executor
Service Ref", "required": false, "type": "string", "javaType":
"java.lang.String", "deprecated": false, "autowired": false, "secret": false,
"description": "Refers to a custom Thread Pool to be used for parallel
processing. Notice if you set this option, then parallel processing is
automatic implied, and you do not have to enable that option as well." },
- "streaming": { "kind": "attribute", "displayName": "Streaming",
"required": false, "type": "boolean", "javaType": "java.lang.Boolean",
"deprecated": false, "autowired": false, "secret": false, "defaultValue":
false, "description": "When in streaming mode, then the splitter splits the
original message on-demand, and each splitted message is processed one by one.
This reduces memory usage as the splitter do not split all the messages first,
but then we do not know the total size, and t [...]
- "stopOnException": { "kind": "attribute", "displayName": "Stop On
Exception", "required": false, "type": "boolean", "javaType":
"java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false,
"defaultValue": false, "description": "Will now stop further processing if an
exception or failure occurred during processing of an org.apache.camel.Exchange
and the caused exception will be thrown. Will also stop if processing the
exchange failed (has a fault message) or an excep [...]
- "timeout": { "kind": "attribute", "displayName": "Timeout", "required":
false, "type": "duration", "javaType": "java.lang.String", "deprecated": false,
"autowired": false, "secret": false, "defaultValue": "0", "description": "Sets
a total timeout specified in millis, when using parallel processing. If the
Splitter hasn't been able to split and process all the sub messages within the
given timeframe, then the timeout triggers and the Splitter breaks out and
continues. Notice if you pr [...]
- "onPrepareRef": { "kind": "attribute", "displayName": "On Prepare Ref",
"required": false, "type": "string", "javaType": "java.lang.String",
"deprecated": false, "autowired": false, "secret": false, "description": "Uses
the Processor when preparing the org.apache.camel.Exchange to be send. This can
be used to deep-clone messages that should be send, or any custom logic needed
before the exchange is send." },
- "shareUnitOfWork": { "kind": "attribute", "displayName": "Share Unit Of
Work", "required": false, "type": "boolean", "javaType": "java.lang.Boolean",
"deprecated": false, "autowired": false, "secret": false, "defaultValue":
false, "description": "Shares the org.apache.camel.spi.UnitOfWork with the
parent and each of the sub messages. Splitter will by default not share unit of
work between the parent exchange and each splitted exchange. This means each
splitted exchange has its own in [...]
- "parallelAggregate": { "kind": "attribute", "displayName": "Parallel
Aggregate", "required": false, "type": "boolean", "javaType":
"java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false,
"defaultValue": false, "description": "If enabled then the aggregate method on
AggregationStrategy can be called concurrently. Notice that this would require
the implementation of AggregationStrategy to be implemented as thread-safe. By
default this is false meaning that Camel [...]
- "stopOnAggregateException": { "kind": "attribute", "displayName": "Stop On
Aggregate Exception", "required": false, "type": "boolean", "javaType":
"java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false,
"defaultValue": false, "description": "If enabled, unwind exceptions occurring
at aggregation time to the error handler when parallelProcessing is used.
Currently, aggregation time exceptions do not stop the route processing when
parallelProcessing is used. Enab [...]
- "id": { "kind": "attribute", "displayName": "Id", "required": false,
"type": "string", "javaType": "java.lang.String", "deprecated": false,
"autowired": false, "secret": false, "description": "Sets the id of this node"
},
- "description": { "kind": "element", "displayName": "Description",
"required": false, "type": "object", "javaType":
"org.apache.camel.model.DescriptionDefinition", "deprecated": false,
"autowired": false, "secret": false, "description": "Sets the description of
this node" }
+ "expression": { "kind": "expression", "displayName": "Expression",
"required": true, "type": "object", "javaType":
"org.apache.camel.model.language.ExpressionDefinition", "oneOf": [ "constant",
"exchangeProperty", "groovy", "header", "hl7terser", "joor", "jsonpath",
"language", "method", "mvel", "ognl", "ref", "simple", "spel", "tokenize",
"xpath", "xquery", "xtokenize" ], "deprecated": false, "secret": false,
"description": "Expression of how to split the message body, such as as-is [...]
+ "delimiter": { "kind": "attribute", "displayName": "Delimiter",
"required": false, "type": "string", "javaType": "java.lang.String",
"deprecated": false, "secret": false, "defaultValue": ",", "description":
"Delimiter used in splitting messages. Can be turned off using the value false.
The default value is ," },
+ "parallelProcessing": { "kind": "attribute", "displayName": "Parallel
Processing", "required": false, "type": "boolean", "javaType":
"java.lang.Boolean", "deprecated": false, "secret": false, "defaultValue":
false, "description": "If enabled then processing each splitted messages occurs
concurrently. Note the caller thread will still wait until all messages has
been fully processed, before it continues. Its only processing the sub messages
from the splitter which happens concurrently." },
+ "strategyRef": { "kind": "attribute", "displayName": "Strategy Ref",
"required": false, "type": "string", "javaType": "java.lang.String",
"deprecated": false, "secret": false, "description": "Sets a reference to the
AggregationStrategy to be used to assemble the replies from the splitted
messages, into a single outgoing message from the Splitter. By default Camel
will use the original incoming message to the splitter (leave it unchanged).
You can also use a POJO as the AggregationStr [...]
+ "strategyMethodName": { "kind": "attribute", "displayName": "Strategy
Method Name", "required": false, "type": "string", "javaType":
"java.lang.String", "deprecated": false, "secret": false, "description": "This
option can be used to explicit declare the method name to use, when using POJOs
as the AggregationStrategy." },
+ "strategyMethodAllowNull": { "kind": "attribute", "displayName": "Strategy
Method Allow Null", "required": false, "type": "boolean", "javaType":
"java.lang.Boolean", "deprecated": false, "secret": false, "defaultValue":
false, "description": "If this option is false then the aggregate method is not
used if there was no data to enrich. If this option is true then null values is
used as the oldExchange (when no data to enrich), when using POJOs as the
AggregationStrategy" },
+ "executorServiceRef": { "kind": "attribute", "displayName": "Executor
Service Ref", "required": false, "type": "string", "javaType":
"java.lang.String", "deprecated": false, "secret": false, "description":
"Refers to a custom Thread Pool to be used for parallel processing. Notice if
you set this option, then parallel processing is automatic implied, and you do
not have to enable that option as well." },
+ "streaming": { "kind": "attribute", "displayName": "Streaming",
"required": false, "type": "boolean", "javaType": "java.lang.Boolean",
"deprecated": false, "secret": false, "defaultValue": false, "description":
"When in streaming mode, then the splitter splits the original message
on-demand, and each splitted message is processed one by one. This reduces
memory usage as the splitter do not split all the messages first, but then we
do not know the total size, and therefore the org.apa [...]
+ "stopOnException": { "kind": "attribute", "displayName": "Stop On
Exception", "required": false, "type": "boolean", "javaType":
"java.lang.Boolean", "deprecated": false, "secret": false, "defaultValue":
false, "description": "Will now stop further processing if an exception or
failure occurred during processing of an org.apache.camel.Exchange and the
caused exception will be thrown. Will also stop if processing the exchange
failed (has a fault message) or an exception was thrown and [...]
+ "timeout": { "kind": "attribute", "displayName": "Timeout", "required":
false, "type": "duration", "javaType": "java.lang.String", "deprecated": false,
"secret": false, "defaultValue": "0", "description": "Sets a total timeout
specified in millis, when using parallel processing. If the Splitter hasn't
been able to split and process all the sub messages within the given timeframe,
then the timeout triggers and the Splitter breaks out and continues. Notice if
you provide a TimeoutAware [...]
+ "onPrepareRef": { "kind": "attribute", "displayName": "On Prepare Ref",
"required": false, "type": "string", "javaType": "java.lang.String",
"deprecated": false, "secret": false, "description": "Uses the Processor when
preparing the org.apache.camel.Exchange to be send. This can be used to
deep-clone messages that should be send, or any custom logic needed before the
exchange is send." },
+ "shareUnitOfWork": { "kind": "attribute", "displayName": "Share Unit Of
Work", "required": false, "type": "boolean", "javaType": "java.lang.Boolean",
"deprecated": false, "secret": false, "defaultValue": false, "description":
"Shares the org.apache.camel.spi.UnitOfWork with the parent and each of the sub
messages. Splitter will by default not share unit of work between the parent
exchange and each splitted exchange. This means each splitted exchange has its
own individual unit of work." },
+ "parallelAggregate": { "kind": "attribute", "displayName": "Parallel
Aggregate", "required": false, "type": "boolean", "javaType":
"java.lang.Boolean", "deprecated": false, "secret": false, "defaultValue":
false, "description": "If enabled then the aggregate method on
AggregationStrategy can be called concurrently. Notice that this would require
the implementation of AggregationStrategy to be implemented as thread-safe. By
default this is false meaning that Camel synchronizes the cal [...]
+ "stopOnAggregateException": { "kind": "attribute", "displayName": "Stop On
Aggregate Exception", "required": false, "type": "boolean", "javaType":
"java.lang.Boolean", "deprecated": false, "secret": false, "defaultValue":
false, "description": "If enabled, unwind exceptions occurring at aggregation
time to the error handler when parallelProcessing is used. Currently,
aggregation time exceptions do not stop the route processing when
parallelProcessing is used. Enabling this option all [...]
+ "id": { "kind": "attribute", "displayName": "Id", "required": false,
"type": "string", "javaType": "java.lang.String", "deprecated": false,
"secret": false, "description": "Sets the id of this node" },
+ "description": { "kind": "element", "displayName": "Description",
"required": false, "type": "object", "javaType":
"org.apache.camel.model.DescriptionDefinition", "deprecated": false, "secret":
false, "description": "Sets the description of this node" }
}
}
diff --git
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/schemas/camel-spring.xsd
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/schemas/camel-spring.xsd
index c54b6bf..23a6601 100644
---
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/schemas/camel-spring.xsd
+++
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/schemas/camel-spring.xsd
@@ -10450,6 +10450,14 @@ Sets a reference to lookup for the comparator to use
for sorting.
<xs:element ref="tns:serviceCall"/>
</xs:choice>
</xs:sequence>
+ <xs:attribute name="delimiter" type="xs:string">
+ <xs:annotation>
+ <xs:documentation xml:lang="en"><![CDATA[
+Delimiter used in splitting messages. Can be turned off using the value false.
+The default value is ,. Default value: ,
+ ]]></xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
<xs:attribute name="parallelProcessing" type="xs:string">
<xs:annotation>
<xs:documentation xml:lang="en"><![CDATA[
diff --git
a/core/camel-core-model/src/generated/resources/org/apache/camel/model/split.json
b/core/camel-core-model/src/generated/resources/org/apache/camel/model/split.json
index acf7a83..b2c01fa 100644
---
a/core/camel-core-model/src/generated/resources/org/apache/camel/model/split.json
+++
b/core/camel-core-model/src/generated/resources/org/apache/camel/model/split.json
@@ -11,20 +11,21 @@
"output": true
},
"properties": {
- "expression": { "kind": "expression", "displayName": "Expression",
"required": true, "type": "object", "javaType":
"org.apache.camel.model.language.ExpressionDefinition", "oneOf": [ "constant",
"exchangeProperty", "groovy", "header", "hl7terser", "joor", "jsonpath",
"language", "method", "mvel", "ognl", "ref", "simple", "spel", "tokenize",
"xpath", "xquery", "xtokenize" ], "deprecated": false, "autowired": false,
"secret": false, "description": "Expression of how to split the message [...]
- "parallelProcessing": { "kind": "attribute", "displayName": "Parallel
Processing", "required": false, "type": "boolean", "javaType":
"java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false,
"defaultValue": false, "description": "If enabled then processing each splitted
messages occurs concurrently. Note the caller thread will still wait until all
messages has been fully processed, before it continues. Its only processing the
sub messages from the splitter which [...]
- "strategyRef": { "kind": "attribute", "displayName": "Strategy Ref",
"required": false, "type": "string", "javaType": "java.lang.String",
"deprecated": false, "autowired": false, "secret": false, "description": "Sets
a reference to the AggregationStrategy to be used to assemble the replies from
the splitted messages, into a single outgoing message from the Splitter. By
default Camel will use the original incoming message to the splitter (leave it
unchanged). You can also use a POJO a [...]
- "strategyMethodName": { "kind": "attribute", "displayName": "Strategy
Method Name", "required": false, "type": "string", "javaType":
"java.lang.String", "deprecated": false, "autowired": false, "secret": false,
"description": "This option can be used to explicit declare the method name to
use, when using POJOs as the AggregationStrategy." },
- "strategyMethodAllowNull": { "kind": "attribute", "displayName": "Strategy
Method Allow Null", "required": false, "type": "boolean", "javaType":
"java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false,
"defaultValue": false, "description": "If this option is false then the
aggregate method is not used if there was no data to enrich. If this option is
true then null values is used as the oldExchange (when no data to enrich), when
using POJOs as the AggregationStr [...]
- "executorServiceRef": { "kind": "attribute", "displayName": "Executor
Service Ref", "required": false, "type": "string", "javaType":
"java.lang.String", "deprecated": false, "autowired": false, "secret": false,
"description": "Refers to a custom Thread Pool to be used for parallel
processing. Notice if you set this option, then parallel processing is
automatic implied, and you do not have to enable that option as well." },
- "streaming": { "kind": "attribute", "displayName": "Streaming",
"required": false, "type": "boolean", "javaType": "java.lang.Boolean",
"deprecated": false, "autowired": false, "secret": false, "defaultValue":
false, "description": "When in streaming mode, then the splitter splits the
original message on-demand, and each splitted message is processed one by one.
This reduces memory usage as the splitter do not split all the messages first,
but then we do not know the total size, and t [...]
- "stopOnException": { "kind": "attribute", "displayName": "Stop On
Exception", "required": false, "type": "boolean", "javaType":
"java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false,
"defaultValue": false, "description": "Will now stop further processing if an
exception or failure occurred during processing of an org.apache.camel.Exchange
and the caused exception will be thrown. Will also stop if processing the
exchange failed (has a fault message) or an excep [...]
- "timeout": { "kind": "attribute", "displayName": "Timeout", "required":
false, "type": "duration", "javaType": "java.lang.String", "deprecated": false,
"autowired": false, "secret": false, "defaultValue": "0", "description": "Sets
a total timeout specified in millis, when using parallel processing. If the
Splitter hasn't been able to split and process all the sub messages within the
given timeframe, then the timeout triggers and the Splitter breaks out and
continues. Notice if you pr [...]
- "onPrepareRef": { "kind": "attribute", "displayName": "On Prepare Ref",
"required": false, "type": "string", "javaType": "java.lang.String",
"deprecated": false, "autowired": false, "secret": false, "description": "Uses
the Processor when preparing the org.apache.camel.Exchange to be send. This can
be used to deep-clone messages that should be send, or any custom logic needed
before the exchange is send." },
- "shareUnitOfWork": { "kind": "attribute", "displayName": "Share Unit Of
Work", "required": false, "type": "boolean", "javaType": "java.lang.Boolean",
"deprecated": false, "autowired": false, "secret": false, "defaultValue":
false, "description": "Shares the org.apache.camel.spi.UnitOfWork with the
parent and each of the sub messages. Splitter will by default not share unit of
work between the parent exchange and each splitted exchange. This means each
splitted exchange has its own in [...]
- "parallelAggregate": { "kind": "attribute", "displayName": "Parallel
Aggregate", "required": false, "type": "boolean", "javaType":
"java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false,
"defaultValue": false, "description": "If enabled then the aggregate method on
AggregationStrategy can be called concurrently. Notice that this would require
the implementation of AggregationStrategy to be implemented as thread-safe. By
default this is false meaning that Camel [...]
- "stopOnAggregateException": { "kind": "attribute", "displayName": "Stop On
Aggregate Exception", "required": false, "type": "boolean", "javaType":
"java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false,
"defaultValue": false, "description": "If enabled, unwind exceptions occurring
at aggregation time to the error handler when parallelProcessing is used.
Currently, aggregation time exceptions do not stop the route processing when
parallelProcessing is used. Enab [...]
- "id": { "kind": "attribute", "displayName": "Id", "required": false,
"type": "string", "javaType": "java.lang.String", "deprecated": false,
"autowired": false, "secret": false, "description": "Sets the id of this node"
},
- "description": { "kind": "element", "displayName": "Description",
"required": false, "type": "object", "javaType":
"org.apache.camel.model.DescriptionDefinition", "deprecated": false,
"autowired": false, "secret": false, "description": "Sets the description of
this node" }
+ "expression": { "kind": "expression", "displayName": "Expression",
"required": true, "type": "object", "javaType":
"org.apache.camel.model.language.ExpressionDefinition", "oneOf": [ "constant",
"exchangeProperty", "groovy", "header", "hl7terser", "joor", "jsonpath",
"language", "method", "mvel", "ognl", "ref", "simple", "spel", "tokenize",
"xpath", "xquery", "xtokenize" ], "deprecated": false, "secret": false,
"description": "Expression of how to split the message body, such as as-is [...]
+ "delimiter": { "kind": "attribute", "displayName": "Delimiter",
"required": false, "type": "string", "javaType": "java.lang.String",
"deprecated": false, "secret": false, "defaultValue": ",", "description":
"Delimiter used in splitting messages. Can be turned off using the value false.
The default value is ," },
+ "parallelProcessing": { "kind": "attribute", "displayName": "Parallel
Processing", "required": false, "type": "boolean", "javaType":
"java.lang.Boolean", "deprecated": false, "secret": false, "defaultValue":
false, "description": "If enabled then processing each splitted messages occurs
concurrently. Note the caller thread will still wait until all messages has
been fully processed, before it continues. Its only processing the sub messages
from the splitter which happens concurrently." },
+ "strategyRef": { "kind": "attribute", "displayName": "Strategy Ref",
"required": false, "type": "string", "javaType": "java.lang.String",
"deprecated": false, "secret": false, "description": "Sets a reference to the
AggregationStrategy to be used to assemble the replies from the splitted
messages, into a single outgoing message from the Splitter. By default Camel
will use the original incoming message to the splitter (leave it unchanged).
You can also use a POJO as the AggregationStr [...]
+ "strategyMethodName": { "kind": "attribute", "displayName": "Strategy
Method Name", "required": false, "type": "string", "javaType":
"java.lang.String", "deprecated": false, "secret": false, "description": "This
option can be used to explicit declare the method name to use, when using POJOs
as the AggregationStrategy." },
+ "strategyMethodAllowNull": { "kind": "attribute", "displayName": "Strategy
Method Allow Null", "required": false, "type": "boolean", "javaType":
"java.lang.Boolean", "deprecated": false, "secret": false, "defaultValue":
false, "description": "If this option is false then the aggregate method is not
used if there was no data to enrich. If this option is true then null values is
used as the oldExchange (when no data to enrich), when using POJOs as the
AggregationStrategy" },
+ "executorServiceRef": { "kind": "attribute", "displayName": "Executor
Service Ref", "required": false, "type": "string", "javaType":
"java.lang.String", "deprecated": false, "secret": false, "description":
"Refers to a custom Thread Pool to be used for parallel processing. Notice if
you set this option, then parallel processing is automatic implied, and you do
not have to enable that option as well." },
+ "streaming": { "kind": "attribute", "displayName": "Streaming",
"required": false, "type": "boolean", "javaType": "java.lang.Boolean",
"deprecated": false, "secret": false, "defaultValue": false, "description":
"When in streaming mode, then the splitter splits the original message
on-demand, and each splitted message is processed one by one. This reduces
memory usage as the splitter do not split all the messages first, but then we
do not know the total size, and therefore the org.apa [...]
+ "stopOnException": { "kind": "attribute", "displayName": "Stop On
Exception", "required": false, "type": "boolean", "javaType":
"java.lang.Boolean", "deprecated": false, "secret": false, "defaultValue":
false, "description": "Will now stop further processing if an exception or
failure occurred during processing of an org.apache.camel.Exchange and the
caused exception will be thrown. Will also stop if processing the exchange
failed (has a fault message) or an exception was thrown and [...]
+ "timeout": { "kind": "attribute", "displayName": "Timeout", "required":
false, "type": "duration", "javaType": "java.lang.String", "deprecated": false,
"secret": false, "defaultValue": "0", "description": "Sets a total timeout
specified in millis, when using parallel processing. If the Splitter hasn't
been able to split and process all the sub messages within the given timeframe,
then the timeout triggers and the Splitter breaks out and continues. Notice if
you provide a TimeoutAware [...]
+ "onPrepareRef": { "kind": "attribute", "displayName": "On Prepare Ref",
"required": false, "type": "string", "javaType": "java.lang.String",
"deprecated": false, "secret": false, "description": "Uses the Processor when
preparing the org.apache.camel.Exchange to be send. This can be used to
deep-clone messages that should be send, or any custom logic needed before the
exchange is send." },
+ "shareUnitOfWork": { "kind": "attribute", "displayName": "Share Unit Of
Work", "required": false, "type": "boolean", "javaType": "java.lang.Boolean",
"deprecated": false, "secret": false, "defaultValue": false, "description":
"Shares the org.apache.camel.spi.UnitOfWork with the parent and each of the sub
messages. Splitter will by default not share unit of work between the parent
exchange and each splitted exchange. This means each splitted exchange has its
own individual unit of work." },
+ "parallelAggregate": { "kind": "attribute", "displayName": "Parallel
Aggregate", "required": false, "type": "boolean", "javaType":
"java.lang.Boolean", "deprecated": false, "secret": false, "defaultValue":
false, "description": "If enabled then the aggregate method on
AggregationStrategy can be called concurrently. Notice that this would require
the implementation of AggregationStrategy to be implemented as thread-safe. By
default this is false meaning that Camel synchronizes the cal [...]
+ "stopOnAggregateException": { "kind": "attribute", "displayName": "Stop On
Aggregate Exception", "required": false, "type": "boolean", "javaType":
"java.lang.Boolean", "deprecated": false, "secret": false, "defaultValue":
false, "description": "If enabled, unwind exceptions occurring at aggregation
time to the error handler when parallelProcessing is used. Currently,
aggregation time exceptions do not stop the route processing when
parallelProcessing is used. Enabling this option all [...]
+ "id": { "kind": "attribute", "displayName": "Id", "required": false,
"type": "string", "javaType": "java.lang.String", "deprecated": false,
"secret": false, "description": "Sets the id of this node" },
+ "description": { "kind": "element", "displayName": "Description",
"required": false, "type": "object", "javaType":
"org.apache.camel.model.DescriptionDefinition", "deprecated": false, "secret":
false, "description": "Sets the description of this node" }
}
}
diff --git
a/core/camel-core-model/src/main/java/org/apache/camel/model/ProcessorDefinition.java
b/core/camel-core-model/src/main/java/org/apache/camel/model/ProcessorDefinition.java
index 42651c3..2bb5f2c 100644
---
a/core/camel-core-model/src/main/java/org/apache/camel/model/ProcessorDefinition.java
+++
b/core/camel-core-model/src/main/java/org/apache/camel/model/ProcessorDefinition.java
@@ -1664,6 +1664,24 @@ public abstract class ProcessorDefinition<Type extends
ProcessorDefinition<Type>
* <a href="http://camel.apache.org/splitter.html">Splitter EIP:</a>
Creates a splitter allowing you split a message
* into a number of pieces and process them individually.
* <p>
+ * This splitter responds with the original input message. You can use a
custom {@link AggregationStrategy} to
+ * control what to respond from the splitter.
+ *
+ * @param expression the expression on which to split the message
+ * @param delimiter a custom delimiter to use
+ * @return the builder
+ */
+ public SplitDefinition split(Expression expression, String delimiter) {
+ SplitDefinition answer = new SplitDefinition(expression);
+ answer.setDelimiter(delimiter);
+ addOutput(answer);
+ return answer;
+ }
+
+ /**
+ * <a href="http://camel.apache.org/splitter.html">Splitter EIP:</a>
Creates a splitter allowing you split a message
+ * into a number of pieces and process them individually.
+ * <p>
* The splitter responds with the answer produced by the given {@link
AggregationStrategy}.
*
* @param expression the expression on which to split
diff --git
a/core/camel-core-model/src/main/java/org/apache/camel/model/SplitDefinition.java
b/core/camel-core-model/src/main/java/org/apache/camel/model/SplitDefinition.java
index 9be2914..b6dd618 100644
---
a/core/camel-core-model/src/main/java/org/apache/camel/model/SplitDefinition.java
+++
b/core/camel-core-model/src/main/java/org/apache/camel/model/SplitDefinition.java
@@ -43,6 +43,9 @@ public class SplitDefinition extends OutputExpressionNode
implements ExecutorSer
@XmlTransient
private ExecutorService executorService;
@XmlAttribute
+ @Metadata(defaultValue = ",")
+ private String delimiter;
+ @XmlAttribute
@Metadata(javaType = "java.lang.Boolean")
private String parallelProcessing;
@XmlAttribute
@@ -107,6 +110,19 @@ public class SplitDefinition extends OutputExpressionNode
implements ExecutorSer
//
-------------------------------------------------------------------------
/**
+ * Delimiter used in splitting messages. Can be turned off using the value
<tt>false</tt>.
+ * <p/>
+ * The default value is ,
+ *
+ * @param delimiter the delimiter
+ * @return the builder
+ */
+ public SplitDefinition delimiter(String delimiter) {
+ setDelimiter(delimiter);
+ return this;
+ }
+
+ /**
* Sets the AggregationStrategy to be used to assemble the replies from
the splitted messages, into a single
* outgoing message from the Splitter. By default Camel will use the
original incoming message to the splitter
* (leave it unchanged). You can also use a POJO as the AggregationStrategy
@@ -517,6 +533,14 @@ public class SplitDefinition extends OutputExpressionNode
implements ExecutorSer
super.setExpression(expression);
}
+ public String getDelimiter() {
+ return delimiter;
+ }
+
+ public void setDelimiter(String delimiter) {
+ this.delimiter = delimiter;
+ }
+
public AggregationStrategy getAggregationStrategy() {
return aggregationStrategy;
}
diff --git
a/core/camel-core-processor/src/main/java/org/apache/camel/processor/Splitter.java
b/core/camel-core-processor/src/main/java/org/apache/camel/processor/Splitter.java
index 8efa0c7..9fa58f7 100644
---
a/core/camel-core-processor/src/main/java/org/apache/camel/processor/Splitter.java
+++
b/core/camel-core-processor/src/main/java/org/apache/camel/processor/Splitter.java
@@ -42,6 +42,7 @@ import
org.apache.camel.processor.aggregate.UseOriginalAggregationStrategy;
import org.apache.camel.support.ExchangeHelper;
import org.apache.camel.support.ObjectHelper;
import org.apache.camel.util.IOHelper;
+import org.apache.camel.util.StringHelper;
import static org.apache.camel.util.ObjectHelper.notNull;
@@ -51,7 +52,9 @@ import static org.apache.camel.util.ObjectHelper.notNull;
*/
public class Splitter extends MulticastProcessor implements AsyncProcessor,
Traceable {
+ private static final String IGNORE_DELIMITER_MARKER = "false";
private final Expression expression;
+ private final String delimiter;
public Splitter(CamelContext camelContext, Route route, Expression
expression, Processor destination,
AggregationStrategy aggregationStrategy, boolean
parallelProcessing,
@@ -60,7 +63,17 @@ public class Splitter extends MulticastProcessor implements
AsyncProcessor, Trac
boolean useSubUnitOfWork, boolean parallelAggregate) {
this(camelContext, route, expression, destination,
aggregationStrategy, parallelProcessing, executorService,
shutdownExecutorService, streaming, stopOnException, timeout,
- onPrepare, useSubUnitOfWork, parallelAggregate, false);
+ onPrepare, useSubUnitOfWork, parallelAggregate, false, ",");
+ }
+
+ public Splitter(CamelContext camelContext, Route route, Expression
expression, Processor destination,
+ AggregationStrategy aggregationStrategy, boolean
parallelProcessing,
+ ExecutorService executorService, boolean
shutdownExecutorService, boolean streaming,
+ boolean stopOnException, long timeout, Processor onPrepare,
+ boolean useSubUnitOfWork, boolean parallelAggregate,
String delimiter) {
+ this(camelContext, route, expression, destination,
aggregationStrategy, parallelProcessing, executorService,
+ shutdownExecutorService, streaming, stopOnException, timeout,
+ onPrepare, useSubUnitOfWork, parallelAggregate, false, delimiter);
}
public Splitter(CamelContext camelContext, Route route, Expression
expression, Processor destination,
@@ -72,6 +85,22 @@ public class Splitter extends MulticastProcessor implements
AsyncProcessor, Trac
shutdownExecutorService, streaming, stopOnException,
timeout, onPrepare, useSubUnitOfWork, parallelAggregate,
stopOnAggregateException);
this.expression = expression;
+ this.delimiter = ",";
+ notNull(expression, "expression");
+ notNull(destination, "destination");
+ }
+
+ public Splitter(CamelContext camelContext, Route route, Expression
expression, Processor destination,
+ AggregationStrategy aggregationStrategy, boolean
parallelProcessing,
+ ExecutorService executorService, boolean
shutdownExecutorService, boolean streaming,
+ boolean stopOnException, long timeout, Processor onPrepare,
+ boolean useSubUnitOfWork, boolean parallelAggregate,
boolean stopOnAggregateException, String delimiter) {
+ super(camelContext, route, Collections.singleton(destination),
aggregationStrategy, parallelProcessing, executorService,
+ shutdownExecutorService, streaming, stopOnException,
+ timeout, onPrepare, useSubUnitOfWork, parallelAggregate,
stopOnAggregateException);
+ this.expression = expression;
+ StringHelper.notEmpty(delimiter, "delimiter");
+ this.delimiter = delimiter;
notNull(expression, "expression");
notNull(destination, "destination");
}
@@ -153,7 +182,13 @@ public class Splitter extends MulticastProcessor
implements AsyncProcessor, Trac
private SplitterIterable(Exchange exchange, Object value) {
this.original = exchange;
this.value = value;
- this.iterator = ObjectHelper.createIterator(value);
+
+ if (delimiter != null &&
IGNORE_DELIMITER_MARKER.equalsIgnoreCase(delimiter)) {
+ this.iterator = ObjectHelper.createIterator(value, null);
+ } else {
+ this.iterator = ObjectHelper.createIterator(value, delimiter);
+ }
+
this.copy = copyAndPrepareSubExchange(exchange, true);
this.route = ExchangeHelper.getRoute(exchange);
}
diff --git
a/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/SplitReifier.java
b/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/SplitReifier.java
index 2e7e753..03dd7c6 100644
---
a/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/SplitReifier.java
+++
b/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/SplitReifier.java
@@ -59,11 +59,20 @@ public class SplitReifier extends
ExpressionReifier<SplitDefinition> {
Expression exp = createExpression(definition.getExpression());
- Splitter answer = new Splitter(
- camelContext, route, exp, childProcessor,
definition.getAggregationStrategy(), isParallelProcessing, threadPool,
- shutdownThreadPool, isStreaming, isStopOnException, timeout,
definition.getOnPrepare(), isShareUnitOfWork,
- isParallelAggregate,
- isStopOnAggregateException);
+ Splitter answer;
+ if (definition.getDelimiter() != null) {
+ answer = new Splitter(
+ camelContext, route, exp, childProcessor,
definition.getAggregationStrategy(), isParallelProcessing,
+ threadPool, shutdownThreadPool, isStreaming,
isStopOnException, timeout, definition.getOnPrepare(),
+ isShareUnitOfWork, isParallelAggregate,
isStopOnAggregateException,
+ parseString(definition.getDelimiter()));
+ } else {
+ answer = new Splitter(
+ camelContext, route, exp, childProcessor,
definition.getAggregationStrategy(), isParallelProcessing,
+ threadPool, shutdownThreadPool, isStreaming,
isStopOnException, timeout, definition.getOnPrepare(),
+ isShareUnitOfWork, isParallelAggregate,
isStopOnAggregateException);
+ }
+
return answer;
}
diff --git
a/core/camel-core/src/test/java/org/apache/camel/processor/SplitWithDelimiterTest.java
b/core/camel-core/src/test/java/org/apache/camel/processor/SplitWithDelimiterTest.java
new file mode 100644
index 0000000..ec81f91
--- /dev/null
+++
b/core/camel-core/src/test/java/org/apache/camel/processor/SplitWithDelimiterTest.java
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.processor;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.junit.jupiter.api.Test;
+
+public class SplitWithDelimiterTest extends ContextTestSupport {
+
+ @Test
+ public void testSplitWithDelimiterDisabled() throws Exception {
+ String body = "some , # false text";
+ MockEndpoint m = getMockEndpoint("mock:result-0");
+ m.expectedPropertyReceived("CamelSplitSize", 1);
+ m.expectedBodiesReceived(body);
+ template.sendBody("direct:start-0", body);
+ m.assertIsSatisfied();
+ }
+
+ @Test
+ public void testSplitWithDefaultDelimiter() throws Exception {
+ String body = "some , # false text";
+ MockEndpoint m = getMockEndpoint("mock:result-1");
+ m.expectedPropertyReceived("CamelSplitSize", 2);
+ m.expectedBodiesReceived("some ", " # false text");
+ m.assertIsSatisfied();
+ }
+
+ @Test
+ public void testSplitWithDelimiter() throws Exception {
+ String body = "some , # false # text";
+ MockEndpoint m = getMockEndpoint("mock:result-2");
+ m.expectedPropertyReceived("CamelSplitSize", 3);
+ m.expectedBodiesReceived("some , ", " false ", " text");
+ template.sendBody("direct:start-2", body);
+ m.assertIsSatisfied();
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() {
+ return new RouteBuilder() {
+ @Override
+ public void configure() {
+ from("direct:start-0")
+ .split(body(), "false")
+ .to("mock:result-0");
+
+ from("direct:start-1")
+ .split(body())
+ .to("mock:result-1");
+
+ from("direct:start-2")
+ .split(body(), "#")
+ .to("mock:result-2");
+ }
+ };
+ }
+
+}
diff --git
a/core/camel-xml-io/src/generated/java/org/apache/camel/xml/in/ModelParser.java
b/core/camel-xml-io/src/generated/java/org/apache/camel/xml/in/ModelParser.java
index 433e123..0e96baf 100644
---
a/core/camel-xml-io/src/generated/java/org/apache/camel/xml/in/ModelParser.java
+++
b/core/camel-xml-io/src/generated/java/org/apache/camel/xml/in/ModelParser.java
@@ -1191,6 +1191,7 @@ public class ModelParser extends BaseParser {
protected SplitDefinition doParseSplitDefinition() throws IOException,
XmlPullParserException {
return doParse(new SplitDefinition(), (def, key, val) -> {
switch (key) {
+ case "delimiter": def.setDelimiter(val); break;
case "executorServiceRef": def.setExecutorServiceRef(val);
break;
case "onPrepareRef": def.setOnPrepareRef(val); break;
case "parallelAggregate": def.setParallelAggregate(val); break;