I have a case, when saga is executed using User’s authentication. For this I have used a WorkerInterceptor setting up authentication based on passed token before the activity code is executed.
However for the compensation, I need to authenticate a system user, as user’s authentication may no longer be valid (= expired) and all compensating activities still need to pass. So the question is - inside of the WorkerInterceptor, can i retrieve information, whether saga is being compensated, co I can change authentication method?
You can pass this information through the header or rely on the activity naming convention. For example, you can prefix their name with “compensate.”
I hoped there is some internal flag or something that could be used. Alright, I will just add another context propagator with this flag that I will set upon saga compensation.
For the naming convention it is not very plausible as I reuse some activities for normal execution and for compensation (And adding separated compensation activities just for this would result in too much code).
Thank you.