Red Hat Training

A Red Hat training course is available for Red Hat Fuse

251.15. JVM システムプロパティーを使用したプロパティー設定のオーバーライド

Camel 2.5 以降で利用可能
変更を反映するためにアプリケーションを再起動しなくても、JVM システムプロパティーを使用して実行時にプロパティー値をオーバーライドできます。これは、新しい値に置き換えるプロパティーと同じ名前の JVM システムプロパティーを作成することにより、コマンドラインから実行することもできます。この例を以下に示します

PropertiesComponent pc = context.getComponent("properties", PropertiesComponent.class);
pc.setCache(false);

System.setProperty("cool.end", "mock:override");
System.setProperty("cool.result", "override");

context.addRoutes(new RouteBuilder() {
    @Override
    public void configure() throws Exception {
        from("direct:start").to("properties:cool.end");
        from("direct:foo").to("properties:mock:{{cool.result}}");
    }
});
context.start();

getMockEndpoint("mock:override").expectedMessageCount(2);

template.sendBody("direct:start", "Hello World");
template.sendBody("direct:foo", "Hello Foo");

System.clearProperty("cool.end");
System.clearProperty("cool.result");

assertMockEndpointsSatisfied();