Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save logentries-gists/9fc00b458705aa17742975acb107f4f8 to your computer and use it in GitHub Desktop.

Select an option

Save logentries-gists/9fc00b458705aa17742975acb107f4f8 to your computer and use it in GitHub Desktop.
/**
* sends batch job to a queue for further processing.
*
* @param job
* task that will be serialized and sent to queue
* @return true if job has been successfully queued
*/
public boolean sendJobToWaitQueue(Batch job) {
LOGGER.debug("Trying to push job to queue: " + job.toString());
String jobJson = batchToJson(job);
Jedis instance = null;
try {
instance = this.jedisPool.getResource();
// left push to a wait queue
instance.lpush(waitQueue, jobJson);
LOGGER.debug("Job successfully published to channel {} {}", waitQueue, jobJson);
return true;
} catch (Exception e) {
LOGGER.error("Problem while publishing message to a channel", e);
return false;
} finally {
instance.close();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment