代码之家  ›  专栏  ›  技术社区  ›  Romas Augustinavičius

Spring集成网关路由

  •  0
  • Romas Augustinavičius  · 技术社区  · 7 年前

    我对spring集成有一个问题,基本上我正在尝试创建chain,该chain将调用多个服务中的一个,并将结果返回给chain gateway进行进一步处理。

    <int:chain input-channel="inputChannel" output-channel="outputChannel">
        <int:header-enricher>
            <int:header name="temporalPayload" expression="payload"/>
            <int:header name="matcher" value="other" />
        </int:header-enricher>
        <int:gateway request-channel="routerChannel" reply-channel="replyChannel" error-channel="errorChannel"/>
        <int:transformer expression="headers.temporalPayload"/>
    </int:chain>
    
    <int:router input-channel="routerChannel" expression="headers.matcher.matches('(test)|(test2)')?headers.matcher:'other'" >
        <int:mapping value="test1" channel="channel1"/>
        <int:mapping value="test2" channel="channel2"/>
        <int:mapping value="other" channel="channel3" />
    </int:router>
    
    <int:service-activator input-channel="channel1" output-channel="replyChannel" ref="service1" method="handle"/>
    <int:service-activator input-channel="channel2" output-channel="replyChannel" ref="service2" method="handle"/>
    <int:service-activator input-channel="channel3" output-channel="replyChannel" ref="service3" method="handle"/>
    

    网关无法从service activator接收对通道“replyChannel”的回复。What I'am doing wrong?我做错了什么?

    1 回复  |  直到 7 年前
        1
  •  0
  •   Artem Bilan    7 年前

    可以为启用调试日志记录级别 org.springframework.integration 分类并观察信息的传播方式。

    另一方面,在大多数情况下你并不需要 reply-Channel 在网关上,只需依靠 replyChannel 由网关填充的标头。在这种情况下,您甚至需要删除 output-Channel service-activator s

    您的 repjyChannel 为网关窃取消息的人。

    您可以尝试不使用 回复频道 或者按照我上面的建议调查日志。