Skip to content

Commit

Permalink
CAMEL-21338: camel-core - Add boot startup time in INFO logging so it…
Browse files Browse the repository at this point in the history
… show the total time incl boot camel-jbang/camel-main/camel-spring-boot that may take some time also.
  • Loading branch information
davsclaus committed Oct 12, 2024
1 parent 6423dbf commit 8f8ff42
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2749,7 +2749,7 @@ protected void logStartSummary() {
}
}
String msg = String.format("Apache Camel %s (%s) started in %s (build:%s init:%s start:%s", getVersion(),
camelContextExtension.getName(), total, built, init, start);
camelContextExtension.getName(), total, built, init, start);
if (boot != null) {
msg += " boot:" + boot;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -739,19 +739,25 @@ protected void postProcessCamelContext(CamelContext camelContext) throws Excepti
// ensure camel context is build
camelContext.build();

for (MainListener listener : listeners) {
listener.beforeInitialize(this);
}

// allow doing custom configuration before camel is started
for (MainListener listener : listeners) {
listener.beforeConfigure(this);
}

// we want to capture startup events for import tasks during main bootstrap
StartupStepRecorder recorder = camelContext.getCamelContextExtension().getStartupStepRecorder();
StartupStep step;

if (!listeners.isEmpty()) {
step = recorder.beginStep(BaseMainSupport.class, "beforeInitialize", "MainListener");
for (MainListener listener : listeners) {
listener.beforeInitialize(this);
}
recorder.endStep(step);

// allow doing custom configuration before camel is started
step = recorder.beginStep(BaseMainSupport.class, "beforeConfigure", "MainListener");
for (MainListener listener : listeners) {
listener.beforeConfigure(this);
}
recorder.endStep(step);
}

if (standalone) {
step = recorder.beginStep(BaseMainSupport.class, "autoconfigure", "Auto Configure");
autoconfigure(camelContext);
Expand All @@ -774,11 +780,13 @@ protected void postProcessCamelContext(CamelContext camelContext) throws Excepti
postProcessCamelRegistry(camelContext, mainConfigurationProperties);

// allow doing custom configuration before camel is started
step = recorder.beginStep(BaseMainSupport.class, "afterConfigure", "MainListener");
for (MainListener listener : listeners) {
listener.afterConfigure(this);
if (!listeners.isEmpty()) {
step = recorder.beginStep(BaseMainSupport.class, "afterConfigure", "MainListener");
for (MainListener listener : listeners) {
listener.afterConfigure(this);
}
recorder.endStep(step);
}
recorder.endStep(step);

// we want to log the property placeholder summary after routes has been started,
// but before camel context logs that it has been started, so we need to use an event listener
Expand Down
2 changes: 0 additions & 2 deletions core/camel-main/src/main/java/org/apache/camel/main/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@

import org.apache.camel.CamelConfiguration;
import org.apache.camel.CamelContext;
import org.apache.camel.ContextEvents;
import org.apache.camel.ProducerTemplate;
import org.apache.camel.clock.EventClock;
import org.apache.camel.impl.DefaultCamelContext;
import org.apache.camel.spi.Registry;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,9 @@
import org.apache.camel.ContextEvents;
import org.apache.camel.ProducerTemplate;
import org.apache.camel.clock.Clock;
import org.apache.camel.clock.ContextClock;
import org.apache.camel.spi.EventNotifier;
import org.apache.camel.support.ResetableClock;
import org.apache.camel.support.service.ServiceHelper;
import org.apache.camel.util.StopWatch;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down

0 comments on commit 8f8ff42

Please sign in to comment.