Set autoStartup="false" and either directly start() / stop() , or use <control-bus/> (send @myAdapter.start() ).
Getting a direct link (autowire, etc.) depends on the type of endpoint. If this is the polled endpoint, enter a SourcePollingChannelAdapter ; message-driven adapters vary, but usually MessageProducerSupport or MessagingGatewaySupport .
EDIT:
Read the control bus here.
Give the inbound adapter an id attribute.
Add <control-bus input-channel="control"/>
Add <int:gateway service-interface="foo.Controller" default-request-channel="control"/>
Create a gateway interface
public interface Controller { void control(String command); }
@Autowire gateway (or use context.getBean(Controller.class) ).
Then, when you are ready to start the adapter, call, for example. gateway.control("@mqttOut.start()") .
You do not need auto-startup="false" for outgoing adapters.
However, for a simple use case, you may need to explore using Spring profiles instead (put the adapters in the profile and enable the profile at run time.
Gary russell
source share