[ 
https://issues.apache.org/jira/browse/CAMEL-11249?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16017299#comment-16017299
 ] 

Nicola Ferraro commented on CAMEL-11249:
----------------------------------------

There's a limitation set by our own convention of putting a "SPLIT_COMPLETE" 
header (or also a "MULTICAST_COMPLETE" header) on the last element of the 
collection to be split.

If we want to extend splitting to asynchronous streams (like Flow/Publisher), 
that convention should be changed, because in a stream you know that the stream 
is finished when you receive a specific event. So when you emit an item, you 
know that it's the last if you receive (later) a stream close event... but you 
cannot wait indefinitely.

A dirty solution would be to process an element of the stream only when the 
subsequent event is received (that may be another element or the completion 
event).

Or.. introduce empty exchanges to signal such events?

> camel-core - Extend split() capabilities with pluggable splitters
> -----------------------------------------------------------------
>
>                 Key: CAMEL-11249
>                 URL: https://issues.apache.org/jira/browse/CAMEL-11249
>             Project: Camel
>          Issue Type: Improvement
>          Components: camel-core
>            Reporter: Nicola Ferraro
>            Assignee: Nicola Ferraro
>             Fix For: 2.20.0
>
>
> Currently a "split().body()" processor will work with a limited set of value 
> types.
> This is an excerpt from ObjectHelper.createIterator(value):
> {code}
>      * Creates an iterator over the value if the value is a collection, an
>      * Object[], a String with values separated by comma,
>      * or a primitive type array; otherwise to simplify the caller's code,
>      * we just create a singleton collection iterator over a single value
>      * <p/>
>      * Will default use comma for String separating String values.
>      * This method does <b>not</b> allow empty values
> {code}
> New libraries (reactive-streams, grpc, but also java 8 collections) make 
> heavy use of streams, not only standard java collections.
> In order to support a wide range of streams types, we can make the split 
> algorithm pluggable, e.g. by providing custom conversions from a specific 
> type to a "CamelStreamingObject" (tbd).
> This way we can convert any kind of streaming object (e.g. Publisher) into 
> its content by putting a ".split().body()". 
> In Camel 2.19.0, users should include a "UnwrapStreamProcessor" in their 
> routes to do this conversion.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Reply via email to