Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How I access correlationId within BackgroundJob? #19717

Open
CaglarMacha opened this issue May 6, 2024 · 3 comments
Open

How I access correlationId within BackgroundJob? #19717

CaglarMacha opened this issue May 6, 2024 · 3 comments

Comments

@CaglarMacha
Copy link

CaglarMacha commented May 6, 2024

Documentation

Please check the official documentation before asking questions: https://docs.abp.io

GitHub Issues

GitHub issues are for bug reports, feature requests, and other discussions about the framework.

If you're creating a bug/problem report, please include the followings:

  • Your ABP Framework version.
  • Your User Interface type (Angular/MVC/React... etc.) if the issue is related to a specific UI
  • Your database provider(EF Core/MongoDB)
  • Exception message and stack trace if available (check the logs).
  • Steps needed to reproduce the problem.

Please write in English.

Stack Overflow

Please use Stack Overflow for your questions about using the framework, templates, and samples:

https://stackoverflow.com/questions/tagged/abp

Use abp tag in your questions.

ABP Framework version = 5.3.3
Db Provider = EF Core

We use background jobs within some of our AppService or manager class. However, we want to access the correlationId information from Audit logs within these jobs. How can I access correlationId within jobs?. We don't want to pass the correlationId information as a parameter.

@maliming
Copy link
Member

maliming commented May 7, 2024

hi

We don't want to pass the correlationId information as a parameter.

It seems this is the only way to get correlationid in BackgroundJob.

@CaglarMacha
Copy link
Author

hi

We don't want to pass the correlationId information as a parameter.

It seems this is the only way to get correlationid in BackgroundJob.

Thank you so much your answer. Maybe I can create an interface or class to access the correlationId information, and then have my job classes derive from this interface so that they can automatically set the correlationId information. I thought this could be one way, do you have any other recommendations? What's the best practice according to you?

@maliming
Copy link
Member

maliming commented May 7, 2024

hi

The correlationId is related to HttpContext, so it can't be used in a BackgroundJob.

https://github.com/abpframework/abp/blob/dev/framework/src/Volo.Abp.AspNetCore/Volo/Abp/AspNetCore/Tracing/AbpCorrelationIdMiddleware.cs#L24-L44

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants