camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Claus Ibsen <claus.ib...@gmail.com>
Subject Re: CastException error when using choice in a route
Date Fri, 23 Nov 2012 08:13:44 GMT
On Thu, Nov 22, 2012 at 8:17 PM, Florian B.
<florian.bernstein@isar-software.com> wrote:
> Hi I'm trying to setup some routes to handle an import from different csv
> files to a database. First I defined a single route for each file but I
> thought it should be easier and be more flexible when I try to split
> everything up to have some routes which can be used for different files.
>
> Here are the routes I defined till now. That are not all routes. At the
> moment I just setup up two routes to see how it works.
>
> CsvDataFormat csv = new CsvDataFormat();
> csv.setDelimiter(";");
>
> from("file://data?doneFileName=${file:name}.done").noAutoStartup()
>     .choice()
>
> .when(header("CamelFileNameOnly").isEqualTo("import_organization.csv"))
>             .to("direct:csv_organization_in")
>         .when(header("CamelFileNameOnly").isEqualTo("import_user.csv"))
>             .to("direct:csv_user_in")
>    .endChoice().setId("route_pickup_file");
>

Try with using .routeId to set id of the route.

 from("file://data?doneFileName=${file:name}.done").noAutoStartup().routeId("route_pickup_file")
     .choice()
 .when(header("CamelFileNameOnly").isEqualTo("import_organization.csv"))
             .to("direct:csv_organization_in")
         .when(header("CamelFileNameOnly").isEqualTo("import_user.csv"))
             .to("direct:csv_user_in");


> from("direct:csv_organization_in").noAutoStartup().unmarshal(csv)
>     .bean(msdOrganizationConverter, "convert")
> .to(YsuraImportRouteBuilder.ENDPOINT_DIRECT_IMPORT_YSURA_OBJECTS_IN_DB).setId("route_import_organization");
>
>
> When I start up the routes I got following exception:
>
> java.lang.ClassCastException: org.apache.camel.model.RouteDefinition cannot
> be cast to org.apache.camel.model.ChoiceDefinition
>         at
> org.apache.camel.model.ProcessorDefinition.endChoice(ProcessorDefinition.java:1237)
> ~[camel-core-2.10.2.jar:2.10.2]
>         at
> com.isarsoftware.ysura.model.integration.msd.MsdImportRouteBuilder.configure(MsdImportRouteBuilder.java:50)
> ~[ysura-integration-0.0.1.jar:na]
> ....
>
> I've also tried to append a .end() to each of the choices, but then I got an
> error on the second when(): The method when(Predicate) is undefined for the
> type ProcessorDefinition<capture#1-of ?
>  >
>
> Any ideas what I'm doing wrong?
>
> Best Regards,
> Florian
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/CastException-error-when-using-choice-in-a-route-tp5723125.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
FuseSource is now part of Red Hat
Email: cibsen@redhat.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Mime
View raw message