Re: Load route from a yaml in an embedded Camel
Hi Yes its the location that has the file name, and the extension determines if its xml or yaml, etc. So make sure getLocation returns a name ala myname.yaml On Sat, Aug 19, 2023 at 8:26 PM Fyodor Kravchenko wrote: > Thank you, I see the RoutesLoader loads the routes obtained by the > ResourceLoader#resolveResource method, which can load for example a file. > > I need to feed a "dynamically" generated InputStream to the loader. I'm > guessing I might have to implement my own > org.apache.camel.spi.Resource to provide the stream/reader, but > looking at the Resource api I'm failing to understand how do I signal > the loader that it is a "yaml" character sequence and that the location > might be fake. Should the getLocation() return something ending in > ".yaml" and how free am I to invent what a getScheme() method returns? > > /fedd > > On 18.08.2023 14:15, Claus Ibsen wrote: > > Hi > > > > Yes you can use RoutesLoader to load routes from whatever resource, and > > whatever DSL. > > > > See PluginHelper to get hold of RoutesLoader. > > > > > > On Fri, Aug 18, 2023 at 9:06 AM Fyodor Kravchenko > wrote: > > > >> Hello, > >> > >> coudn't find it in the docs... what is the official/semi-official API to > >> load a route definition in a yaml format into the embedded Camel > Context? > >> > >> I tried to use camel-main to load them from files but I wanted to have > >> more flexibility as camel-main adds a seemingly unneeded extra layer and > >> to tweak it I anyway had to dive into the source to see how exactly it > >> loads/reloads the routes stored in the file resources. I see the piece > >> of code that loads the route in the RouteWatcherReloadStrategy and can > >> try to hack it out but I'd like to have it more official and also be > >> sure it survives the upgrade from my current 3.20.4 to, say, Camel 4. > >> Ideally it should work with a non-file streams as I generate the route > >> definitions from another snippet. I will provide the id and other > >> metadata if needed. > >> > >> Thank you! > >> > >> > -- Claus Ibsen - @davsclaus Camel in Action 2: https://www.manning.com/ibsen2
Re: Load route from a yaml in an embedded Camel
Thank you, I see the RoutesLoader loads the routes obtained by the ResourceLoader#resolveResource method, which can load for example a file. I need to feed a "dynamically" generated InputStream to the loader. I'm guessing I might have to implement my own org.apache.camel.spi.Resource to provide the stream/reader, but looking at the Resource api I'm failing to understand how do I signal the loader that it is a "yaml" character sequence and that the location might be fake. Should the getLocation() return something ending in ".yaml" and how free am I to invent what a getScheme() method returns? /fedd On 18.08.2023 14:15, Claus Ibsen wrote: Hi Yes you can use RoutesLoader to load routes from whatever resource, and whatever DSL. See PluginHelper to get hold of RoutesLoader. On Fri, Aug 18, 2023 at 9:06 AM Fyodor Kravchenko wrote: Hello, coudn't find it in the docs... what is the official/semi-official API to load a route definition in a yaml format into the embedded Camel Context? I tried to use camel-main to load them from files but I wanted to have more flexibility as camel-main adds a seemingly unneeded extra layer and to tweak it I anyway had to dive into the source to see how exactly it loads/reloads the routes stored in the file resources. I see the piece of code that loads the route in the RouteWatcherReloadStrategy and can try to hack it out but I'd like to have it more official and also be sure it survives the upgrade from my current 3.20.4 to, say, Camel 4. Ideally it should work with a non-file streams as I generate the route definitions from another snippet. I will provide the id and other metadata if needed. Thank you!
Re: Load route from a yaml in an embedded Camel
Hi Yes you can use RoutesLoader to load routes from whatever resource, and whatever DSL. See PluginHelper to get hold of RoutesLoader. On Fri, Aug 18, 2023 at 9:06 AM Fyodor Kravchenko wrote: > Hello, > > coudn't find it in the docs... what is the official/semi-official API to > load a route definition in a yaml format into the embedded Camel Context? > > I tried to use camel-main to load them from files but I wanted to have > more flexibility as camel-main adds a seemingly unneeded extra layer and > to tweak it I anyway had to dive into the source to see how exactly it > loads/reloads the routes stored in the file resources. I see the piece > of code that loads the route in the RouteWatcherReloadStrategy and can > try to hack it out but I'd like to have it more official and also be > sure it survives the upgrade from my current 3.20.4 to, say, Camel 4. > Ideally it should work with a non-file streams as I generate the route > definitions from another snippet. I will provide the id and other > metadata if needed. > > Thank you! > > -- Claus Ibsen - @davsclaus Camel in Action 2: https://www.manning.com/ibsen2
Load route from a yaml in an embedded Camel
Hello, coudn't find it in the docs... what is the official/semi-official API to load a route definition in a yaml format into the embedded Camel Context? I tried to use camel-main to load them from files but I wanted to have more flexibility as camel-main adds a seemingly unneeded extra layer and to tweak it I anyway had to dive into the source to see how exactly it loads/reloads the routes stored in the file resources. I see the piece of code that loads the route in the RouteWatcherReloadStrategy and can try to hack it out but I'd like to have it more official and also be sure it survives the upgrade from my current 3.20.4 to, say, Camel 4. Ideally it should work with a non-file streams as I generate the route definitions from another snippet. I will provide the id and other metadata if needed. Thank you!