cdi - 如何刷新并发送请求以使用微配置响应式消息获取数据
问题描述
我正在尝试制作一个 webapp,并且我想在刷新 web 时发送一条消息(这是我制作的一个简单示例,因为它更容易理解)。我尝试过使用内部渠道,但我也尝试过使用 Kafka,但也没有用。
失败消息是“未找到频道“通知刷新”的订阅者”。当我用 kafka 尝试它时没有错误,但它没有检索到消息。
我的资源:它返回发布者是因为主应用程序具有的功能而不是这个可重现的示例,但这不是问题。
@ApplicationScoped
@Path("/refresh")
public class refresh {
@Inject
@Channel("notify-refresh")
Emitter<String> emitter;
@Inject
@Channel("uploaded")
Publisher<String> publisher;
@GET
@Produces(MediaType.SERVER_SENT_EVENTS)
@SseElementType(MediaType.TEXT_PLAIN)
public Publisher<String> hello() {
emitter.send("lets go");
return publisher;
}
}
然后这个类接受消息,进行一些更改并发送到处理器:
@ApplicationScoped
public class generator {
@Incoming("notify-refresh")
@Outgoing("send-processor")
public String sendToProcessor(String uni){
return uni;
}
}
返回资源的处理器:
@ApplicationScoped
public class processor {
@Incoming("send-processor")
@Outgoing("uploaded")
public String processMsg(String uni){
return uni;
}
}
解决方案
推荐阅读
- python - 我收到一个错误“无法将关键字'组'解析到字段中。”试图在 admin.py 中过滤组模型
- ruby-on-rails - form_for 选择字段中的占位符?
- git - 如何获得“有效”的 Git 忽略模式列表?
- bash - grep 文件 bash 中最后一次匹配与 nlines 之后的匹配
- sql-server - .NET Core API 未连接到在 Docker 上运行的 SQL Server
- firebase - 让ExpansionPanelList在Streambuilder中工作
- java - Android Lint:是否可以在 Maven 上的 jar 文件(不是 aar)中发布 lint 检查
- javascript - 获取 HashTable 的值
- node.js - 如何更新 mongodb atlas 文档中的值?
- javascript - If 语句 - Javascript/HTML 数学测验