public class Changes
extends java.lang.Object
Contains the Change Notifications API, supports normal and continuous feed Changes.
Usage example for normal feed limiting to 10 results, with a filter:
// feed type normal
String since = db.info().getUpdateSeq(); // latest update seq
ChangesResult changeResult = db.changes()
.since(since)
.limit(10)
.filter("example/filter")
.getChanges();
//process the ChangesResult
for (ChangesResult.Row row : changeResult.getResults()) {
String docId = row.getId()
JsonObject doc = row.getDoc();
}
Usage example for continuous feed, including document content:
// feed type continuous
Changes changes = db.changes()
.includeDocs(true)
.heartBeat(30000)
.continuousChanges();
while (changes.hasNext()) {
ChangesResult.Row feed = changes.next();
String docId = feed.getId();
JsonObject doc = feed.getDoc();
}
//while loop blocks; stop from another thread
changes.stop(); // stop continuous feed
ChangesResult
,
Databases -
get changesModifier 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.
public boolean hasNext()
public ChangesResult.Row next()
public void stop()
public ChangesResult getChanges()
ChangesResult
encapsulating the normal feed changespublic Changes since(java.lang.String since)
public Changes limit(int limit)
public Changes filter(java.lang.String filter)
public Changes heartBeat(long heartBeat)
public Changes timeout(long timeout)
public Changes includeDocs(boolean includeDocs)
public Changes style(java.lang.String style)