2

For my project I'm creating a queueing mechanism based on the Command Pattern, which can execute one of a number of jobs. Jobs can add other jobs to the queue or can be added by a human. Most of the jobs are done after executing once, but certain jobs will need to be rescheduled at a later time.

I decided I want to create a seperate dataset about jobs that need to be rescheduled and create a seperate process that loops over these at a set interval to add new jobs to the queue.

I'm stuck at what's the right naming convention for my dataset and (looping) process for rescheduling jobs. My thinking is that it's going to look something like this:

My datasets:

  • Job (in the queue) - Information about which job to execute.
  • Incident Report - Any result that needs to more attention gets logged here.
  • Result (multiple) - All data that resulted from the executed jobs.
  • Scheduled Job (What to call?) - Information about a job that needs to be executed in the future and the timestamp my process needs to add the job to the queue.

My objects:

  • Client - A object that gets a job from the queue and maps to a specific command class and passes it to the command invoker.
  • Command (multiple) - Contains logic to of the job and job data to pass around dependencies.
  • Command Invoker - Gives the final call to execute the command and removes it from the queue afterwards. This class will probably also be responsible for updating data about scheduled jobs.
  • Job Scheduler - A independent object that can add jobs at any time from a job that's being executed.

I'm not sure if I need to add the process of rescheduling jobs as a a seperate job or as a different application altogether. I hope somebody can give me some advice of how to go forward.

1 Answer 1

1

Scheduled

  • Technically a scheduled job implies a job scheduler. You talk about writing your own scheduler but normally this would be handled at quite a low level and takes into account things like available resources and job priority, not just when the job wants to be run.
  • In English, I would say that scheduled implies a timetable.

Deferred

  • Technically implies that the job is waiting for something, an external service to become available or resources to be freed up.
  • But again, in English I might be expecting the opposite to be true, deferred referring to the fact that the job is put off until some defined time.

Personally I'd go with the first: scheduled job. You plan on writing something you are going to call a job scheduler and not a deferred job handler, so that makes sense.

PS. I don't know if this would fit with the rest of your system, but have you considered creating threads that wait for the deferral period to pass before checking the queue. Java for example has a Thread.sleep(timePeriod) method otherwise you would still have the computational over head of the thread having to wake up every so often to check what time it was but at least it wouldn't be accessing your data structure each time.

1
  • Thanks, great insights but I'm still not sure about how to implement it Mar 24, 2015 at 18:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.