Implement support for the push model in the pubsub extension #776
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds support for the push model for PubSub. The current version only supports the pull model, where the application needs a constantly running application thread which monitors the pubsub infrastructure for new messages and dispatches them accordingly. This works fine for hosted applications, but not for applications running on e.g. Cloud Run. The push model, which this PR supports. fixes that as in this model, a HTTP call is made by the PubSub broker to the application to deliver the messages.
This PR changes the object returned by the Subscriber methods in QuarkusPubSub to use the interface instead of the actual Subscriber class implementation. This has the added benefit of being able to switch automatically between the push and pull model without any code changes (only a property needs to be changed). Especially when testing, this is convenient as running a push model from a test is not fully supported by the current emulators. Using this setup, the user of the extension can use a pull model when running tests, and a push model when running in production without code changes.
Note that this change is of course backwards incompatible. However:
var
keywordGiven the above the ease of testing was valued over the downside of a backwards incompatible change.
The PR adds a programmatic reactive route which is used to listen for new messages. Authentication is implemented using a RouteFilter as per the recommended practices in the Google PubSub documentation.
Two new dependencies are introduced in the PR to support this model: quarkus-reactive-routes and google-api-client. These dependencies are not needed in the pull scenario. I decided against marking these dependencies are optional (and letting the user include them in case the push model is used), because: