完整的异步 Web 服务通信 - 发送方和接收方无法同时使用 [英] Complete Async web service communication - sender and receiver are not available same time

查看:19
本文介绍了完整的异步 Web 服务通信 - 发送方和接收方无法同时使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

两个系统通过集成(使用 apache-camel)相互通信.假设系统 A 需要向系统 B 提交一个请求,系统 B 已经公开了一个 Web 服务来接收数据,并且集成正在根据系统 B 的 Web 服务转换数据.

Two systems are talking to each other through integration(Using apache-camel). Let say system A needs to submit a request to System B which has exposed a web service to receive data and integration is transforming data as per system B web service.

在上面的场景中,A 和 B 必须同时可用,A 将不得不等待 B 的响应.我需要通过将队列放在集成层和异步通信来消除这种依赖关系.例如:

In above scenario A and B has to be available same time and A will have to wait for response from B. I need to remove this dependency by putting queue at integration layer and with Async communication. Ex:

        <camel:route id="AtoIntegration">
        <camel:from
            uri="spring-ws:someEndPoint" />
        <camel:bean ref="testAsyncPreprocessor" />
        <camel:inOnly uri="activemq:requestqueue" />
    </camel:route>
    <camel:route id="integrationToB">
    <camel:from uri="activemq:requestqueue" />
    <camel:transacted  />
    <camel:bean ref="afterQueueProcessor" />
    <camel:setHeader headerName="CamelHttpMethod">
        <camel:constant>POST</camel:constant>
    </camel:setHeader>
    <camel:setHeader headerName="Content-Type">
        <camel:constant>application/x-www-form-urlencoded</camel:constant>
    </camel:setHeader>
    <camel:to uri="http://localhost:8080/systemB/newOrder?test=testData"
    />
</camel:route>

根据上述路由系统 A 可以提交请求,即使系统 B 不可用,但路由 integrationToB 仍然需要系统 B 可用,否则它将失败并将请求在重试后放入死信队列.所以我想弄清楚如何配置路由 integrationToB 仅在系统 B 可用时运行.

As per above routing system A can submit request even if system B is not available but route integrationToB still needs system B to be available else it will fail and put request to Dead Letter Queue after retry. So i'm trying to figure out how i can configure route integrationToB only run if system B is available.

推荐答案

我不太明白,你说你在系统之间放了一个排队机制.好的,但是如果您这样做了,则无需知道系统是否可用.当队列可用时,该系统将从队列中消费.

I don't quite understand, you said you put a queuing mechanism in between the systems. Ok, but if you have done this there is no need to know if a system is available or not. That system will consume from the queue when it becomes available.

如果您仍然需要从队列发送到 Web 服务,那么在两者之间使用排队机制有什么意义?

If you still need to send from a queue to a web-service then what's the point of having a queuing mechanism in between?

这篇关于完整的异步 Web 服务通信 - 发送方和接收方无法同时使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆