'Duplication of camel context mbeans after vetoed start

I have an application where I have custom lifecycle strategy for camel context start. This strategy has some logic which checked onCamelStart "event". Let's say it checks if cluster formed or not. If not, VetoCamelContextStartException thrown and thus context not started.

But I got warning with message like "clash of names for camel context" and name with prefix -n is used to register camel context into mbean server. Camel handle duplication in such a way As result I see couple of beans in jmx console.

DefaultManagementLifecycleStrategy is used to register mbeans (added in ManagmentStrategyFactory) and it can unmanage mbeans during onCamelStop.

As result I have next sequence of events which manifest into duplication of mbeans:

  • Start of Camel Context.
  • DefaultManagementLifecycleStrategy register all mbeans
  • CustomLifecycleStrategy puts the veto for start.
  • DefaultManagementLifecycleStrategy uregister all mbeans when onStop invoked.
  • Camel context marked as stopped.
  • Camel context is starting and registration of mbeans repeats.
  • Start of Camel context is vetoed again
  • Camel doesn't stop context due to it is already stopped (marked as stopped) and as result all mbeans are still in place.
  • Camel starts again and duplication of mbeans occurs.

We haven't seen such warning and duplication of mbeans in 2.17.7. Is it some bug in Camel? Or are we doing something wrong conceptually?

I have migrated Camel from 2.17.7 to 2.25.4. I am using Spring Boot and my camel context is defined in xml.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source