- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
场景可能是:我的期望可能是批量 10 个数据点,我想对 {failed 5, pass 5} 或 sth. 做出响应。
我的逻辑是将批次拆分为数据元素并进行验证。
成功的验证将发送到聚合器,
失败的验证将抛出错误并由错误 channel 接收。
接收者列表路由器将 errorChannel 作为 inputChannel 和 2 个过滤器连接到它,目的是过滤某种类型的错误以直接发送响应(与用户输入无关的接收 - 服务器错误等),某种类型的客户端错误将转到聚合器以构建响应。
逻辑有问题吗?
我的问题是在聚合器之后使用服务激活器构建结果时,我不断收到“收到回复消息,但接收线程已经收到回复”。这个服务激活器连接到replyChannel,似乎有一些消息已经发送到这个 channel ?
在“错误过滤器”连接到replyChannel之后,我只检查了我的集成工作流程这个服务激活器和服务器错误分支(但句柄从未被调用。)
有问题?顺便说一句,收件人列表路由器或其他类型的端点可以连接到 errorChannel 吗?或者它必须是服务激活器,就像我在所有在线示例中看到的那样?(但它们是非常简单的示例..)
示例 XML
<int:gateway id="myGateway" service-interface="someGateway" default-request-channel="splitChannel" error-channel="errorChannel" default-reply-channel="replyChannel" async-executor="MyThreadPoolTaskExecutor"/>
<int:splitter input-channel="splitChannel" output-channel="transformChannel" method="split">
<bean class="Splitter" />
</int:splitter>
<int:transformer id="transformer" input-channel="transformChannel" method="transform" output-channel="aggregateChannel">
<bean class="Transformer"/> // this may throw the validation error (filter_ErrorType_1), if it cannot transform
</int:transformer>
<int:aggregator id="aggregator"
input-channel="aggregateChannel"
output-channel="createAnswerChannel"
method="aggregate">
<bean class="MyAggregator" />
</int:aggregator>
<int:recipient-list-router id="myErrorRouter" input-channel="errorChannel">
<int:recipient channel="filter_ErrorType_1"/>
<int:recipient channel="filter_ErrorType_2"/>
<int:recipient channel="filter_ErrorType_3"/>
</int:recipient-list-router>
<int:filter input-channel="filter_ErrorType_1" output-channel="aggregateChannel" method="accept"></int:filter>
<int:filter input-channel="filter_ErrorType_2" output-channel="createErrorAnswerChannel" method="accept"></int:filter>
<int:filter input-channel="filter_ErrorType_3" output-channel="createErrorAnswerChannel" method="accept"></int:filter>
<int:service-activator input-channel='createErrorAnswerChannel' output-channel="replyChannel" method='buildError'>
<bean class="AnswerBuilder"/>
</int:service-activator>
<int:service-activator input-channel='createAnswerChannel' output-channel="replyChannel" method='build'>
<bean class="AnswerBuilder"/>
</int:service-activator>
<int:gateway id="myGateway" service-interface="someGateway" default-request-channel="splitChannel" error-channel="errorChannel" default-reply-channel="replyChannel" async-executor="MyThreadPoolTaskExecutor"/>
<int:splitter input-channel="splitChannel" output-channel="transformChannel" method="split">
<bean class="Splitter" />
</int:splitter>
<int:transformer id="transformer1" input-channel="toTransformer1" method="transform" output-channel="toTransformer2">
<bean class="Transformer1"/> // this may throw the validation error (filter_ErrorType_1), if it cannot transform
</int:transformer>
<int:transformer id="transformer2" input-channel="toTransformer2" method="transform" output-channel="toTransformer3">
<bean class="Transformer2"/> // this may throw the validation error (filter_ErrorType_2), if it cannot transform
</int:transformer>
<int:transformer id="transformer3" input-channel="toTransformer3" method="transform" output-channel="aggregateChannel">
<bean class="Transformer3"/> // this may throw the validation error (filter_ErrorType_3), if it cannot transform
</int:transformer>
???
// seems like you are proposing to have one gateway for each endpoint that may throw error.
// but in this case, take transfomer 1 for example, I cannot output the gateway directly to aggregate channel since for valid data it has to go to transformer 2
// but the failed message throwed by the error handler cannot pass transformer 2 because of afterall this is a error message not a valid data for transformer 2
// <int:service-activator input-channel="toTransformer1" output-channel="toTransformer2" ref="gateway1"/>
// <int:gateway id="gateway1" default-request-channel="toTransformer1" error-channel="errorChannel1"/>
// <int:transformer id="transformer" input-channel="toTransformer1" method="transform">
// <bean class="Transformer"/> // this may throw the validation error (filter_ErrorType_1), if it cannot transform
// </int:transformer>
// how to deal with this problem?
<int:service-activator input-channel='createErrorAnswerChannel' output-channel="replyChannel" method='buildError'>
<bean class="AnswerBuilder"/>
</int:service-activator>
<int:service-activator input-channel='createAnswerChannel' output-channel="replyChannel" method='build'>
<bean class="AnswerBuilder"/>
</int:service-activator>
最佳答案
你的问题不清楚。请确保将来提供更具体的信息。一些配置和 StackTrace 或日志也很有用。
我猜你在你的流程开始时就有 <gateway>
已配置 error-channel
.这就是为什么您会收到 Reply message received but the receiving thread has already received a reply
.
但我不能确定,因为你的问题中没有这些词。对?
您不能依赖 errorChannel
标题在那里,然后回来 reply
最终因为errorChannel
网关的情况下的 header 与 replyChannel
相同,它是 TemporaryReplyChannel
- 一次性使用 channel ,仅适用于 receive()
手术。
由于我们没有您提供的任何配置或代码,因此我们无法为您提供适当的帮助。
我想你需要一个中间流 gateway
通过 service-activator
:
<service-activator id="gatewayTestService" input-channel="inputChannel"
output-channel="outputChannel" ref="gateway"/>
<gateway id="gateway" default-request-channel="requestChannel" error-channel="myErrorChannel"/>
<chain>
与
<gateway>
仅在那里执行验证并捕获错误并返回所需的失败回复。那个
service-activator
将能够将它们全部发送到
<aggregator>
之后。在这种情况下,
<aggregator>
可以正常回复网关。
errorChannel
是默认全局 bean 的名称,用于捕获来自任何集成位置的任何错误消息。在 http://docs.spring.io/spring-integration/reference/html/configuration.html#namespace-errorhandler 中查看更多信息. myErrorRouter
将处理所有错误!
<int:recipient-list-router>
如果通过 selector
,则向其所有收件人发送消息或者如果没有 selector
. default-reply-channel
在 <gateway>
如果不是 publish-subscribe
.您可以依靠 replyChannel
标题,如果没有 output-channel
则有效defined . <service-activator>
和 <gateway>
在您的 <transformer>
面前非常直截了当之后 <splitter>
:<int:service-activator input-channel="transformChannel"
output-channel="aggregateChannel" ref="gateway"/>
<int:gateway id="gateway" default-request-channel="transformChannel" error-channel="validationErrorChannel"/>
<int:transformer id="transformer" input-channel="transformChannel" method="transform">
<bean class="Transformer"/> // this may throw the validation error (filter_ErrorType_1), if it cannot transform
</int:transformer>
splitter
将项目发送到
service-activator
.那个人继续向
gateway
发送消息附近
transformer
定制
error-channel
正好为一项。
transformer
回复
replyChannel
与之前的完全一致
gateway
.如果抛出异常,则由
validationErrorChannel
处理。过程。应该回复一些补偿信息。该消息冒泡到
service-activator
.最后
service-activator
将结果发送到
aggregateChannel
.它是
service-activator
的黑匣子验证是否良好。
<int:gateway id="myGateway" service-interface="someGateway" default-request-channel="splitChannel"
async-executor="MyThreadPoolTaskExecutor" />
<int:splitter input-channel="splitChannel" output-channel="transformChannel" method="split">
<bean class="Splitter" />
</int:splitter>
<int:service-activator input-channel="validateChannel" output-channel="aggregateChannel"
ref="validateGateway"/>
<gateway id="validateGateway" default-request-channel="toTransformer1" error-channel="myErrorChannel"/>
<chain input-channel="toTransformer1">
<int:transformer method="transform">
<bean class="Transformer1" />
</int:transformer>
<int:transformer method="transform">
<bean class="Transformer2" />
</int:transformer>
<int:transformer method="transform">
<bean class="Transformer3" />
</int:transformer>
</chain>
<int:service-activator input-channel="myErrorChannel" method="buildError">
<bean class="AnswerBuilder" />
</int:service-activator>
<int:aggregator id="aggregator"
input-channel="aggregateChannel"
output-channel="createAnswerChannel"
method="aggregate">
<bean class="MyAggregator" />
</int:aggregator>
<int:service-activator input-channel='createAnswerChannel' method='build'>
<bean class="AnswerBuilder" />
</int:service-activator>
myErrorChannel
上进行错误处理。 .
关于Spring集成errorChannel,错误句柄,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39256191/
我设置了 Helm 柄和 Helm 柄。我有tiller-deploy。昨天,我可以定期运行了。但今天我收到此错误消息 Error: could not find a ready tiller pod
我以前已将分er安装到特定的 namespace 中。 我设置了一个环境变量来设置'tiller'命名空间-但我不记得该环境变量的名称-而且似乎无法通过网络搜索找到它。 这是什么 key ? 最佳答案
当我在 View 模型中使用如下界面时 class MainViewModel @ViewModelInject constructor( private val trafficImagesR
我正在尝试找到如何在某个 fragment 相关场景中定义 Hilt 的解决方案。我有以下设置: Activity 父 fragment 1 子 fragment 1 子 fragment 2 ...
Hilt 指出如果没有@Provides 注解就不能提供这个接口(interface): interface PlannedListRepository { fun getAllLists()
我的问题非常简单明了:两个注释/示例之间有什么区别: 例子一 @Singleton class MySingletonClass() {} @Module @InstallIn(FragmentCom
我是一名优秀的程序员,十分优秀!