WSO2 API Manager - 添加新网关的最佳方式?

时间:2018-04-19 15:27:05

标签: caching wso2 wso2-am gateway

在我们的环境中,我们有几个网关运行(出于安全目的,为每个客户端,环境等)。

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

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

  • 使用网关分配新计算机(它们是AWS中的Ubuntu 16.04实例)。
  • 停止API管理器(在其他计算机上运行)
  • 在此API管理器中编辑api-manager.xml,并在“环境”部分
  • 中添加新网关
  • 启动API Manager
  • 尝试在新网关中部署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>

更糟糕的是。出现此错误后,自然操作是降级为CREATED API,并尝试在所有网关中再次发布。

在这种情况下,我们先前运行的网关出现Exception occurred while trying to invoke service method updateApiFromString错误

添加新网关的正确方法是什么?而且,我该如何清理损坏的状态呢?

1 个答案:

答案 0 :(得分:1)

使用以下代码在Wso2碳面板(主机名:9443 / carbon url)中添加/更新APILifeCycle。转到扩展→生命周期,然后编辑/添加APILifeCycle。

Qt::UserRole

关注此https://docs.wso2.com/display/AM200/Extending+the+API+Life+Cycle