diff --git a/modules/jooby-camel/src/main/java/io/jooby/camel/CamelModule.java b/modules/jooby-camel/src/main/java/io/jooby/camel/CamelModule.java index c47725b54d..e6f696ad3a 100644 --- a/modules/jooby-camel/src/main/java/io/jooby/camel/CamelModule.java +++ b/modules/jooby-camel/src/main/java/io/jooby/camel/CamelModule.java @@ -17,9 +17,11 @@ import org.apache.camel.builder.RouteBuilder; import org.apache.camel.impl.DefaultCamelContext; import org.apache.camel.main.SimpleMain; +import org.apache.camel.spi.EventNotifier; import io.jooby.Extension; import io.jooby.Jooby; +import io.jooby.Reified; import io.jooby.ServiceRegistry; import io.jooby.internal.camel.JoobyCamelContext; import io.jooby.internal.camel.SingletonProvider; @@ -157,6 +159,14 @@ public void install(Jooby application) throws Exception { application.onStarting( () -> { + // dump configuration as initial properties, enabled camel auto-configuration + var config = application.getConfig(); + if (config.hasPath("camel")) { + for (var prop : config.getConfig("camel").entrySet()) { + main.addInitialProperty( + "camel." + prop.getKey(), prop.getValue().unwrapped().toString()); + } + } // build camel main.init(); @@ -167,6 +177,14 @@ public void install(Jooby application) throws Exception { camel.addRoutes(route); } } + // Do events + Reified> eventType = Reified.list(EventNotifier.class); + var events = application.getServices().getOrNull(eventType); + if (events != null) { + for (var event : events) { + camel.getManagementStrategy().addEventNotifier(event); + } + } // Start camel: main.start(); });