Skip to content

@EnableIntegrationMBeanExport can't override the auto-config, because of wrong order of classes processing #1451

@artembilan

Description

@artembilan

The sample is based on Spring Integration:

@Configuration
@EnableAutoConfiguration
@EnableIntegrationMBeanExport(defaultDomain = "foo.my")
public class Application {

    public static void main(String[] args) {
        SpringApplication.run(Application.class, args).close();
    }
}

The Boot logs show:

o.s.i.monitor.IntegrationMBeanExporter   : Located managed bean 'org.springframework.integration:type=MessageChannel,name=nullChannel': registering with JMX server as MBean [org.springframework.integration:type=MessageChannel,name=nullChannel]

However the test-case passes:

@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = Application.class)
public class ApplicationTests {

    @Autowired
    private IntegrationMBeanExporter integrationMBeanExporter;

    @Test
    public void contextLoads() {
        DirectFieldAccessor dfa = new DirectFieldAccessor(integrationMBeanExporter);
        assertEquals("foo.my", dfa.getPropertyValue("domain"));
    }

}

Reproducible on Boot 1.1.5.

Not sure what's going on, but it looks like @Conditional...s and any auto-config have to be appliend only after after any other custom configs and explicit @Enable... usage.

Suppose the same issue we have with any ...AutoConfiguration which is based on @Enable...

BTW, the same result I see, if I explicitly define:

@Bean
public IntegrationMBeanExporter mbeanExporter(MBeanServer mbeanServer) {
        IntegrationMBeanExporter exporter = new IntegrationMBeanExporter();
        exporter.setDefaultDomain("foo.my");
        exporter.setServer(mbeanServer);
        return exporter;
}

isntead of @EnableIntegrationMBeanExport

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions