Hi

Yes if you do manual stuff like this that are out of the ordinary,
then you need to wait until camel context is started to add your
custom routes.


On Tue, May 10, 2022 at 10:58 AM Martin Lichtin
<lich...@yahoo.com.invalid> wrote:
>
> Is there potentially a race condition when calling addRoutes while
> camelContext status is 'Initializing'?
>
> I noticed the routes are not actually added in such a case, but no error
> or warning appears, they're just silently ignored.
>
> Creating the CamelContext with blueprint, then adding the routes in the
> bean, like:
>
>    <camelContext id="myCamelContext"
> xmlns="http://camel.apache.org/schema/blueprint";
>      xsi:schemaLocation="http://camel.apache.org/schema/blueprint
> http://camel.apache.org/schema/blueprint/camel-blueprint.xsd";>
>      <template id="producerTemplate" />
>    </camelContext>
>
>    <bean id="myBean" class="MyBean" init-method="init">
>      <property name="camelContext" ref="myCamelContext" />
>      <property name="producerTemplate" ref="producerTemplate" />
>    </bean>
>
> Seems basic and it works in 2.x so wondering what has changed.
> Workaround is to poll and wait for CamelContext to be in Started state.
>
> BaseService uses a 'lock' during initialization but that's not in use
> when adding routes.
>


-- 
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2

Reply via email to