首页 > 解决方案 > WSO2 API Manager - 使用动态端点进行负载平衡

问题描述

我有一个使用动态端点的 API。现在我希望它也能做负载平衡。我知道如何使用元素来做到这一点,但是在 APIM 中使用动态端点时,您只能操作“To”标头。

以下是用于设置端点的中介序列。我希望能够在两台服务器之间进行负载平衡,而不是在每种情况下只处理一个端点。

有什么想法吗?

谢谢。

<?xml version="1.0" encoding="UTF-8"?>
<sequence name="inSequence_clientEquipmentsAPI_1_2_STG" trace="disable" xmlns="http://ws.apache.org/ns/synapse">
    <!-- check for healthcheck operation -->
    <filter xpath="get-property('To')='/etc/equipments/client/1.0/healthCheck'">
        <!-- if healthCheck, directs to healthCheck API (EI)-->
        <then>
            <property name="REST_URL_POSTFIX" scope="axis2" action="remove"/>
            <header name="To" value="http://10.220.160.36:8290/healthCheck/clientEquipments"/>
        </then>
        <!-- else direct to regular clientEquipment API (EI)-->
        <else>
            <property name="newContext" expression="substring-after(get-property('To'),'/etc')"/>       
            <header name="To" expression="fn:concat('http://10.220.160.36:8290', $ctx:newContext)"/>
        </else>         
    </filter>
</sequence>

标签: wso2wso2-am

解决方案


推荐阅读