At this moment we have monolith app where all mbeans are defined in single place. In future they will be migrated and placed in dedicated modules, each module will have their spring context definition.
Found @EnableMBeanExport(registration = RegistrationPolicy.IGNORE_EXISTING) useful for migration from original solution to a new approach. My spring version is 5.2.4
I wish to have control over mbeans export, but noticed from javadoc (AnnotationMBeanExporter) that by default using this annotation export ALL mbeans from spring context. It means that jmx configuration from module A will publish mbeans from other modules B or C, even mbeans from 3rd party libraries will be available.
I planned to set JMX configuration only on specific modules that would like to expose mbeans and not sure if:
have to change approach and place @EnableMBeanExport once, somewhere in main configuration
have to create a new annotation, that would change default process
add sth to annotation to activate it on specific module
See the javadocs for @EnableMBeanExport
.
* <p>The resulting {@link org.springframework.jmx.export.MBeanExporter MBeanExporter}
* bean is defined under the name "mbeanExporter". Alternatively, consider defining a
* custom {@link AnnotationMBeanExporter} bean explicitly.
*
So simply declare the AnnotationMBeanExporter
as a @Bean
and configure it to only register the beans you need.