Skip to content

RabbitMQ based job queue library for client and server.

License

Notifications You must be signed in to change notification settings

VEuPathDB/lib-rabbit-job-queue

Repository files navigation

RabbitMQ Job Queue

GitHub release (latest by date) Docs

Client/server library for utilizing RabbitMQ as a job queue.

Usage

Gradle
  implementation("org.veupathdb.lib:rabbit-job-queue:1.0.0")

Worker / Client

Java
var client = new QueueWorker(new QueueConfig());

client.onJob(job -> {

  // Do some work here.

  if (success)
    client.sendSuccess(new SuccessNotification(job.getJobID()));
  else
    client.sendError(new ErrorNotification(job.getJobID(), errorCode));
});
Kotlin
val client = QueueWorker {}

client.onJob {
  // Do some work here.

  if (success)
    client.sendSuccess(SuccessNotification(it.jobID))
  else
    client.sendError(ErrorNotification(it.jobID, errorCode))
}

Dispatcher / Server

Java
var dispatch = new QueueDispatcher(new QueueConfig());

dispatch.onSuccess(msg -> {
  // Do something with the job success
});

dispatch.onError(err -> {
  // Do something with the job error
});

dispatch.dispatch(new JobDispatch(
  someJobID,
  "jobType",
  body
));
Kotlin
val dispatch = QueueDispatcher {}

dispatch.onSuccess {
  // Do something with the job success
}

dispatch.onError {
  // Do something with the job error
}

dispatch.dispatch(JobDispatch(
  someJobID,
  "jobType",
  body
))