Skip to content
This repository has been archived by the owner on Feb 23, 2023. It is now read-only.

Mongo Change Streams Doesn't Work with v0.12.x #1706

Closed
SentryMan opened this issue Aug 29, 2022 · 12 comments
Closed

Mongo Change Streams Doesn't Work with v0.12.x #1706

SentryMan opened this issue Aug 29, 2022 · 12 comments
Labels
for: external-project For an external project and not something we can fix

Comments

@SentryMan
Copy link

SentryMan commented Aug 29, 2022

So, I'm working with Mongo change streams.

reactiveMongoTemplate.changeStream("Manga", FULL_DOC, Manga.class)
But I'm getting this error when I try to subscribe to events:

Error processing com.mongodb.reactivestreams.client.internal.MongoDatabaseImpl@414f8bf8 Exception is org.bson.codecs.configuration.CodecConfigurationException: Invalid @BsonCreator constructor in ChangeStreamDocument. Invalid Property type for 'operationType'. Expected class com.mongodb.client.model.changestream.OperationType, found class java.lang.String.

I have added the ChangeStreamDocument class to my reflection config, and It works fine when I'm not running on the binary.

Here is my repo: https://github.com/SentryMan/Manga-Spring-Backend/blob/8bd0c2367265fc4e7fedb67be2aecd9deb4e4816/src/main/java/com/mangasite/services/MangaService.java#L94-L95

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Aug 29, 2022
@sdeleuze sdeleuze added type: question A question and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Aug 30, 2022
@sdeleuze
Copy link
Contributor

Maybe you miss a type/reflection hint on com.mongodb.client.model.changestream.OperationType.

@sdeleuze sdeleuze added status: waiting-for-feedback We need additional information before we can continue and removed type: question A question labels Aug 30, 2022
@SentryMan SentryMan changed the title Mongo Change Streams Suddenly Not Working with Mongo Change Streams Suddenly Not Working with Native Image Aug 30, 2022
@SentryMan
Copy link
Author

SentryMan commented Aug 31, 2022

Yeah, this doesn't work SentryMan/Manga-Spring-Backend@5d3ee9c

Also, I had it working before without needing to add reflection. I only recently noticed it had stopped working. I personally suspect that when this constructor got deprecated something broke.

    @Deprecated
    public ChangeStreamDocument(final OperationType operationType,
            final BsonDocument resumeToken,
            final BsonDocument namespaceDocument,
            final BsonDocument destinationNamespaceDocument,
            final TDocument fullDocument,
            final BsonDocument documentKey,
            final BsonTimestamp clusterTime,
            final UpdateDescription updateDescription,
            final BsonInt64 txnNumber,
            final BsonDocument lsid) 

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Aug 31, 2022
@sdeleuze
Copy link
Contributor

Your repro is using an outdated RC, please use Spring Native 0.12.1 with latest Spring Boot 2.7.x version.

@sdeleuze sdeleuze added status: waiting-for-triage An issue we've not yet triaged or decided on status: waiting-for-feedback We need additional information before we can continue and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Aug 31, 2022
@SentryMan
Copy link
Author

SentryMan commented Aug 31, 2022

That was the first thing I tried. https://github.com/SentryMan/Manga-Spring-Backend/blob/a9931a7876e45f3c55694e8d698df2c14edfe6eb/pom.xml
On the fix branch I was running 2.7.3 with 0.12.1

@spring-projects-issues spring-projects-issues removed the status: waiting-for-feedback We need additional information before we can continue label Aug 31, 2022
@SentryMan
Copy link
Author

It seems when I revert the version to spring native 11.4 / 2.6.6 it works

@SentryMan SentryMan changed the title Mongo Change Streams Suddenly Not Working with Native Image Mongo Change Streams Doesn't Work with v12 Sep 1, 2022
@SentryMan SentryMan changed the title Mongo Change Streams Doesn't Work with v12 Mongo Change Streams Doesn't Work with v0.12.x Sep 1, 2022
@SentryMan
Copy link
Author

Yeah, the problem seems to start at v0.12.0

@sdeleuze
Copy link
Contributor

sdeleuze commented Sep 7, 2022

Could be missing reflection hints on the parameters that are used to identify the new constructor reflectively. Please make a try with reflection hints for all the parameter types used in ChangeStreamDocument constructors.

@sdeleuze sdeleuze added the status: waiting-for-feedback We need additional information before we can continue label Sep 7, 2022
@SentryMan
Copy link
Author

That also didn't work

@spring-projects-issues spring-projects-issues removed the status: waiting-for-feedback We need additional information before we can continue label Sep 8, 2022
@SentryMan
Copy link
Author

How shall we proceed?

@sdeleuze
Copy link
Contributor

I tried https://github.com/SentryMan/Manga-Spring-Backend/blob/a9931a7876e45f3c55694e8d698df2c14edfe6eb/pom.xml, but when running it with mvn spring-boot:build-image + docker run docker.io/library/manga-backend:3.0.0, I get a Could not resolve placeholder 'SECRET_KEY' in value "${SECRET_KEY}". So if you want some help from me, please provide a repro that works, some thing where for example Mongo and the native app runs via Docker Compose with the various environnement variable set.

@sdeleuze sdeleuze added status: waiting-for-feedback We need additional information before we can continue and removed status: feedback-provided Feedback has been provided labels Sep 23, 2022
@SentryMan
Copy link
Author

I have created an example repo to show this error https://github.com/SentryMan/Spring-Native-Mongo-Change-Stream

@spring-projects-issues spring-projects-issues added the status: feedback-provided Feedback has been provided label Sep 26, 2022
@spring-projects-issues spring-projects-issues removed the status: waiting-for-feedback We need additional information before we can continue label Sep 26, 2022
@sdeleuze
Copy link
Contributor

sdeleuze commented Jan 2, 2023

Spring Native is now superseded by Spring Boot 3 official native support, see the related reference documentation for more details.

As a consequence, I am closing this issue, and recommend trying your use case with latest Spring Boot 3 version. If you still experience the issue reported here, please open an issue directly on the related Spring project (Spring Framework, Data, Security, Boot, Cloud, etc.) with a reproducer.

Thanks for your contribution on the experimental Spring Native project, we hope you will enjoy the official native support introduced by Spring Boot 3.

@sdeleuze sdeleuze closed this as completed Jan 2, 2023
@sdeleuze sdeleuze added for: external-project For an external project and not something we can fix and removed status: feedback-provided Feedback has been provided labels Jan 2, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
for: external-project For an external project and not something we can fix
Development

No branches or pull requests

3 participants