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: route <-> XML <-> route
Date Tue, 26 May 2015 07:19:28 GMT
Hi

Yeah <bean>

On Tue, May 26, 2015 at 9:02 AM, Tim Dudgeon <tdudgeon.ml@gmail.com> wrote:
> Yes, but how to specify the bean that is referenced? Can that be specified
> in the XML using a bean element as if it was being using on startup, or does
> it need to be added to the registry "manually"?
>
> Tim
>
>
> On 26/05/2015 07:49, Claus Ibsen wrote:
>>
>> On Mon, May 25, 2015 at 3:01 PM, Tim Dudgeon <tdudgeon.ml@gmail.com>
>> wrote:
>>>
>>> Hi,
>>>
>>> I'm wanting some guidance on how to generate a route definition using the
>>> API in a way that allows it to be converted to XML and then executed.
>>> I've
>>> got the basics sorted, but struggling on how to handle processors and
>>> beans.
>>> For instance, if I generate a route like this:
>>>
>>> // generate the route
>>> RoutesDefinition routes1 = new RoutesDefinition()
>>> RouteDefinition route = routes1.route()
>>> route.from("timer://foo?fixedRate=true&period=200")
>>> route.log("Hello World!")
>>> route.process(new SimpleProcessor())
>>>
>>> // set route to context
>>> CamelContext camelContext = new DefaultCamelContext()
>>> camelContext.start()
>>> camelContext.addRouteDefinitions(routes1.getRoutes())
>>>
>>> Then the route works fine (e.g. my SimpleProcessor gets called as
>>> expected).
>>> But if I generate the XML definition of the route it looks like this:
>>>
>>> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
>>> <routes xmlns="http://camel.apache.org/schema/spring">
>>> <route>
>>> <from uri="timer://foo?fixedRate=true&amp;period=200"/>
>>> <log message="Hello World!"/>
>>> <process/>
>>> </route>
>>> </routes>
>>>
>>> e.g. the processor definition has been lost.
>>> I suspect I need to register the processor bean with the registry and use
>>> the processRef() method on the route, or something along those lines.
>>> Does anyone have any examples of how to handle this?
>>>
>> Yes for representing this as xml, you would need to use a ref for the
>> processor
>>
>>
>>
>>> Thanks
>>> Tim
>>
>>
>>
>



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
hawtio: http://hawt.io/
fabric8: http://fabric8.io/

Mime
View raw message