无论如何,有手动启动/初始化通道适配器吗?
我的context.xml中有两对入站/出站适配器,并且想在运行时确定我要开始使用哪一对。
编辑:
具体方案:
我有一个客户端,可以在运行时将其配置为mqtt发布者或订阅者。
我的context.xml看起来像这样:
<int-mqtt:message-driven-channel-adapter
client-id="foo"
auto-startup="true"
url="tcp://192.168.97.164:1883"
topics="testtopic/#"
channel="writeToFile" />
<file:outbound-channel-adapter
id="writeToFile"
auto-startup="true"
directory="./test/out"
delete-source-files="false"/>
<int:transformer id="Transformer"
ref="MessageTransformer"
input-channel="readFromFile"
output-channel="mqttOut"
method="bytesFromFile" />
<bean id="MessageTransformer" class="MessageTransformer"/>
<int-mqtt:outbound-channel-adapter
id="mqttOut"
client-id="foo"
url="tcp://192.168.97.164:1883"
auto-startup="false"
default-qos="1"
default-retained="true"
default-topic="testtopic/bla"
/>
<file:inbound-channel-adapter
auto-startup="false"
id="readFromFile"
directory="./test/in"
filename-pattern="myFile*">
<int:poller id="poller"
fixed-rate="5000" />
</file:inbound-channel-adapter>
如您所见,我有两个设置:
1.订阅者案例:读取mqtt消息->写入文件
2.发布者案例:从目录中轮询文件->通过mqtt发送
我在运行时决定要应用什么设置。
那么,您能告诉我这套控制总线到底如何适合吗?
设置autoStartup="false"
和直接start()
/ stop()
它们,或使用<control- bus/>
(发送@myAdapter.start()
)。
获取直接参考(自动装配等)取决于端点类型。如果是轮询的端点,请插入SourcePollingChannelAdapter
;。消息驱动的适配器有所不同,但通常为MessageProducerSupport
或MessagingGatewaySupport
。
编辑:
在此处阅读有关控制总线的信息。
给入站适配器一个id
属性。
加 <control-bus input-channel="control"/>
加 <int:gateway service-interface="foo.Controller" default-request- channel="control"/>
创建一个网关接口
public interface Controller {
void control(String command);
}
@Autowire
网关(或使用context.getBean(Controller.class)
)。
然后,当您准备启动适配器时,请调用gateway.control("@mqttOut.start()")
。
您不需要auto-startup="false"
出站适配器。
但是,对于像这样的简单用例,您可能想研究使用Spring配置文件(将适配器放入配置文件中并在运行时启用配置文件。
我一直在使用Android AltBeacon库来监控和定位附近的iBeacons。该应用程序的一个特定要求是允许扫描信标检测,即使当应用程序在后台时也允许扫描信标检测,并且当应用程序关闭时完全停止扫描信标检测。 据我所知,这个需求可以通过bootstrapnotifier/regionbootstrap部分满足,但是扫描服务即使在应用程序关闭时也会重新启动,这是我不希望发生的。
我正在基于RecyclerView构建一个组件,允许用户通过拖放来重新排序项目。一旦我在DragListener侧,我需要它在适配器中的位置,以便执行正确的移动,但我只能访问视图。下面是我在适配器视图绑定中所做的工作: 你觉得对吗?因为如果我像这样移动一个项目: 然后位置标签不再正确,如果我通知fyDataSetChanged(),我失去了花哨的动画。有什么建议吗?
问题 你要为需要并发执行的代码创建/销毁线程 解决方案 threading 库可以在单独的线程中执行任何的在 Python 中可以调用的对象。你可以创建一个 Thread 对象并将你要执行的对象以 target 参数的形式提供给该对象。 下面是一个简单的例子: # Code to execute in an independent thread import time def countdown(
控制台-频道-停止 接口URL {youke-url}/console/Index.php?c=live&a=stop×tamp=1607677497&access_key=abc&sign=04394c5a45b6920bed314e94e178ebcf1dfded74 请求方式 POST Content-Type form-data 请求Query参数 参数 示例值 是否必填 参数描
对不起,老问题。我已经澄清了。我如何用我可怜的线程类开始停止线程? 编辑:它在循环中,我想在代码开头再次重新启动它。我如何启动停止重新启动? 我的班级: 在主代码中,我希望:
参考 workerman手册 http://doc3.workerman.net/install/start-and-stop.html