wso2~api訂(ding)閱策略與訂(ding)閱凍結
相關參考:
api訂閱策略在admin后臺,你可以通過Rate Limiting Policies>Subscription Policies來添加(jia)和修改自定(ding)義的策略,并(bing)且它可(ke)以(yi)在(zai)使(shi)用次數(count),使(shi)用帶寬( Bandwidth),異(yi)常事件數量等方面對(dui)請求進行限制。
基本配置
限制單位
- Minute(s)
- Hour(s)
- Day(s)
- Month(s)
- Year(s)
請求數

請求帶寬

事件數

突發流量限制

免費與商業配置
免費與(yu)商(shang)業(ye)(ye)的策略(lve),默認使(shi)用免費策略(lve),商(shang)業(ye)(ye)策略(lve)可以自定義限(xian)制方式,它們在(zai)達到(dao)限(xian)制后都(dou)會對接(jie)口停止訂閱,直(zhi)到(dao)下一(yi)個(ge)策略(lve)周(zhou)期的到(dao)來(lai)


被限流后,將返回這個錯誤
# http 429
{
"code": "900804",
"message": "Message throttled out",
"description": "You have exceeded your quota .You can access API after 2025-Jun-10 09:40:00+0000 UTC",
"nextAccessTime": "2025-Jun-10 09:40:00+0000 UTC"
}
api訂閱的鎖定
開發者平臺,在應用中看到api的鎖定狀態

發布者對api管理員,可以鎖定某個api,可能對發布者管理員來說,某個應用使用不太正常,需要禁用它對api的訪問

應用訂閱的api被鎖定后,應用再調用api時,返回這個錯誤
# http 401
{
"code": "900907",
"message": "The requested API is temporarily blocked",
"description": "Access failure for API: /user-register/1.0.0, version: 1.0.0 status: (900907) - The requested API is temporarily blocked"
}
鎖定api的接口
/api/am/publisher/v4/subscriptions/block-subscription?subscriptionId=e55f1158-e291-4de4-a6e4-c500b902d025&blockState=BLOCKED
api訂閱狀態修改后生效的緩存時間
- 從文檔上看,緩存是15分鐘,如果你把api里的應用訂閱改成blocking,15分鐘后應用將不能訪問當前api

關閉緩存,配置實時生效
如果您不接受緩存的時長,或者需要(yao)實時讓(rang)配置(zhi)生效,那可以把緩存關閉
- values.yaml(deployment.toml)
wso2:
apim:
configurations:
cache:
gateway_token:
# -- Gateway token cache enabled
enabled: false
# -- Gateway token cache expiration time
expiryTime: "15m"
resource:
# -- Gateway resource cache enabled
enabled: false
# -- Gateway resource cache expiration time
expiryTime: "900s"
km_token:
# -- Gateway KM token cache enabled
enabled: false
# -- Gateway KM token cache expiration time
expiryTime: "15m"
api策略中的商業計劃
這塊(kuai)內容需要(yao)結合analytics功能來實現,并且需要(yao)配置monetization對應的銀(yin)行賬戶,以便生產費用后,如(ru)何將錢打到賬戶中
api相關接口
api詳細
/api/am/devportal/apis/{apiId}
api訂閱策略詳細
/api/am/devportal/apis/{apiId}/subscription-policies