Caching WSO2 API管理器-添加新网关的最佳方式?

Caching WSO2 API管理器-添加新网关的最佳方式?,caching,wso2,wso2-am,gateway,Caching,Wso2,Wso2 Am,Gateway,在我们的环境中,我们有几个正在运行的网关(为了安全起见,每个客户端、环境等等) 作为默认配置,这些网关启用了资源缓存(请参阅) 当我们必须添加新网关(例如,新客户)并尝试将已发布的API部署到新网关时,就会出现问题。在这种情况下,我们将执行以下操作: 为网关分配一台新机器(它们是AWS中的Ubuntu 16.04实例) 停止API管理器(在其他计算机上运行) 在此api管理器中编辑api-manager.xml,并在“环境”部分中添加新网关 启动API管理器 尝试在新网关中部署API(我们仅在

在我们的环境中,我们有几个正在运行的网关(为了安全起见,每个客户端、环境等等)

作为默认配置,这些网关启用了资源缓存(请参阅)

当我们必须添加新网关(例如,新客户)并尝试将已发布的API部署到新网关时,就会出现问题。在这种情况下,我们将执行以下操作:

  • 为网关分配一台新机器(它们是AWS中的Ubuntu 16.04实例)
  • 停止API管理器(在其他计算机上运行)
  • 在此api管理器中编辑api-manager.xml,并在“环境”部分中添加新网关
  • 启动API管理器
  • 尝试在新网关中部署API(我们仅在“发布”选项卡的“网关”部分中检查新网关)
然后我们得到一个错误,因为它试图重新创建以前存在的缓存

TID: [-1234] [] [2018-04-19 16:53:35,698] ERROR {org.wso2.carbon.governance.registry.extensions.aspects.DefaultLifeCycle} -  org.wso2.carbon.registry.core.exceptions.RegistryException: Execution failed for action : Publish Embedded error : FaultGatewaysException:{"PUBLISHED":{"Prototype":"Error while updating API in the gateway. Error while updating API in the gateway. Cache resourceCache already exists","Production":"Error while updating API in the gateway. Error while updating API in the gateway. Cache resourceCache already exists","Sandbox":"Error while updating API in the gateway. Error while updating API in the gateway. Cache resourceCache already exists"},"UNPUBLISHED":{}} {org.wso2.carbon.governance.registry.extensions.aspects.DefaultLifeCycle}
这是我们的网关配置

<APIGateway>
<!-- The environments to which an API will be published -->
<Environments>
  <!-- Environments can be of different types. Allowed values are 'hybrid', 'production' and 'sandbox'.
             An API deployed on a 'production' type gateway will only support production keys
             An API deployed on a 'sandbox' type gateway will only support sandbox keys
             An API deployed on a 'hybrid' type gateway will support both production and sandbox keys. -->
  <!-- api-console element specifies whether the environment should be listed in API Console or not -->
  <Environment type="production" api-console="true">
    <Name>Prototype</Name>
    <Description>Prototype</Description>
    <ServerURL>https://apisandbox.example.com:9446/services/</ServerURL>
    <GatewayEndpoint>https://apisandbox.example.com:8246</GatewayEndpoint>
    <Username>${admin.username}</Username>
    <Password>${admin.password}</Password>
  </Environment>
  <Environment type="sandbox" api-console="true">
    <Name>Sandbox</Name>
    <Description>Sandbox</Description>
    <ServerURL>https://apisandbox.example.com:9446/services/</ServerURL>
    <GatewayEndpoint>https://apisandbox.example.com:8246</GatewayEndpoint>
    <Username>${admin.username}</Username>
    <Password>${admin.password}</Password>
  </Environment>
  <Environment type="production" api-console="false">
    <Name>Production</Name>
    <Description>Production</Description>
    <ServerURL>https://apigateway.example.com:9447/services/</ServerURL>
    <GatewayEndpoint>https://apigateway.example.com:8247</GatewayEndpoint>
    <Username>${admin.username}</Username>
    <Password>${admin.password}</Password>
  </Environment>
</Environments>

原型
原型
https://apisandbox.example.com:9446/services/
https://apisandbox.example.com:8246
${admin.username}
${admin.password}
沙箱
沙箱
https://apisandbox.example.com:9446/services/
https://apisandbox.example.com:8246
${admin.username}
${admin.password}
生产
生产
https://apigateway.example.com:9447/services/
https://apigateway.example.com:8247
${admin.username}
${admin.password}

更糟。发生此错误后,自然操作是降级到创建的API,并尝试在所有网关中再次发布

在本例中,我们在尝试为以前运行的网关调用服务方法UpdateAppromString时发生了
异常


添加新网关的正确方法是什么?如何清除已损坏的状态?

使用以下代码在Wso2 carbon panel(主机名:9443/carbon url)中添加/更新APILifeCycle。后藤延伸→ 生命周期和编辑/添加生命周期

<aspect name="APILifeCycle" class="org.wso2.carbon.governance.registry.extensions.aspects.DefaultLifeCycle">
    <configuration type="literal">
        <lifecycle>
            <scxml xmlns="http://www.w3.org/2005/07/scxml"
                   version="1.0"
                   initialstate="Created">
                <state id="Created">
                    <datamodel>
                        <data name="checkItems">
                            <item name="Deprecate old versions after publish the API" forEvent="">
                            </item>
                            <item name="Require re-subscription when publish the API" forEvent="">
                            </item>
                        </data>
                        <data name="transitionExecution">
                            <execution forEvent="Deploy as a Prototype"
                                       class="org.wso2.carbon.apimgt.impl.executors.APIExecutor">
                            </execution>
                            <execution forEvent="Publish"
                                       class="org.wso2.carbon.apimgt.impl.executors.APIExecutor">
                            </execution>
                        </data>
                    </datamodel>
                    <transition event="Publish" target="Published"/>
                    <transition event="Deploy as a Prototype" target="Prototyped"/>
                </state>
                <state id="Prototyped">
                    <datamodel>
                        <data name="checkItems">
                            <item name="Deprecate old versions after publish the API" forEvent="">
                            </item>
                            <item name="Require re-subscription when publish the API" forEvent="">
                            </item>
                        </data>
                        <data name="transitionExecution">
                            <execution forEvent="Publish"
                                       class="org.wso2.carbon.apimgt.impl.executors.APIExecutor">
                            </execution>
                            <execution forEvent="Demote to Created"
                                       class="org.wso2.carbon.apimgt.impl.executors.APIExecutor">
                            </execution>
                        </data>
                    </datamodel>
                    <transition event="Publish" target="Published"/>
                    <transition event="Demote to Created" target="Created"/>
                    <transition event="Deploy as a Prototype" target="Prototyped"/>
                </state>

                <state id="Published">
                    <datamodel>
                        <data name="transitionExecution">
                            <execution forEvent="Block"
                                       class="org.wso2.carbon.apimgt.impl.executors.APIExecutor">
                            </execution>
                            <execution forEvent="Deprecate"
                                       class="org.wso2.carbon.apimgt.impl.executors.APIExecutor">
                            </execution>
                            <execution forEvent="Demote to Created"
                                       class="org.wso2.carbon.apimgt.impl.executors.APIExecutor">
                            </execution>
                            <execution forEvent="Deploy as a Prototype"
                                       class="org.wso2.carbon.apimgt.impl.executors.APIExecutor">
                            </execution>
                        </data>
                    </datamodel>
                    <transition event="Block" target="Blocked"/>
                    <transition event="Deploy as a Prototype" target="Prototyped"/>
                    <transition event="Demote to Created" target="Created"/>
                    <transition event="Deprecate" target="Deprecated"/>
                    <transition event="Publish" target="Published"/>

                </state>
                <state id="Blocked">
                    <datamodel>
                        <data name="transitionExecution">
                            <execution forEvent="Re-Publish"
                                       class="org.wso2.carbon.apimgt.impl.executors.APIExecutor">
                            </execution>
                            <execution forEvent="Deprecate"
                                       class="org.wso2.carbon.apimgt.impl.executors.APIExecutor">
                            </execution>
                        </data>
                    </datamodel>
                    <transition event="Deprecate" target="Deprecated"/>
                    <transition event="Re-Publish" target="Published"/>
                </state>
                <state id="Deprecated">
                    <datamodel>
                        <data name="transitionExecution">
                            <execution forEvent="Retire"
                                       class="org.wso2.carbon.apimgt.impl.executors.APIExecutor">
                            </execution>
                        </data>
                    </datamodel>
                    <transition event="Retire" target="Retired"/>
                </state>
                <state id="Retired">
                </state>
            </scxml>
        </lifecycle>
    </configuration>
</aspect>