【问题标题】:Spring Integration - int-http:inbound-gatewaySpring 集成 - int-http:inbound-gateway
【发布时间】:2015-04-28 04:37:07
【问题描述】:

我定义了一个 int-http:inbound-gateway,它有一个请求通道和一个回复通道。请求通道连接到服务激活器,该服务激活器验证消息并通过其输出通道返回消息响应。如何将经过验证的消息转发到另一个端点以进行进一步的消息处理?就像我需要 2 个输出通道,一个用于响应,一个用于消息。

<int-http:inbound-gateway
    request-channel="requestChannel"
    reply-channel="responseChannel"
    supported-methods="POST"
    path="/message/hl7/{source}">
    <int-http:request-mapping
            consumes="application/json" produces="application/json"/>
    <int-http:header name="source" expression="#pathVariables.source"/>
</int-http:inbound-gateway>

<int:service-activator ref="HL7MessageEndpoint"
                       method="POST"
                       input-channel="requestChannel"
                       output-channel="responseChannel"/>

 <!-- need to send original message to jms if service activator validates successfully -->  

【问题讨论】:

  • 您可以发布您的工作/代码突出显示您尝试过的内容吗?

标签: spring-integration


【解决方案1】:

将回复频道更改为&lt;publish-subscribe-channel/&gt;。这样,回复将返回到网关,您可以订阅另一个组件。您可能需要将任务执行器添加到通道,以便下游流不会在 Web 容器线程上运行。

【讨论】:

  • 感谢您的建议,但我认为这不会起作用,因为回复频道包含确认类型的消息,我需要处理原始消息。
  • 所以改用requestChannel pub/sub。在服务激活器上设置order="1",在第二个订阅者上设置order="2"。这样,只有在服务激活器正常完成时才会调用第二个订阅者。您不得从备选流程返回任何结果。
【解决方案2】:

如果消息有效,请在您的转换器中添加一个标志 返回 MessageBuilder.withPayload(Dto).setHeader("ValidFlag", Dto.getValidFlag().toString()) 。建造(); 添加路由器判断消息是否有效 定义输入输出通道

`<channel id="requestInChannel"/>
<channel id="outputActivatorInChannel" />
<channel id="validatorInChannel"/>

<header-value-router input-channel="requestInChannel"
    header-name="validFalg" default-output-channel="validatorInChannel"
    resolution-required="false">
    <mapping value="false" channel="outputActivatorInChannel" />
    <mapping value="true" channel="validatorInChannel" />
</header-value-router>`

如果消息有效,则进入两个不同的激活器

<int:service-activator ref="OutputActibvator" method="POST" input-channel="validatorInChannel" output-channel="responseChannel"/>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-11-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多