如何动态停止消息驱动适配器以停止接收消息?

How to stop the Message driven adapter dynamically to stop receiving messages?

   <control-bus input-channel ="inboundChannel/>
    <channel id ="inboundChannel"/>
    <message-driven-channel-adapter id="inAQueue" channel="inboundChannel" 
    auto-startup="false" container="DefaultContainer"/>
    <service-activator input-channel="inboundChannel" ref="Something" 
    method="abc"/>

inboundChannel.send(MessageBuilder.withPayload("@inAQueue.stop()").build();

inboundChannel.send(MessageBuilder.withPayload("@inAQueue.start()").build());

But my service activator class receive this message and throws class cast exception that string can not be cast to jmstextMessage.

而且我不确定我是否以正确的方式尝试它。

您在 inboundChannel 上有 2 个订阅者 - message-driven 适配器和 control-bus。消息将以 round-robin 方式分发。

控制总线应订阅其自己的通道,控制消息将发送到该通道。