Do you have some jobs that can only be run on certain servers (e.g. jobs tied to a specific OS like Linux, Max and Windows)? Or do you want to run a job only on the server that created the job? JobRunr has you covered with Server Tags!
BackgroundJobServer can have multiple server tags and a job can specify only one server tag via the Job annotation. If the server tag of the job matches any of the server tags of the server, the server is eligible to run the job.
Jobis by default tagged with the
DEFAULTtag - this makes sure that if you do not specify a tag on the
Job, it gets executed anyway.
Using server tags is as easy as using Queues, again thanks to the
Job annotation. Just add it to your service method and specify on which server your background job should run.
When you are using the
JobBuilder pattern, you can pass the serverTag via the
Run job on the server that created the job
A special server tag is available to run a job on the server that created that same job. This comes in handy when you want to run a job that uses a resource (like a file, …) that is only available on the server that created the job.
In that case, you can use the following:
Configuration is easy, both in the fluent api and using Spring configuration:
Using the fluent API, pass all the server tags as Strings (or string constants) to the
For the Spring configuration, you can use the
org.jobrunr.background-job-server.tags property to set the different server tags.