com.mongodb.client.model.changestream.ChangeStreamDocument Java Examples

The following examples show how to use com.mongodb.client.model.changestream.ChangeStreamDocument. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MongoSourceTask.java    From mongo-kafka with Apache License 2.0 6 votes vote down vote up
/**
 * This method also is responsible for caching the {@code resumeAfter} value for the change
 * stream.
 */
private void setCachedResultAndResumeToken() {
  MongoChangeStreamCursor<ChangeStreamDocument<Document>> changeStreamCursor =
      getChangeStreamIterable(sourceConfig, mongoClient).cursor();
  ChangeStreamDocument<Document> firstResult = changeStreamCursor.tryNext();
  if (firstResult != null) {
    cachedResult =
        new BsonDocumentWrapper<>(
            firstResult,
            ChangeStreamDocument.createCodec(
                Document.class, MongoClientSettings.getDefaultCodecRegistry()));
  }
  cachedResumeToken =
      firstResult != null ? firstResult.getResumeToken() : changeStreamCursor.getResumeToken();
  changeStreamCursor.close();
}
 
Example #2
Source File: MongoDBSourceBuilder.java    From hazelcast-jet-contrib with Apache License 2.0 5 votes vote down vote up
StreamContext(
        MongoClient client,
        ChangeStreamIterable<? extends T> changeStreamIterable,
        FunctionEx<? super ChangeStreamDocument<? extends T>, U> mapFn,
        ConsumerEx<? super MongoClient> destroyFn,
        FunctionEx<? super MongoClient, ? extends BsonTimestamp> startAtOperationTimeFn
) {
    this.client = client;
    this.changeStreamIterable = changeStreamIterable;
    this.mapFn = mapFn;
    this.destroyFn = destroyFn;

    this.timestamp = startAtOperationTimeFn == null ? null : startAtOperationTimeFn.apply(client);
}
 
Example #3
Source File: MongoSourceTest.java    From pulsar with Apache License 2.0 5 votes vote down vote up
@Test
public void testWriteBadMessage() throws Exception {

    source.open(map, mockSourceContext);

    subscriber.onNext(new ChangeStreamDocument<Document>(null, new MongoNamespace("hello.pulsar"),
            new Document("hello", "pulsar"), new BsonDocument("_id", new BsonString("id")), OperationType.INSERT, null));

    Record<byte[]> record = source.read();

    assertEquals(new String(record.getValue()),
            "{\"fullDocument\":{\"hello\":\"pulsar\"},"
            + "\"ns\":{\"databaseName\":\"hello\",\"collectionName\":\"pulsar\",\"fullName\":\"hello.pulsar\"},"
            + "\"operation\":\"INSERT\"}");
}
 
Example #4
Source File: ReactiveMongoDatabaseImpl.java    From quarkus with Apache License 2.0 4 votes vote down vote up
@Override
public <T> Multi<ChangeStreamDocument<T>> watch(ClientSession clientSession, List<? extends Bson> pipeline,
        Class<T> clazz) {
    return Wrappers.toMulti(database.watch(clientSession, pipeline, clazz));
}
 
Example #5
Source File: ReactiveMongoDatabaseImpl.java    From quarkus with Apache License 2.0 4 votes vote down vote up
@Override
public Multi<ChangeStreamDocument<Document>> watch(List<? extends Bson> pipeline, ChangeStreamOptions options) {
    return null;
}
 
Example #6
Source File: ReactiveMongoClientImpl.java    From quarkus with Apache License 2.0 4 votes vote down vote up
@Override
public <T> Multi<ChangeStreamDocument<T>> watch(ClientSession clientSession, List<? extends Bson> pipeline,
        Class<T> clazz, ChangeStreamOptions options) {
    ChangeStreamPublisher<T> publisher = apply(options, client.watch(clientSession, pipeline, clazz));
    return Wrappers.toMulti(publisher);
}
 
Example #7
Source File: ReactiveMongoCollectionImpl.java    From quarkus with Apache License 2.0 4 votes vote down vote up
@Override
public <D> Multi<ChangeStreamDocument<D>> watch(List<? extends Bson> pipeline, Class<D> clazz) {
    return Wrappers.toMulti(collection.watch(pipeline, clazz));
}
 
Example #8
Source File: ReactiveMongoCollectionImpl.java    From quarkus with Apache License 2.0 4 votes vote down vote up
@Override
public Multi<ChangeStreamDocument<Document>> watch(List<? extends Bson> pipeline) {
    return Wrappers.toMulti(collection.watch(pipeline));
}
 
Example #9
Source File: ReactiveMongoCollectionImpl.java    From quarkus with Apache License 2.0 4 votes vote down vote up
@Override
public <D> Multi<ChangeStreamDocument<D>> watch(Class<D> clazz) {
    return Wrappers.toMulti(collection.watch(clazz));
}
 
Example #10
Source File: ReactiveMongoClientImpl.java    From quarkus with Apache License 2.0 4 votes vote down vote up
@Override
public <T> Multi<ChangeStreamDocument<T>> watch(ClientSession clientSession, List<? extends Bson> pipeline,
        Class<T> clazz) {
    return Wrappers.toMulti(client.watch(clientSession, pipeline, clazz));
}
 
Example #11
Source File: ReactiveMongoDatabaseImpl.java    From quarkus with Apache License 2.0 4 votes vote down vote up
@Override
public <T> Multi<ChangeStreamDocument<T>> watch(ClientSession clientSession, List<? extends Bson> pipeline,
        Class<T> clazz, ChangeStreamOptions options) {
    return null;
}
 
Example #12
Source File: ReactiveMongoDatabaseImpl.java    From quarkus with Apache License 2.0 4 votes vote down vote up
@Override
public <T> Multi<ChangeStreamDocument<T>> watch(ClientSession clientSession, Class<T> clazz,
        ChangeStreamOptions options) {
    return null;
}
 
Example #13
Source File: ReactiveMongoCollectionImpl.java    From quarkus with Apache License 2.0 4 votes vote down vote up
@Override
public <D> Multi<ChangeStreamDocument<D>> watch(List<? extends Bson> pipeline, Class<D> clazz,
        ChangeStreamOptions options) {
    return Wrappers.toMulti(apply(options, collection.watch(pipeline, clazz)));
}
 
Example #14
Source File: ReactiveMongoDatabaseImpl.java    From quarkus with Apache License 2.0 4 votes vote down vote up
@Override
public Multi<ChangeStreamDocument<Document>> watch(ClientSession clientSession, ChangeStreamOptions options) {
    return null;
}
 
Example #15
Source File: ReactiveMongoDatabaseImpl.java    From quarkus with Apache License 2.0 4 votes vote down vote up
@Override
public <T> Multi<ChangeStreamDocument<T>> watch(ClientSession clientSession, Class<T> clazz) {
    return Wrappers.toMulti(database.watch(clientSession, clazz));
}
 
Example #16
Source File: ReactiveMongoDatabaseImpl.java    From quarkus with Apache License 2.0 4 votes vote down vote up
@Override
public <T> Multi<ChangeStreamDocument<T>> watch(List<? extends Bson> pipeline, Class<T> clazz,
        ChangeStreamOptions options) {
    return null;
}
 
Example #17
Source File: ReactiveMongoClientImpl.java    From quarkus with Apache License 2.0 4 votes vote down vote up
@Override
public <T> Multi<ChangeStreamDocument<T>> watch(Class<T> clazz, ChangeStreamOptions options) {
    ChangeStreamPublisher<T> publisher = apply(options, client.watch(clazz));
    return Wrappers.toMulti(publisher);
}
 
Example #18
Source File: ReactiveMongoDatabaseImpl.java    From quarkus with Apache License 2.0 4 votes vote down vote up
@Override
public <T> Multi<ChangeStreamDocument<T>> watch(List<? extends Bson> pipeline, Class<T> clazz) {
    return Wrappers.toMulti(database.watch(pipeline, clazz));
}
 
Example #19
Source File: ReactiveMongoDatabaseImpl.java    From quarkus with Apache License 2.0 4 votes vote down vote up
@Override
public Multi<ChangeStreamDocument<Document>> watch(ClientSession clientSession) {
    return Wrappers.toMulti(database.watch(clientSession));
}
 
Example #20
Source File: ReactiveMongoDatabaseImpl.java    From quarkus with Apache License 2.0 4 votes vote down vote up
@Override
public Multi<ChangeStreamDocument<Document>> watch(List<? extends Bson> pipeline) {
    return Wrappers.toMulti(database.watch(pipeline));
}
 
Example #21
Source File: ReactiveMongoDatabaseImpl.java    From quarkus with Apache License 2.0 4 votes vote down vote up
@Override
public <T> Multi<ChangeStreamDocument<T>> watch(Class<T> clazz, ChangeStreamOptions options) {
    return null;
}
 
Example #22
Source File: ReactiveMongoDatabaseImpl.java    From quarkus with Apache License 2.0 4 votes vote down vote up
@Override
public <T> Multi<ChangeStreamDocument<T>> watch(Class<T> clazz) {
    return Wrappers.toMulti(database.watch(clazz));
}
 
Example #23
Source File: ReactiveMongoDatabaseImpl.java    From quarkus with Apache License 2.0 4 votes vote down vote up
@Override
public Multi<ChangeStreamDocument<Document>> watch(ChangeStreamOptions options) {
    return null;
}
 
Example #24
Source File: ReactiveMongoDatabaseImpl.java    From quarkus with Apache License 2.0 4 votes vote down vote up
@Override
public Multi<ChangeStreamDocument<Document>> watch() {
    return Wrappers.toMulti(database.watch());
}
 
Example #25
Source File: ReactiveMongoClientImpl.java    From quarkus with Apache License 2.0 4 votes vote down vote up
@Override
public Multi<ChangeStreamDocument<Document>> watch(ClientSession clientSession, ChangeStreamOptions options) {
    ChangeStreamPublisher<Document> publisher = apply(options, client.watch(clientSession));
    return Wrappers.toMulti(publisher);
}
 
Example #26
Source File: ReactiveMongoClientImpl.java    From quarkus with Apache License 2.0 4 votes vote down vote up
@Override
public <T> Multi<ChangeStreamDocument<T>> watch(ClientSession clientSession, Class<T> clazz) {
    return Wrappers.toMulti(client.watch(clientSession, clazz));
}
 
Example #27
Source File: ReactiveMongoClientImpl.java    From quarkus with Apache License 2.0 4 votes vote down vote up
@Override
public Multi<ChangeStreamDocument<Document>> watch(ClientSession clientSession, List<? extends Bson> pipeline,
        ChangeStreamOptions options) {
    ChangeStreamPublisher<Document> publisher = apply(options, client.watch(clientSession, pipeline));
    return Wrappers.toMulti(publisher);
}
 
Example #28
Source File: ReactiveMongoClientImpl.java    From quarkus with Apache License 2.0 4 votes vote down vote up
@Override
public <T> Multi<ChangeStreamDocument<T>> watch(List<? extends Bson> pipeline, Class<T> clazz,
        ChangeStreamOptions options) {
    ChangeStreamPublisher<T> publisher = apply(options, client.watch(pipeline, clazz));
    return Wrappers.toMulti(publisher);
}
 
Example #29
Source File: ReactiveMongoCollectionImpl.java    From quarkus with Apache License 2.0 4 votes vote down vote up
@Override
public <D> Multi<ChangeStreamDocument<D>> watch(Class<D> clazz, ChangeStreamOptions options) {
    return Wrappers.toMulti(apply(options, collection.watch(clazz)));
}
 
Example #30
Source File: ReactiveMongoCollectionImpl.java    From quarkus with Apache License 2.0 4 votes vote down vote up
@Override
public Multi<ChangeStreamDocument<Document>> watch(List<? extends Bson> pipeline, ChangeStreamOptions options) {
    return Wrappers.toMulti(apply(options, collection.watch(pipeline)));
}