Skip to content

ReactiveMongoTemplate does not return ChangeStreamEvents with PreImages #4495

Closed
@PhilippAllstadt

Description

@PhilippAllstadt

Hi @ALL,

in our use case we have the requirement to consume changestream events with pre-images. We are using MongoDB version 6.0.7.
Further, our spring version is the newest and we are using the latest mongodb drivers.

Despite it, delete and update events haven´t filled fullDocumentBeforeChange in raw if event is consumed in our spring app.

In database. pre-images should work because we´ve tested consuming via mongosh shell.

This is our code to consume change stream in our spring app:

var collectionChangeStream = reactiveMongoTemplate .changeStream(TransactionEntity.class) .withOptions( (optionsBuilder) -> optionsBuilder .returnFullDocumentBeforeChange() .returnFullDocumentOnUpdate()) .watchCollection("transaction");

if (changeStreamToken.isPresent() && changeStreamToken.get().getToken() != null) {
  collectionChangeStream.resumeAfter(changeStreamToken.get().getToken());
} else {
  collectionChangeStream.resumeAt(Instant.now().minusSeconds(seconds));
}

return collectionChangeStream.listen();

Am I missing something?

Thank you very much.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions