[
https://issues.apache.org/jira/browse/CAMEL-18485?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17603233#comment-17603233
]
Raymond commented on CAMEL-18485:
---------------------------------
ad 1) Nice
ad 2/3) I actually looked at the route reload, but there was something that I
missed or didn't work as expected (Can't recall what exactly), so I wrote my
own filewatch class and actually also use the ResourceHelper, but I was
thinking maybe we can skip it all and just pass a string to
loadOrUpdateRoute(String route) as a convenient method. Thus not a must have,
but just something convenient. But like you said, this maybe a bit too far from
normal use case to spend too much time on it.
> Error message when loading a routetemplate as resource
> ------------------------------------------------------
>
> Key: CAMEL-18485
> URL: https://issues.apache.org/jira/browse/CAMEL-18485
> Project: Camel
> Issue Type: Improvement
> Components: came-core
> Affects Versions: 3.18.1
> Environment: - JDK 11 (OpenJDK Temurin)
> - Windows 10
> - Camel 3.18.1
> Reporter: Raymond
> Assignee: Claus Ibsen
> Priority: Minor
> Fix For: 3.19.0
>
>
> I'm loading a xml routetemplate as resource as follows:
> {code:java}
> loader = extendedCamelContext.getRoutesLoader();
> Resource resource = IntegrationUtil.setResource(routetemplate);
> log.info("Loading routetemplate " + routetemplate);
> try{
> loader.loadRoutes(resource);
> }catch(java.lang.IllegalArgumentException e){
> loader.updateRoutes(resource);
> }
> {code}
> I however made a mistake and the resource was empty. The error
> message/stacktrace I received was:
> {code:java}
> Unable to parse resource: route.yaml
> at
> org.apache.camel.dsl.yaml.YamlRoutesBuilderLoaderSupport.lambda$doLoadRouteBuilder$1(YamlRoutesBuilderLoaderSupport.java:90)
> at java.base/java.util.Optional.orElseThrow(Optional.java:408)
> at
> org.apache.camel.dsl.yaml.YamlRoutesBuilderLoaderSupport.doLoadRouteBuilder(YamlRoutesBuilderLoaderSupport.java:90)
> at
> org.apache.camel.dsl.support.RouteBuilderLoaderSupport.loadRoutesBuilder(RouteBuilderLoaderSupport.java:104)
> at
> org.apache.camel.impl.engine.DefaultRoutesLoader.findRoutesBuilders(DefaultRoutesLoader.java:124)
> at
> org.apache.camel.spi.RoutesLoader.findRoutesBuilders(RoutesLoader.java:117)
> at org.apache.camel.spi.RoutesLoader.loadRoutes(RoutesLoader.java:72)
> {code}
> I was a bit puzzled about this because I was thinking I was providing a XML.
> Maybe better in this case:
> {code:java}
> Unable to parse resource: empty resource {code}
> The text also mentions 'route', but it can also be a routeConfiguration or a
> routeTemplate.
> Three sidenotes (some things I noticed):
> 1. In general one could check faulty input better. (is it a valid xml, yaml
> etc, or just some random text, empty or null). And for routetemplate are all
> the template parameters provide?
> 2. Notice in the example code I first need to create a resource before
> passing it to the routeloader. I have a string and would like to pass
> directly as a String to the routeloader.
> 3. When loading an existing route the routeloader may give an error (for
> example when the route already exist). I would like to
> loadOrUpdateRoute(String route) (this was possible in Camel 2).
--
This message was sent by Atlassian Jira
(v8.20.10#820010)