WSO2 ESB中入站端点的含义和目的是什么?

时间:2018-09-04 17:40:05

标签: java-ee wso2 integration wso2esb wso2ei

我正在研究用于WSO2 ESB认证的材料:

https://wso2.com/training/enterprise-integrator-developer-fundamentals#request_training_enroll

“下载实验室工具包” 部分中,有一个有关如何设置入站端点的教程。基本上,它只是将入站终结点添加到此先前实施的教程项目中

https://docs.wso2.com/display/EI611/Sending+a+Simple+Message+to+a+Service

我已经做到了,并且工作正常,基本上在我的项目中,我有这个REST API:

<?xml version="1.0" encoding="UTF-8"?>
<api context="/healthcare" name="HealthcareAPI" xmlns="http://ws.apache.org/ns/synapse">
    <resource methods="GET" uri-template="/querydoctor/{category}">
        <inSequence>
            <log description="Request Log" level="custom">
                <property name="message" value="Welcome to HealthcareService"/>
            </log>
            <send>
                <endpoint key="QueryDoctorEP"/>
            </send>
        </inSequence>
        <outSequence>
            <send/>
        </outSequence>
        <faultSequence/>
    </resource>
</api>

可以通过此语句直接调用:

curl -v http://localhost:8280/healthcare/querydoctor/surgery

然后,我将此入站终结点添加到项目中:

<?xml version="1.0" encoding="UTF-8"?>
<inboundEndpoint name="QueryDoctorInboundEndpoint" protocol="http" suspend="false" xmlns="http://ws.apache.org/ns/synapse">
    <parameters>
        <parameter name="inbound.http.port">8285</parameter>
        <parameter name="dispatch.filter.pattern">/healthcare/querydoctor/.*</parameter>
    </parameters>
</inboundEndpoint>

这意味着我也可以使用这个新的映射URL来调用此服务:

curl -v http://localhost:8285/healthcare/querydoctor/surgery

我正在使用另一个端口,因为此入站端点正在执行此映射:

<parameter name="dispatch.filter.pattern">/healthcare/querydoctor/.*</parameter>

我的疑问是:为什么我要使用入站终结点代替我的REST API的经典URL?有什么好处或可能的用例?

我试图阅读有关此端点类型的官方文档页面: https://docs.wso2.com/display/ESB490/Working+with+Inbound+Endpoints

但我对此有很多疑问,

  

入站端点是可以插入消息的消息入口点   直接从传输层到中介层,而无需   通过Axis引擎。

我的API是REST服务,为什么要通过AXIS? (据我所知AXIS是SOAP WS技术。)我缺少什么?不使用Axis引擎有什么好处?

另一个疑问是:中介层是我的API序列,其中包含中介者,但是此传输层是什么?

然后它还指定:

  

在现有传输中,仅HTTP传输支持   多租户,这是可以克服的一个限制   入站架构的介绍。

是什么意思?我没有这个限制。

最后还指定:

  

基于常规Axis2的另一个限制   运输是运输不支持动态   配置。使用入站端点,可以创建   入站消息传递通道是动态的,并且还内置   集群协调以及对所有人的多租户支持   运输。

这是什么意思?

在我看来,在本教程中,没有真正的需要(出于演示目的)使用入站端点。不是吗?

如果某些入站端点使用了真实情况,那么

1 个答案:

答案 0 :(得分:1)

This is not a complete answer. It is just my guesses, from software developer side view. Usage of single api is better then usage of several different api. Results are less code, less errors (code is tested already), more features are delivered in shorter time. Historically web services provide better options then rest, at least some time ago. Actually wso is build around axis engine and then time to introduce rest capabilities came up. It sounds reasonable just to transform rest request into same object as axis engine does with soap request and use everything made before. Drawbacks, I assume, much slower then pure rest service might work. Another issues are soap protocol and axis engine have certain assertions and limitations, valuable for rest.

For example if you wish to make rest endpoint to accept some information and respond with file you have to configure set of synapse properties like content-type, encode file content in really tricky way. All this configuration will pass over several layers of synapse engine for such simple thing.

I hope, wso developers will share more info about subject.