@@ -18,7 +18,7 @@ See the [中文文档](https://opensergo.io/zh-cn/) for document in Chinese.
1818
19191 . Add dependency in Maven ` pom.xml ` :
2020
21- ``` xml
21+ ``` xml
2222<!-- replace here with the latest version -->
2323<dependency >
2424 <groupId >io.opensergo</groupId >
@@ -29,20 +29,28 @@ See the [中文文档](https://opensergo.io/zh-cn/) for document in Chinese.
2929
30302 . Subscribe data from OpenSergo control plane:
3131
32- ``` java
32+ ``` java
3333// 1. Create client with remote host and port of OpenSergo control plane
3434OpenSergoClient client = new OpenSergoClient (host, port);
3535// 2. Start the OpenSergo client.
3636client. start();
3737
38- // 3. Subscribe the config of the target (namespace, appName, kind)
39- client. subscribeConfig(new SubscribeKey (" default" , " my-service" , configKind),
40- new OpenSergoConfigSubscriber () {
38+ // 3. Prepare for subscribing the config of the target (namespace, appName, kind)
39+ // 3.1 Create the SubscribeKey of your target
40+ SubscribeKey subscribeKey = new SubscribeKey (" default" , " my-service" , configKind);
41+ // 3.2 Create the SubscribeInfo of your target by subscribeKey
42+ OpensergoClientSubscribeInfo subscribeInfo = new OpensergoClientSubscribeInfo (subscribeKey);
43+ // 3.3 Add a Subscriber for you target which would listen changes of target
44+ subscribeInfo. addSubscriber(new OpenSergoConfigSubscriber () {
4145 @Override
4246 public boolean onConfigUpdate (SubscribeKey subscribeKey , Object dataList ) {
43- // Handle received config here
47+ // TODO Handle received config here
4448 System . out. println(" key: " + subscribeKey + " , data: " + dataList);
4549 return true ;
4650 }
4751 });
52+
53+ // 4. Register into OpenSergoClient the SubscribeInfo which was builded above.
54+ // And then the client will subscribe config automatic.
55+ client. registerSubscribeInfo(subscribeInfo);
4856```
0 commit comments