MongoDB Java Driver Create a tailable cursor


Example

find(query).projection(fields).cursorType(CursorType.TailableAwait).iterator();

That code applies to the MongoCollection class.

CursorType is an enum and it has the following values:

Tailable
TailableAwait

Corresponding to the old (<3.0) DBCursor addOption Bytes types:

Bytes.QUERYOPTION_TAILABLE
Bytes.QUERYOPTION_AWAITDATA