gpt4 book ai didi

java - 是否有类似 DefaultMqttPahoClientFactory 的东西用于创建异步客户端?

转载 作者:行者123 更新时间:2023-12-02 05:45:11 25 4
gpt4 key购买 nike

我想在 Spring Integration 中使用异步 Paho 客户端:

@Bean
public DefaultMqttPahoClientFactory clientFactory() {
return new DefaultMqttPahoClientFactory();
}

<int-mqtt:message-driven-channel-adapter id="mqttInbound"
client-id="${mqtt.default.client.id}.src"
url="${mqtt.url}"
topics="sometopic"
client-factory="clientFactory"
channel="output"/>

我必须自己写一个吗?我只能找到同步客户端工厂的示例。

最佳答案

正确;目前仅支持同步客户端。

欢迎打开improvement JIRA issue here当然还有contributions are always welcome - guidelines here

也就是说,我不清楚在入站适配器中使用异步客户端的好处(如您的示例所示);它是消息驱动的,到达的消息在客户端线程上异步传递。显然,出站适配器可以从异步操作中获得一些好处。

outbound adapter非常简单,编写一个使用异步客户端的应用程序应该不会太难 - 它可能需要将传递 token 发送到某个 channel - 但我们应该从 IMqttDeliveryToken 对象中抽象出来,这样我们不要将 Paho 泄漏到上层。

关于java - 是否有类似 DefaultMqttPahoClientFactory 的东西用于创建异步客户端?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24141082/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com