Announcement Announcement Module
Collapse
No announcement yet.
SimpleAsyncTaskExecutor not transfering data from calling thread Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • SimpleAsyncTaskExecutor not transfering data from calling thread

    I am having a job which is running for longer time as it has around 100000 records.

    To make it running quicker I thought of introducing SimpleAsyncTaskExecutor instead of running in single thread model.

    In my setup, jobs are created dynamically and scheduled using quartz. Quartz create a thread and put the required parameter in the thread from the database for that job to execute. This thread calls the spring batch job. This Job is configured to use SimpleAsyncTaskExecutor, so it creates several threads and start the process.

    It looks like the assumption is every step should have all the information to execute a job, I believe most of the time we need information from exeternal source, in my case it is from thread local objects. But spring not carrying this information to the new threads and this breaks my application.

    Is there a way to intercept and pass this thread local object information to the newly created threads.

    Kindly help me if anybody have an answer or alternative approach to my problem.

    Thanks
    Lakshmanan

  • #2
    What is it that is using thread local to transfer state? If you control that code one option would be to try using InheritableThreadLocal. Or you could refactor it to not use thread local. Or to transfer the data from thread local to one of the context objects in Batch. Or (probably the easiest) transfer to a field in your own class and declare the bean definition to be step scoped, so that there is one instance per execution.

    Comment

    Working...
    X