Description

Capture configuration changes in real time by listening to configurations on ACM.  In case of any configuration changes, you can use the Get Configurations API to obtain the latest value of the configuration and dynamically refresh the local cache.

Registered listening adopts asynchronous Servlet technique. Registered listening is essentially to compare the MD5 with configurations and configuration values to that in the backend.  If the MD5 values don’t match, then it immediately returns the different configuration.  If they match, it holds for 30 seconds.  And it returns an empty string.

Request type

POST

Request URL

/diamond-server/config.co

Request parameters

Name  Type Required Description
Probe-Modify-Request string Yes Listen to data messages. The format is dataId^2group^2contentMD5^2tenant^1.
  • dataId: Configuration ID
  • group: Configuration group
  • contentMD5: MD5 of configuration content
  • tenant: The tenant, corresponding to the namespace field of ACM

Header parameters

Name Type Required Description
longPullingTimeout string Yes If the long pulling timeout is 30 seconds, then enter 30000 here.
Spas-Accesskey string Yes The accessKey can be found in the ACM console.
timeStamp string Yes Request time string in millisecond.
Spas-Signature string Yes  SpasSigner.sign ( Probe- Modify- -RequestContent, secretKey) // Sign the tenant, group, and timestamp with a key using the signature algorithm HMACSHA1.  The timestamp is signed to prevent replay attacks. The signature is valid for 60s.

Parameter description

  • A delimiter to separate fields within a configuration: ^2 = Character.toString((char) 2
  • A delimiter to separate configurations: ^1 = Character.toString((char) 1)
  • contentMD5: MD5(content). This is an empty string because the first local cache is empty.

Response parameters

Parameter type Description
string Configuration value

错误编码

错误代码 描述 语义
400 Bad Request 客户端请求中的语法错误
403 Forbidden 没有权限
404 Not Found 客户端错误,未找到
500 Internal Server Error 服务器内部错误
200 OK 正常

Examples

  • Request example

    http://serverIp: 8080/diamond-server/config.co
    POST request body data:
    Probe- Modify- Request=dataId^2group^2contentMD5^2tenant^1
  • Return example

    In case of any configuration changes
    dataId^2group^2tenant^1 
    If no configuration changes: an empty string is returned