Reuse of the workflow stubs

mnkartik
Wed, 12 Jul 2023 15:08:34 +0000
Community Support

Hello Team,

Based on this topic

Thread safety and reusability of Stubs and Implementations Community Support

From the documentation, it’s not immediately clear what can be a DI Scope of Activity/Workflow Implementation/Stub. What can be a singleton and what should be created for each invocation of the workflow? Activity Implementation Activity implementations are Singletons, stateless, and reused across workflows and worker threads. Activity Stub Should each instance of a workflow implementation create or use its own set of activity stubs? Is it a correct implementation to create an activity stub …

Below is the scenario

T1 time :

Workflow instance ( wf-obj1) is created

From client side workflow stub ( wf-stub-obj1) is created

The same stub ( wf-stub-obj1 ) is reused for sending multiple signals, to the
same workflow instance ( wf-obj1 )

T2 time :

Workflow instance (wf-obj1) is crashed and recreated from history events with new instance ( wf-obj2)

Question ?

Considering this scenario, From client side can we still use workflow stub (wf-stub-obj1 ) to send signals to workflow instance (wf-obj2) or do we need to recreate the stubs.

Is it a good practice to cache the stubs ( to preserve cpu and memory resources ) or recreate everytime

2 posts - 2 participants