Java 使用ControlBus发送消息以打开Spring集成入站适配器时出错

Java 使用ControlBus发送消息以打开Spring集成入站适配器时出错,java,spring,spring-integration,Java,Spring,Spring Integration,这是我第一次尝试使用ControlBus打开/关闭入站通道适配器 为了简单起见,我通过将一个空文件写入入站文件适配器监视的目录来发送控制消息(此文件一直处于打开状态),然后将其路由到服务激活器,该服务激活器将打开/关闭其他入站适配器 <int:channel id="controlBusChannel" /> <int:control-bus input-channel="controlBusChannel" auto-startup="true"/> <file:

这是我第一次尝试使用ControlBus打开/关闭入站通道适配器

为了简单起见,我通过将一个空文件写入入站文件适配器监视的目录来发送控制消息(此文件一直处于打开状态),然后将其路由到服务激活器,该服务激活器将打开/关闭其他入站适配器

<int:channel id="controlBusChannel" />
<int:control-bus input-channel="controlBusChannel" auto-startup="true"/>
<file:inbound-channel-adapter id="controlFilesIn" directory="file:/tmp/control/input" prevent-duplicates="true" auto-startup="true">
    <int:poller id="poller" fixed-delay="500"/>
</file:inbound-channel-adapter>
<int:service-activator input-channel="controlFilesIn" output-channel="controlFilesOut" ref="controlFileHandler" method="handleUpdate"/>
<bean id="controlFileHandler" class="com.myproj.integration.ControlBusController"/>
<file:outbound-channel-adapter id="controlFilesOut" directory="file:/tmp/control/output" delete-source-files="true" />

<file:inbound-channel-adapter id="filesIn" directory="file:/tmp/filesIn/input" prevent-duplicates="true" filter="FileFilterOnLastModifiedTime" auto-startup="false">
    <int:poller id="poller" fixed-delay="500"/>
</file:inbound-channel-adapter>
filesIn已经声明为我的适配器的ID,如上面的XML代码段所示

有什么想法吗?谢谢


另外,我试着加入@ManagedOperation/@ManagedAttribute注释,但它们似乎没有任何积极的效果。

因为在
上没有
频道
属性,而只有
id
,所以频道是自动创建的,并且与
id
完全一致。适配器本身获得一个bean名称,如
filesIn.adapter

因此,必须将ControlBus命令表达式更改为:

String controlMessage = "@'filesIn.adapter'.start()";
Caused by: org.springframework.expression.EvaluationException: The method 'start' is not supported by this command processor. If using the Control Bus, consider adding @ManagedOperation or @ManagedAttribute.
        at org.springframework.integration.handler.ExpressionCommandMessageProcessor$ExpressionCommandMethodResolver.validateMethod(ExpressionCommandMessageProcessor.java:111)
String controlMessage = "@'filesIn.adapter'.start()";