Spring integration Spring集成-处理管道-设计

Spring integration Spring集成-处理管道-设计,spring-integration,Spring Integration,我正在尝试设计一个需要使用多个端点处理消息的消息处理管道。在每个阶段,端点返回有效负载(可以转换)或错误消息。以下是我脑海中的一个通用示例: <int:payload-type-router input-channel="preprocessing-output"> <int:mapping type="com.example.Error" channel="error" /> <int:mapping type="com.examp

我正在尝试设计一个需要使用多个端点处理消息的消息处理管道。在每个阶段,端点返回有效负载(可以转换)或错误消息。以下是我脑海中的一个通用示例:

<int:payload-type-router input-channel="preprocessing-output">
        <int:mapping type="com.example.Error" channel="error" />
        <int:mapping type="com.example.PreprocessedDomainObject" channel="validation-input"/>
</int:payload-type-router>

<int:service-activator input-channel="validation-input"
        ref="validationService" method="validate" output-channel="validation-output"/>

<int:payload-type-router input-channel="validation-output">
            <int:mapping type="com.example.Error" channel="error" />
            <int:mapping type="com.example.CouldBeAnotherObject" channel="processor-input"/>
</int:payload-type-router>


所以,这个处理链可能相当长。。。有没有更好的方法来设计它,而不是在每个阶段之后设计一个有效负载类型的路由器?感觉有点多余。

好吧,我会根据例外情况来做。验证服务应该只抛出异常,您所需要的只是在调用方上捕获它,或者如果它是入站通道适配器,则使用
errorChannel

这样,您根本不需要这些路由器定义,只需要简单的服务调用链