|
13 | 13 | import com.azure.cosmos.examples.common.CustomPOJO2; |
14 | 14 | import com.azure.cosmos.implementation.Utils; |
15 | 15 | import com.azure.cosmos.implementation.apachecommons.lang.RandomStringUtils; |
| 16 | +import com.azure.cosmos.models.ChangeFeedProcessorOptions; |
16 | 17 | import com.azure.cosmos.models.CosmosContainerProperties; |
17 | 18 | import com.azure.cosmos.models.CosmosContainerRequestOptions; |
18 | 19 | import com.azure.cosmos.models.CosmosContainerResponse; |
|
21 | 22 | import com.fasterxml.jackson.core.JsonProcessingException; |
22 | 23 | import com.fasterxml.jackson.databind.JsonNode; |
23 | 24 | import com.fasterxml.jackson.databind.ObjectMapper; |
| 25 | + |
24 | 26 | import org.slf4j.Logger; |
25 | 27 | import org.slf4j.LoggerFactory; |
26 | 28 | import reactor.core.scheduler.Schedulers; |
@@ -49,11 +51,20 @@ public class SampleChangeFeedProcessor { |
49 | 51 | private static ChangeFeedProcessor changeFeedProcessorInstance; |
50 | 52 | private static boolean isWorkCompleted = false; |
51 | 53 |
|
| 54 | + private static ChangeFeedProcessorOptions options; |
| 55 | + |
| 56 | + |
| 57 | + |
52 | 58 | public static void main(String[] args) { |
53 | 59 | logger.info("BEGIN Sample"); |
54 | 60 |
|
55 | 61 | try { |
56 | 62 |
|
| 63 | + // <ChangeFeedProcessorOptions> |
| 64 | + options = new ChangeFeedProcessorOptions(); |
| 65 | + options.setStartFromBeginning(false); |
| 66 | + // </ChangeFeedProcessorOptions> |
| 67 | + |
57 | 68 | //Summary of the next four commands: |
58 | 69 | //-Create an asynchronous Azure Cosmos DB client and database so that we can issue async requests to the DB |
59 | 70 | //-Create a "feed container" and a "lease container" in the DB |
@@ -129,6 +140,7 @@ public static void main(String[] args) { |
129 | 140 | public static ChangeFeedProcessor getChangeFeedProcessor(String hostName, CosmosAsyncContainer feedContainer, CosmosAsyncContainer leaseContainer) { |
130 | 141 | return new ChangeFeedProcessorBuilder() |
131 | 142 | .hostName(hostName) |
| 143 | + .options(options) |
132 | 144 | .feedContainer(feedContainer) |
133 | 145 | .leaseContainer(leaseContainer) |
134 | 146 | .handleChanges((List<JsonNode> docs) -> { |
|
0 commit comments