You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Federico Mariani (Jira)" <ji...@apache.org> on 2021/12/10 14:07:00 UTC

[jira] [Commented] (CAMEL-17310) maven camel:run - Add option for route reload

    [ https://issues.apache.org/jira/browse/CAMEL-17310?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17457164#comment-17457164 ] 

Federico Mariani commented on CAMEL-17310:
------------------------------------------

Hi [~davsclaus] , I don't know if it is the right approach but I noticed something strange when reloading camel routes, I added the following Mojo
 
{code:java}
@Mojo(name = "dev", defaultPhase = LifecyclePhase.PREPARE_PACKAGE,
requiresDependencyResolution = ResolutionScope.COMPILE_PLUS_RUNTIME)
public class DevMojo extends RunMojo {

/**
* To watch the directory for file changes which triggers a live reload of the Camel routes on-the-fly.
*/
@Parameter(property = "camel.fileWatcherDirectory")
private String fileWatcherDirectory;

/**
* Enable route reloading
*
* @throws Exception
*/
protected void beforeBootstrapCamel() throws Exception {
    System.setProperty("camel.main.routesReloadEnabled", "true");
    System.setProperty("camel.main.routesReloadDirectory", fileWatcherDirectory);
    System.setProperty("camel.main.durationMaxAction", "stop");
    System.setProperty("camel.main.routesReloadPattern",
        "*.xml,*.yaml,*.java");
}

}
{code}

and I tested it with [https://github.com/apache/camel-examples/tree/main/examples/routeloader] and the following command _mvn clean compile && mvn camel:dev -Dcamel.fileWatcherDirectory=src/main/resources/myroutes_, after route is reloaded the old one is not stopped, as you can see from logs:
{code:java}
15:03:11.818 [Camel (MyJavaLoader) thread #7 - timer://xml] INFO  route4 - I am XML
15:03:11.828 [Camel (MyJavaLoader) thread #7 - timer://xml] INFO  route7 - I am XML new route
{code}

before reload I had only 1 xml route
{code:java}
15:03:04.352 [Camel (MyJavaLoader) thread #2 - timer://xml] INFO  route1 - I am XML
{code}

> maven camel:run - Add option for route reload
> ---------------------------------------------
>
>                 Key: CAMEL-17310
>                 URL: https://issues.apache.org/jira/browse/CAMEL-17310
>             Project: Camel
>          Issue Type: New Feature
>          Components: tooling
>            Reporter: Claus Ibsen
>            Priority: Major
>             Fix For: 3.15.0
>
>
> Like we have with camel-jbang and its --reload option, then we can have something similar for mvn camel:run - however we could also consider naming it mvn camel:dev



--
This message was sent by Atlassian Jira
(v8.20.1#820001)