Details
Description
The Javadoc (https://static.javadoc.io/org.apache.camel/camel-core/2.23.3/org/apache/camel/StartupListener.html) for StartupListener is misleading (italics for emphasis):
This can be used to perform any custom work when the entire CamelContext has been initialized and almost started. For example this ensures that all Camel routes have been started and are up and running, before this callback is invoked.
However, routes are not started within the callback. The following code, for example,
DefaultCamelContext context = new DefaultCamelContext(); context.addStartupListener((c, alreadyStarted) -> { c.createProducerTemplate().sendBody("direct:doesNotExistYet", new Object()); }); context.addRoutes(new RouteBuilder() { @Override public void configure() { from("direct:doesNotExistYet").bean((Consumer<Object>) System.out::println); } }); context.start();
fails with
Caused by: org.apache.camel.component.direct.DirectConsumerNotAvailableException: No consumers available on endpoint: direct://doesNotExistYet. Exchange[ID-x-1563396556957-0-1]
at org.apache.camel.component.direct.DirectProducer.process(DirectProducer.java:69)
at org.apache.camel.processor.SharedCamelInternalProcessor.process(SharedCamelInternalProcessor.java:186)
at org.apache.camel.processor.SharedCamelInternalProcessor.process(SharedCamelInternalProcessor.java:86)
at org.apache.camel.impl.ProducerCache$1.doInProducer(ProducerCache.java:541)
at org.apache.camel.impl.ProducerCache$1.doInProducer(ProducerCache.java:506)
at org.apache.camel.impl.ProducerCache.doInProducer(ProducerCache.java:369)
at org.apache.camel.impl.ProducerCache.sendExchange(ProducerCache.java:506)
at org.apache.camel.impl.ProducerCache.send(ProducerCache.java:229)
at org.apache.camel.impl.DefaultProducerTemplate.send(DefaultProducerTemplate.java:144)
at org.apache.camel.impl.DefaultProducerTemplate.sendBody(DefaultProducerTemplate.java:161)
... 12 more
I am aware that using ExtendedStartupListener or an EventNotifier makes this work, but it would be great if the Javadoc was updated (assuming this is intended behavior, I am not sure).