【发布时间】:2018-04-19 15:27:04
【问题描述】:
在我们的环境中,我们运行了多个网关(出于安全目的,针对每个客户端、环境等)。
这些网关启用了资源缓存,作为默认配置(请参阅Configuring caching)
当我们必须添加新网关(例如,新客户)并尝试将已发布的 API 部署到新网关时,就会出现问题。在这种情况下,我们执行以下操作:
- 使用网关分配一台新机器(它们是 AWS 中的 Ubuntu 16.04 实例)。
- 停止 API 管理器(在其他机器上运行)
- 在此 API 管理器中编辑 api-manager.xml,并在 Environments 部分添加新网关
- 启动 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>
更糟糕的是。出现此错误后,自然会降级为 CREATED API,并尝试在所有网关中再次发布。
在这种情况下,我们会为之前运行的网关收到 Exception occurred while trying to invoke service method updateApiFromStringerror
添加新网关的正确方法是什么?还有,如何清除损坏的状态?
【问题讨论】:
标签: caching wso2 wso2-am gateway