Reactive support within activity

Are there any mongo reactive driver examples within activity. We have a reactive spring boot application which uses reactive mongo driver. Trying to see if there are any limitations on using the reactive mongo streams.
In case of Spring REST API usually the caller will block to trigger the reactive chain. Would like to understand how can this be handled within temporal activity classes.

Can activity returns Mono or Flux ?

2 Likes

I do not believe we have any examples of mongo integration. Maxim might know something I don’t.

I’m not familiar with the requirements these streams impose. Is ability to complete activity asynchronously without tying a thread to its execution enough?

Look at the async activity completion sample.. Is it what you need?

This is not for async operations.

To handle the back pressure scenarios(to handle better concurrency) we use reactive mongo and reactive rest client in our application. The mongo return Mono and rest return Mono. In order to read the response the client need to subscribe to the Mono. Trying to understand how does this work in temporal if activity returns Mono

I briefly looked at this page: https://dimitr.im/difference-between-mono-and-flux.

And from it, it sounds like that it is about asynchronous programming. For example, you can use subscribe to complete activity asynchronously:

Publisher<Whatever> result = foo();
result.subscribe(.... /* complete activity here */);

For backpressure, we are going to implement this issue.

Am I missing something?

If reactor type interfaces are common we could create much tighter integration that would allow passing Mono and Flux objects between workflows and activities directly.

Publish/Subscribe separates the request and process happen on worker threads. From the client perspective its still synchronous call.

The issue mentioned does help manage the resources within the worker.

I am trying to find out if backpressure is really a concern with GRPC/RSocket based implementations.