When a user on our web site creates a record, we use a PreInsertEventListener to look for an HttpContext. If one exists, we can extrapolate the user and time zone from the claims.
For MassTransit jobs, we don’t have an HttpContext. We are using PublishContext and ConsumeContext to pass user information. I would like to get this information to the PreInsertEventListener (or to a interceptor if you prefer).
How can I retrieve state beyond an HttpContext in the PreInsertEventListener or to an interceptor? I would like to consume a scoped class that stores this data, but since it’s scoped, I need to create a scope to get the service, and the state is lost.
Any help would be greatly appreciated.
Thanks!