Skip to content

Commit 6295c16

Browse files
authored
Merge pull request #114009 from SnehaGunda/tabbedconceptual
Adding tabs
2 parents 73e3d3d + a8e6cff commit 6295c16

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

articles/cosmos-db/create-sql-api-java-changefeed.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ mvn clean package
8484

8585
Press enter. Now the following block of code will execute and initialize the Change Feed processor on another thread:
8686

87+
# [Java SDK 4.0](#tab/v4sdk)
8788

8889
**Java SDK 4.0**
8990
```java
@@ -98,6 +99,8 @@ mvn clean package
9899
while (!isProcessorRunning.get()); //Wait for Change Feed processor start
99100
```
100101
102+
# [Java SDK 3.7.0](#tab/v3sdk)
103+
101104
**Java SDK 3.7.0**
102105
```java
103106
changeFeedProcessorInstance = getChangeFeedProcessor("SampleHost_1", feedContainer, leaseContainer);
@@ -110,7 +113,8 @@ mvn clean package
110113
111114
while (!isProcessorRunning.get()); //Wait for Change Feed processor start
112115
```
113-
116+
---
117+
114118
```"SampleHost_1"``` is the name of the Change Feed processor worker. ```changeFeedProcessorInstance.start()``` is what actually starts the Change Feed processor.
115119
116120
Return to the Azure Portal Data Explorer in your browser. Under the **InventoryContainer-leases** container, click **items** to see its contents. You will see that Change Feed Processor has populated the lease container, i.e. the processor has assigned the ```SampleHost_1``` worker a lease on some partitions of the **InventoryContainer**.
@@ -119,6 +123,8 @@ mvn clean package
119123
120124
1. Press enter again in the terminal. This will trigger 10 documents to be inserted into **InventoryContainer**. Each document insertion appears in the Change Feed as JSON; the following callback code handles these events by mirroring the JSON documents into a materialized view:
121125
126+
# [Java SDK 4.0](#tab/v4sdk)
127+
122128
**Java SDK 4.0**
123129
```java
124130
public static ChangeFeedProcessor getChangeFeedProcessor(String hostName, CosmosAsyncContainer feedContainer, CosmosAsyncContainer leaseContainer) {
@@ -145,6 +151,8 @@ mvn clean package
145151
}
146152
```
147153
154+
# [Java SDK 3.7.0](#tab/v3sdk)
155+
148156
**Java SDK 3.7.0**
149157
```java
150158
public static ChangeFeedProcessor getChangeFeedProcessor(String hostName, CosmosContainer feedContainer, CosmosContainer leaseContainer) {
@@ -170,6 +178,7 @@ mvn clean package
170178
typeContainer.upsertItem(document).subscribe();
171179
}
172180
```
181+
---
173182
174183
1. Allow the code to run 5-10sec. Then return to the Azure Portal Data Explorer and navigate to **InventoryContainer > items**. You should see that items are being inserted into the inventory container; note the partition key (```id```).
175184
@@ -185,6 +194,8 @@ mvn clean package
185194
186195
Hit enter again to call the function ```deleteDocument()``` in the example code. This function, shown below, upserts a new version of the document with ```/ttl == 5```, which sets document Time-To-Live (TTL) to 5sec.
187196
197+
# [Java SDK 4.0](#tab/v4sdk)
198+
188199
**Java SDK 4.0**
189200
```java
190201
public static void deleteDocument() {
@@ -212,6 +223,7 @@ mvn clean package
212223
feedContainer.upsertItem(document,new CosmosItemRequestOptions()).block();
213224
}
214225
```
226+
# [Java SDK 3.7.0](#tab/v3sdk)
215227
216228
**Java SDK 3.7.0**
217229
```java
@@ -240,6 +252,7 @@ mvn clean package
240252
feedContainer.upsertItem(document,new CosmosItemRequestOptions()).block();
241253
}
242254
```
255+
---
243256
244257
The Change Feed ```feedPollDelay``` is set to 100ms; therefore, Change Feed responds to this update almost instantly and calls ```updateInventoryTypeMaterializedView()``` shown above. That last function call will upsert the new document with TTL of 5sec into **InventoryContainer-pktype**.
245258

0 commit comments

Comments
 (0)