2

我有一个流程,我通过网络服务接收请求。我使用组件绑定将该请求转发到 JMS 队列。但是,我想从该队列中获取异步回复并将其用作对 Web 服务的响应。我需要在流程中使用 reply-to 和 async-reply-router 吗?或者在Mule 3中有没有其他方法可以做到这一点?任何指针?

<flow name="mviService">
    <http:inbound-endpoint address="http://localhost:62005/mvi"
        exchange-pattern="request-response">
        <cxf:jaxws-service serviceClass="com.xyz.services.mvi.MVIServicePortType" />
    </http:inbound-endpoint>
    <component class="com.pennmutual.services.mvi.MVIServiceImpl">
        <binding interface="com.pennmutual.mvi.helper.XMLReqProcessorInterface"
            method="process121Order">
            <jms:outbound-endpoint queue="mviq.121.order" />
        </binding>
            </component>

            <async-reply>

            </async-reply>

      </flow>

============ 已编辑 - 请参阅下面的重新设计的问题 =================

我认为我在描述场景方面做得不好。让我再试一次。这是场景——

  1. 客户端调用我们在此流程中描述的服务“mviService”。mviService 通过基于 HTTP/SOAP 的入站端点获取 XML 请求。我们将此请求称为 XML121Request.4
  2. MVI "com.xyz.services.mvi.MVIServiceImpl" 中定义的组件对 XML121Request 进行了一些更改。
  3. 将此 XML121 转发到 JMS 队列“mviq.121.order”。它为此使用组件绑定。
  4. 此 JMS 队列的出站端点是转发此请求的第三方 Web 服务。第三方确认收到 XML121 并返回同步 Web 服务调用。
  5. 来自该第三方服务的响应在稍后的时间点出现,通常是几秒钟。响应是异步的。第三方调用 MVI 上的另一个 Web 服务端点并发送 XML121Response。
  6. MVI 将此响应放入名为“mviq.async.service.reply”的 JMS 队列中。
  7. “mviService”流程需要等待此响应并将此响应(经过一些修改)发送给调用者(在步骤 1 中)。

我能够从第三方获得响应,并且该响应被排入名为“mviq.async.service.reply”的队列中。我想使用/使用此消息并将其作为对第一次调用 MVI 的响应返回。

我正在尝试使用“请求-回复”。

    <request-reply timeout="60000">
        <vm:outbound-endpoint path="request" />
        <jms:inbound-endpoint queue="mviq.async.service.reply"
            exchange-pattern="one-way" />
    </request-reply>

问题是,即使在这种情况下我不想有出站端点,我仍然必须放置一个,因为这是请求-回复标签所要求的。流程在该时间点等待 60 秒,但即使我将某些内容放入队列“mviq.async.service.reply”,相关 ID 也不匹配,因此服务超时并返回错误。

下面会提到流量。

<flow name="mviService">
    <http:inbound-endpoint address="http://localhost:62005/mvi"
        exchange-pattern="request-response">
        <cxf:jaxws-service serviceClass="com.xyz.services.mvi.MVIServicePortType" />
    </http:inbound-endpoint>
    <component class="com.pennmutual.services.mvi.MVIServiceImpl">
        <binding interface="com.xyz.mvi.helper.XMLReqProcessorInterface"
            method="process121Order">
            <jms:outbound-endpoint queue="mviq.121.order" />
        </binding>
    </component>

    <!-- <logger message="XML Correlation ID 1 is #[mule:message.headers(all)]" /> -->
    <request-reply timeout="60000">
        <vm:outbound-endpoint path="request" /> <!-- we don't care about this -->
        <jms:inbound-endpoint queue="mviq.async.service.reply"
            exchange-pattern="one-way" />
    </request-reply>
        <!-- <component class="com.xyz.mvi.CreateMVIServiceResponse"/> -->
</flow>

===== 回复到 ==============

<flow name="mviService">
    <http:inbound-endpoint address="http://localhost:62005/mvi"
        exchange-pattern="request-response">
        <cxf:jaxws-service serviceClass="com.xyz.services.mvi.MVIServicePortType" />
    </http:inbound-endpoint>
    <component class="com.xyz.services.mvi.MVIServiceImpl">
        <binding interface="com.xyz.mvi.helper.XMLReqProcessorInterface"
            method="process121Order">
            <jms:outbound-endpoint queue="mviq.121.order" exchange-pattern="request-response">
                <message-properties-transformer scope="outbound">
                    <add-message-property key="MULE_REPLYTO" value="mviq.async.service.reply" />
                </message-properties-transformer>
            </jms:outbound-endpoint>
        </binding>
     </component>
</flow>
4

1 回答 1

2

我建议您不要创建服务组件类,而是使用cxf:proxy-service,这将使您可以直接访问 SOAP 信封,并有机会在 XML 级别以您想要的方式组装响应。

这将使您摆脱服务组件类强加给您的约束,因此无需使用绑定并打开使用request-response.

请参阅此 SO 答案并查看(瘦)代理服务用户指南以获取更多信息。

于 2012-07-18T19:28:05.630 回答