Hi,

Instead of splitting ImageCollection as the body, I think you just need to
split List<SingleImageModel> as the body.

On Wed, Dec 20, 2017 at 7:50 AM, Charles Berger <
charlesb.yesm...@googlemail.com> wrote:

> Hi,
>
> I'm building my first application using Camel and have a question
> about how to use a splitter.
>
> My route receives a serialized Java class which contains a private
> ArrayList of a POJO and getter and setter methods for the list.
>
> I convert the serialized class into a its Java representation and then
> apply it to a splitter.  What I want to get out of the Splitter is
> each individual instance of the POJOs in the List but what I get
> instead is the complete list.
>
> Here is some code to show what I mean
>
> public class ImageCollection {
>
> private List<SingleImageModel> images = new ArrayList<SingleImageModel>();
>
> public void setImages(List) { ... }
>
> public List getImages() { }
>
> }
>
> public class SingleImageModel {
>
> members ...
>
> getters & setters
>
> }
>
> Routes:
>
> The first route accepts a POST from a servlet, validates the incoming
> payload and converts it into an instance of ImageCollection, which is
> dispatched to the requestQueue, then returns a response to the client.
>
>         from("servlet:uploadUrl")
>         .log("Request: ${body}")
>         .to("bean:uploadRequestQueue")
>         .log("${body}")
>         .marshal().json(JsonLibrary.Jackson)
>         .wireTap("activemq:requestQueue")
>         .to("bean:formatResponse")
>         .end()
>
>
> The second route is supposed to take the ImageCollection and split it
> into the SingleImageModel instances
>
>
>         from("activemq:requestQueue")
>         .convertBodyTo(ImageCollection.class)
>         .log("${body}")
>         .split(bodyAs(ImageCollection.class))
>         .log("${body}")
>         .to("bean:downloadImageQueue")
>         .marshal().json(JsonLibrary.Jackson)
>         .to("activemq:ftpQueue");
>
> I think I need to use an Aggregator to return the individual instances
> of the SingleImageModel class from the list inside ImageCollection,
> but I can't work out what that should do.
>
> Instead, what is happening is that the bean registered for the
> downloadImageQueue is receiving an instance of ImageCollection when it
> expects an instance of SingleImageModel and the type conversion in
> that bean is failing.
>
> Any guidance much appreciated.
>
> Thanks,
>
> Charles.
>

Reply via email to