public class Changes
extends java.lang.Object
Contains the Change Notifications API, supports normal and continuous feed Changes.
// feed type normal
String since = dbClient.context().info().getUpdateSeq(); // latest update seq
ChangesResult changeResult = dbClient.changes()
.since(since)
.limit(10)
.filter("example/filter")
.getChanges();
for (ChangesResult.Row row : changeResult.getResults()) {
String docId = row.getId()
JsonObject doc = row.getDoc();
}
// feed type continuous
Changes changes = dbClient.changes()
.includeDocs(true)
.heartBeat(30000)
.continuousChanges();
while (changes.hasNext()) {
ChangesResult.Row feed = changes.next();
String docId = feed.getId();
JsonObject doc = feed.getDoc();
// changes.stop(); // stop continuous feed
}
ChangesResult| Modifier and Type | Method and Description |
|---|---|
Changes |
continuousChanges()
Requests Change notifications of feed type continuous.
|
Changes |
filter(java.lang.String filter) |
ChangesResult |
getChanges()
Requests Change notifications of feed type normal.
|
boolean |
hasNext()
Checks whether a feed is available in the continuous stream, blocking
until a feed is received.
|
Changes |
heartBeat(long heartBeat) |
Changes |
includeDocs(boolean includeDocs) |
Changes |
limit(int limit) |
ChangesResult.Row |
next() |
Changes |
since(java.lang.String since) |
void |
stop()
Stops a running continuous feed.
|
Changes |
style(java.lang.String style) |
Changes |
timeout(long timeout) |
public Changes continuousChanges()
Feed notifications are accessed in an iterator style.
Changespublic boolean hasNext()
public ChangesResult.Row next()
public void stop()
public ChangesResult getChanges()
ChangesResultpublic Changes since(java.lang.String since)
public Changes limit(int limit)
public Changes heartBeat(long heartBeat)
public Changes timeout(long timeout)
public Changes filter(java.lang.String filter)
public Changes includeDocs(boolean includeDocs)
public Changes style(java.lang.String style)
Copyright © 2011-2017. All Rights Reserved.