-
Feb 23rd, 2011, 11:35 AM
#1
Job Share Objects
How Can I share objects beetwen different jobs ?
I've one job launched by other jobs with JobLauncher but it only accepts in the run method simple parameters like String,Date, etc..Can I extend JobLauncher ?
How differents job can comunicate ?
Can someone help me?
-
Feb 24th, 2011, 03:06 AM
#2
you can use plain Spring beans to share something between jobs (as long as the jobs are running in the same Spring application context.) The Spring beans - some kind of "holders" - would be injected in the artifacts (readers, writer, listeners) of the different jobs. But be careful with that: you're basically coupling the jobs with each other. Don't forget also to clean the holder beans between execution, so that a job doesn't use the data from a previous run.
Did you also think about storing what you need in the database?
-
Feb 24th, 2011, 05:03 AM
#3
Thank you for your answer,
i'll try to describe my scenario:
i have a job that loads some data, creates my domain-model object and starts a job. the domain model object has to be shared with the job launched by the first job because the second job requests some resources using a method inside the domain model and start a thread for each resource it obtains. After this (when all the threads ends well) the second job calls a final method inside the domain model object.
what do you recommend me to do? should i try to use a single job with two steps and one of this steps should be partitionized?
-
Feb 24th, 2011, 06:40 AM
#4
Why don't simply make a job with 2 steps?
having a dedicate child app ctx for each job execution, and have the shared data as one plain spring bean in the job and inject into that 2 step artifacts
-
Feb 24th, 2011, 09:02 AM
#5
could you give me an example?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules