Cron jobs accessing request scoped variables #4897
Unanswered
karuppannanp
asked this question in
Q&A
Replies: 1 comment 1 reply
-
You would have to use a mock request such as |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have an application that calls an external service (using RxHttpClient) to get some data and stores them in the application (static global variable) during startup. This variable is refreshed by a cron job scheduled to run at a particular interval by calling the external service. And also, there is rest endpoint that is exposed in the application to manually trigger this refresh process.
I have a
@RequestScope
java class that is used for customized auditing when calling external http service. If the scheduled cron job runs, there is an exception in accessing the request scoped object. The exception isNo bean of type [com.xxxxxxx.yyyyy.model.servicetiming.ServiceTimingTrace] exists for the given qualifier: @RequestScope. Make sure the bean is not disabled by bean requirements (enable trace logging for 'io.micronaut.context.condition' to check) and if the bean is enabled then ensure the class is declared a bean and annotation processing is enabled (for Java and Kotlin the 'micronaut-inject-java' dependency should be configured as an annotation processor).
Is there any way to overcome this error like we do in spring
RequestContextHolder.setRequestAttributes(new RequestAttributes() { }
Beta Was this translation helpful? Give feedback.
All reactions