Complete Async web service communication - sender

2019-08-20 07:10发布

问题:

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.

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>

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.

回答1:

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.

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?