spring-webflux - 春季迭代。发送 Slack 通知 WebFlux
问题描述
我需要在流程的许多部分发送一条松弛消息,指示文件处理信息并继续主流程。
我没有找到一种完全直接的方法
到目前为止,我的解决方案是:
声明一个队列通道来接收需要发送的消息
@Bean
MessageChannel slackChannel() {
return MessageChannels.queue(SLACK_CHANNEL).get();
}
该通道中的每条消息都将发送到 Slack(在发送之前应用一些转换)
@Bean
IntegrationFlow startFlow() {
return IntegrationFlows
.from(FILE_CHANNEL)
.filter(myFilter)
.handle(myService, "doSomething")
.transform(doSomeTransformation)
.channel(SLACK_CHANNEL)
.split()
.aggregate(myAggregator)
.transform(anotherTransformer)
.channel(ANOTHER_CHANNEL)
.get();
}
这里是松弛流
@Bean
IntegrationFlow sendFileProcessingInfo() {
return IntegrationFlows
.from(SLACK_CHANNEL)
.transform(Message.class, this::prepareSlackMessage)
.handle(WebFlux.outboundGateway(m ->
UriComponentsBuilder.fromUriString(slackConfigurationProperties.getUrl())
.build()
.toUri())
.httpMethod(HttpMethod.POST)
.expectedResponseType(String.class))
.log()
.get();
}
问题之一是在将消息发送到主流程中间的 SLACK_CHANNEL 后流程不会继续。
另一个问题是 sendFileProcessingInfo 显然从未激活
另外,我怀疑expectedResponseType 必须是String。
那么,在流程中间发送 HTTP 消息的最合适的解决方案应该是什么?问题的原因可能是什么?
另外,为准备松弛消息进行转换会改变主要流程的对象吗?
我会很感激这方面的任何帮助。
谢谢!
解决方案
推荐阅读
- powershell - 无法使用“Get-ADUser”cmdlet 提取用户电子邮件地址
- asp.net-web-api2 - 使用 Web API TransactionScope 和 SQL Server 内存表问题
- c++ - 错误:函数'int解决方案的参数太少(std :: vector
, int)' - maven - 如何使用 maven 程序集插件从输出文件中删除一些文件夹?
- javascript - 初始化日期变量-Javascript
- c# - SqlDependency 适用于我的测试数据库,但不适用于真实数据库
- java - 每次用户单击加号按钮时如何添加+30?
- ios - 使用 Xamarin UITest 在 iOS 选取器中选择一个项目?
- c# - C# 获取带有超过一年附件的电子邮件
- c - 如何在 C 中使用 char 数组添加两个大的非负整数?