[ 
https://issues.apache.org/jira/browse/CAMEL-13761?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Claus Ibsen resolved CAMEL-13761.
---------------------------------
       Resolution: Fixed
         Assignee: Claus Ibsen
    Fix Version/s: 3.0.0.M5
                   3.0.0

I updated the javadoc

> StartupListener runs before routes are started, contrary to Javadoc
> -------------------------------------------------------------------
>
>                 Key: CAMEL-13761
>                 URL: https://issues.apache.org/jira/browse/CAMEL-13761
>             Project: Camel
>          Issue Type: Improvement
>          Components: came-core
>    Affects Versions: 2.23.3
>            Reporter: Marquis Wang
>            Assignee: Claus Ibsen
>            Priority: Trivial
>             Fix For: 3.0.0, 3.0.0.M5
>
>
> 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):
> {quote}This can be used to perform any custom work when the entire 
> [{{CamelContext}}|https://static.javadoc.io/org.apache.camel/camel-core/2.23.3/org/apache/camel/CamelContext.html]
>  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._
> {quote}
> However, routes are not started within the callback. The following code, for 
> example, 
> {code:java}
> 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();{code}
> fails with
> {code}
> 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
> {code}
> 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).



--
This message was sent by Atlassian JIRA
(v7.6.14#76016)

Reply via email to