You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Marquis Wang (JIRA)" <ji...@apache.org> on 2019/07/17 20:53:00 UTC
[jira] [Updated] (CAMEL-13761) StartupListener runs before routes
are started, contrary to Javadoc
[ https://issues.apache.org/jira/browse/CAMEL-13761?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Marquis Wang updated CAMEL-13761:
---------------------------------
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):
{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).
was:
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-mwang2-pml-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).
> 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: Bug
> Components: came-core
> Affects Versions: 2.23.3
> Reporter: Marquis Wang
> Priority: Trivial
>
> 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)