Worker Pause Logic Explanation - gresrun/jesque GitHub Wiki

So let's walk through a scenario; we have a single worker and a single client and a job type that takes a long time.

  1. Client enqueues the job
  2. Worker takes the job and begins processing - Worker.isPaused() == false - Worker.isProcessingJob() == true - Worker's status as reported in Redis is showing the current job. (This is what is shown in (R/J)esque-Web Console)
  3. Client (via an AdminClient) issues a togglePausedWorkers(true) command
  4. Worker's Admin receives and processes the pause command, which calls Worker.togglePause(true) - Worker.isPaused() == true - Worker.isProcessingJob() == true - Worker's status as reported in Redis is still showing the current job.
  5. Worker completes the current job. - Worker.isPaused() == true - Worker.isProcessingJob() == false - Worker's status as reported in Redis is now "paused"

So, in effect, Worker.isPaused() is indicative of whether the Worker has been asked to be paused and can be used in conjunction with Worker.isProcessingJob() to see if it has paused yet. The status in Redis does not indicate whether the Worker has been asked to be paused but is only the actual state (paused or processing a job).