edit-icon download-icon

Listen to configurations

Last Updated: Jul 16, 2018

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. The returned value is blank.

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 parameter

Name Type Required Description
ongPullingTimeout string Yes If the long pulling timeout is 30 seconds, then enter 30000 here.
Spas- AccessKey string Yes The accessKey is obtained from 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

Error code

Error code Description Meaning
400 Bad Request Syntax error in client request
403 Forbidden No permission
404 Not Found Client error, not found
500 Internal Server Error Internal server error
200 OK Normal

Examples

Request example

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

Return example

  1. In case of any configuration changes
  2. dataId^2group^2tenant^1
  3. If no configuration changes: an empty string is returned
Thank you! We've received your feedback.