简体   繁体   中英

Spring Integration: Autowiring Queues Failing when using JMX

I can autowire two QueueChannel instances using @Autowired and @Qualifier in a test class just fine, until I add JMX export namespace handlers.

I've not got the exact config handy (it was a problem at work that's now bugging me out of hours!), but I'm using these elements:

<int-jmx:mbean-export default-domain="com.business" server="mbeanServer" />
<context:mbean-export />
<context:mbean-server />

When I've got these three things defined, the autowiring process fails throwing a NoSuchBeanException . However, I can see that there are beans with the IDs of my queues, as I've got a post processor that's iterating over all beans in the context.

Is this something to do with proxying obfuscating the declared type of the QueueChannel s, preventing autowiring-by-type working?

You need to autowire using the interface instead of the concrete class because the JMX export wraps the channel in a proxy. Use PollableChannel for QueueChannel , or SubscribableChannel for DirectChannel .

It's always good practice to code using interfaces rather than concrete classes, for exactly this reason.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM