Hi No you cannot - you mix standard Java with Camel "parsing" the model when it calls the configure() method. It would be the same in regular Camel route. You basically do standard Java code with a new constructor and pass in a string literal. Camel is not in use at that point.
In your template bean example, then you need to use {{MyProcessor}} as the bean name. See the IMPORTANT note at: https://camel.apache.org/manual/route-template.html#_binding_beans_to_route_template On Thu, Sep 8, 2022 at 11:53 AM ski n <raymondmees...@gmail.com> wrote: > Hi, > > I have a routetemplate as follows: > > routeTemplate("processortemplate") > .templateParameter("out") > .from("direct:in") > .process("MyProcessor") > .to("{{out}}"); > > This works. > > The processor is registered an the called by reference. Now I added a > constructor argument to the processor and I tried to call it like this: > > routeTemplate("processortemplate") > .templateParameter("processerParam") > .templateParameter("out") > .from("direct:in") > .process(new MyProcessor("{{processorParam}}")) > .to("{{out}}"); > > This doesn't work, because the parameter of the processor is parsed before > the template parameter is parsed. Result is that the parameter > {{myProcessorParam}} is passed as literal param. > > I tried to come with up something like this: > > routeTemplate("processortemplate") > .templateParameter("processerparam") > .templateParameter("out") > .templateBean("MyProcessor") > .typeClass("com.foo.MyProcessor") > .property("processerparam", "{{processerparam}}") > .end() > .from("direct:in") > .to("bean:MyProcessor?method=process") > .to("{{out}}"); > > But this didn't pass the parameter as well. As a workaround I set > constructor argument as a header and then get the header within the > processor. > > Question: > > Is there a way to pass constructor arguments to a processor in another way? > I couldn't find anything at the routeTemplate page on how to handle > processors. > > Raymond > -- Claus Ibsen ----------------- http://davsclaus.com @davsclaus Camel in Action 2: https://www.manning.com/ibsen2