spring-integration - Spring Integration DSL如何将消息异步发送到其他内部通道
问题描述
现在我接受一个 http 请求来处理耗时的任务。所以我想先回复请求者,然后使用其他异步流来处理它。
我尝试在 handler() 方法中使用 CompletableFuture.runAsync ,然后使用 MessageChannel.send 来做。但我认为应该有更优雅的方式
@Bean
public IntegrationFlow testFlow(){
return IntegrationFlows.from("requestChannel")//accept an request
.handle(handlerSomeThing())//do something
.handle()?// how to send message to main and reply quickly
.enrichHeaders(c->c.header(HttpHeaders.STATUS_CODE,HttpStatus.OK))
.get();
}
@Bean
public IntegrationFlow mainFlow(){
return IntegrationFlows.from("mainChannel")//accept an request
.handleMainLogic()//handler main logic
.get();
}
解决方案
推荐阅读
- matplotlib - 如何用 matplotlib 绘制一个填充的矩形棱柱
- python - 在 Azure 应用服务上的 python 烧瓶应用中部署泡菜模型
- javascript - GatsbyJS 博客中的分页
- node.js - 如何修复错误:未指定默认引擎且未提供扩展名。在我的 Express 应用程序中?
- paypal - PayPal 按钮 - 添加要从 IPN 侦听器发回的自定义属性
- javascript - 网站 - 每个人都使用 javascript 的一个会话?
- javascript - 如何使用 async wdio 使用相同的选择器抓取多个元素?
- three.js - 在 three.js 中倾斜(“滚动”)相机
- java - 如何使用 Spring Integration 中的 File Watcher 仅用于等待,而不用于移动?
- java - 我的排序方法没有正确排序字符串(Java)