Spring Boot JPA auditing with Temporal Activities

Hi, I’m relatively new to using temporal,

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.

Thanks in Advance! :slightly_smiling_face:

Hello @dulith

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)

Or you can use Context Propagator, see this example. sdk-java/ContextPropagationTest.java at master · temporalio/sdk-java · GitHub

Let me know if it helps,

Hi @antonio.perez

Thanks for the insight, I will look into data converters and use auth token in the request metadata.

Thanks again,