jamesnetherton opened a new issue, #9313:
URL: https://github.com/apache/camel-quarkus/issues/9313

   When the `camel-quarkus-management` extension is present, the 
`camel.main.jmxManagementNamePattern` option has no effect. The CamelContext 
management name is always the CamelContext name.
   
   ### Steps to reproduce
   
   1. Add `camel-quarkus-management` to an application
   2. Set the following in `application.properties`:
   
      ```properties
      camel.main.jmxManagementNamePattern = custom-#name#
      ```
   
   3. Start the application and inspect the Camel MBeans
   
   Expected: MBeans are registered under 
`org.apache.camel:context=custom-camel-1,...` and the `ManagementName` 
attribute of the context MBean is `custom-camel-1`.
   
   Actual: MBeans are registered under `org.apache.camel:context=camel-1,...` 
and `ManagementName` is `camel-1`.
   
   ### Cause
   
   `CamelManagementRecorder` explicitly sets the management name in its 
`CamelContextCustomizer`:
   
   ```java
   context.setManagementNameStrategy(new 
DefaultManagementNameStrategy(context));
   context.setManagementName(context.getName());
   ```
   
   `JmxManagementLifecycleStrategy.onContextStarting` only consults the 
`ManagementNameStrategy` (which is what applies the name pattern) when 
`context.getManagementName()` is `null`. Because the name is pre-set, the 
pattern is never resolved.
   
   The `setManagementName` call was added together with 
`setManagementNameStrategy` for #7522. Only the strategy is needed to fix that 
issue. Camel assigns the management name itself during context startup.
   
   ### Proposed fix
   
   Remove the `context.setManagementName(context.getName())` call and add test 
coverage for `camel.main.jmxManagementNamePattern`.
   
   With the default pattern (`#name#`) the resolved management name is 
unchanged. The only behaviour changes are:
   
   - Applications that set `camel.main.jmxManagementNamePattern` will have it 
honoured, so the `context=` key of their MBean `ObjectName`s will change.
   - If JMX is disabled, `CamelContext.getManagementName()` returns `null` 
instead of the CamelContext name, which matches plain Camel.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to