Christoph Ewerlin created CAMEL-23023:
-----------------------------------------

             Summary: CamelContext Startup behavior interfers with Spring 
Lifecycle
                 Key: CAMEL-23023
                 URL: https://issues.apache.org/jira/browse/CAMEL-23023
             Project: Camel
          Issue Type: Bug
          Components: camel-spring
    Affects Versions: 4.8.7
            Reporter: Christoph Ewerlin


SpringCamelContext registers to ApplicationEvent "ContextRefreshed" and then 
starts the CamelContext, see SpringCamelContext::onApplicationEvent.

There is also a comment saying that 
{code:java}
// nominally we would prefer to use Lifecycle interface that
// would invoke start() method, but in order to do that
// SpringCamelContext needs to implement SmartLifecycle
// (look at DefaultLifecycleProcessor::startBeans), but it
// cannot implement it as it already implements
// RuntimeConfiguration, and both SmartLifecycle and
// RuntimeConfiguration declare isAutoStartup method but
// with boolean and Boolean return types, and covariant
// methods with primitive types are not allowed by the JLS
// so we need to listen for ContextRefreshedEvent and start
// on its reception {code}
The problem with that is, that for instance KafkaConsumers are started as part 
of the lifecycle before the CamelContext is starting, which in our case results 
in messages being consumed and delegated to a camel route, before the context 
is started -> exception, message loss.

The ideal behavior would be that the camel context is started BEFORE the kafka 
listeners start to fire.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to