spring-integration - Spring 集成异步 Http 出站调用
问题描述
我有一个要求,我必须在循环中使用不同的有效负载值对 http 端点进行 Http 出站调用,调用函数不必等待从出站调用收到的响应,所以基本上出站调用将异步发生一个循环。
有没有办法我们可以使用 Http.outboundGateway 来实现这一点
解决方案
您只需要有一个ExecutorChannel
作为该 HTTP 出站网关端点的输入。就像是:
.channel(MessageChannels.executor(someTaskExecutor))
.handle(Http.outboundGateway(...))
如果您从某个循环中执行此操作,那么您还应该有一个id
用于该通道的注入和用于从您的代码发送。如果您不喜欢在代码中处理 API,您也可以考虑@MessagingGateway
在该通道之上使用外观。MessageChannel
在文档中查看更多信息:
https://docs.spring.io/spring-integration/docs/current/reference/html/core.html#executor-channel
推荐阅读
- objective-c - 哪个更快?切换语句或字典?
- python - 未找到 Jupyter 实验室
- html - HTML - 最大宽度之外的 div
- mysql - 从 Latin1 SQL Server 迁移到 utf8mb4 MySQL 错误字符串错误问题
- java - 如何停止在java中打印空矩阵
- python - 在调用检查函数的函数中,应该在哪里生成/打印/发送错误消息?
- svg - 有没有办法绘制形状,以便它们的填充在组内充当不透明但对背景透明
- reactjs - 如何暂停 requestAnimationFrame 并在特定时间恢复(在 React 中)?
- recursion - 以队列为参数的递归空间复杂度
- wpf - 使用 Prism 7.x 和 8.x 在对话框中控制焦点?