Is there a way to manage JPA auditing (createdBy user) when a Temporal activity method is invoked?
In our application, data persistence is done via both HTTP requests and Temporal activities.
We have an authorization header per HTTP request and we use it to create UserPrinciple for JPA auditing (here we know the UserPrinciple bean will be in the Spring IoC request bean scope).
But when a temporal activity is invoked, in which Spring IoC bean scope will the activity be executed?
If it is in the request scope too, is it okay to pass the auth token with the Activity method parameters?
Please let me know if there is another standardised way to do this.
Activities are executed in a different process than the workflow code (or in a different worker). When workflow code executes an activity, an activityTask is scheduled in the server and a worker (can be the same or another worker) will pick up the activity task and execute it.
You can pass the token from your workflow code to the activity as input (You can use data converters to encrypt the token if security concerns you)