Step 10 of 21 · 4 minutes

VIP Treatment

The Scenario

The job queue has 10,000 monthly statements, but a customer just made a payment that needs to be processed urgently.

Payments are revenue. Reports can wait. We need a way to prioritize.

The Challenge

How do we ensure critical jobs jump the queue and get processed immediately?

The Solution

Use Priority Queues to define job importance:


jobScheduler.create(aJob()
    .withQueue("High") // You can also use an enum for this
    .withDetails(() -> createCreditCard(card)));

// or via the @Job annotation
@Job(queue = "High")
public void processPayment(Payment payment) { ... }

@Job(queue = "Low")
public void generateReport() { ... }

Configure the queues in order of priority. JobRunr always processes higher-priority queues first.

Read the documentation →

Try It Yourself

  1. Trigger 1000 expense reports (low priority)
  2. Make a payment (high priority)
  3. Watch the payment complete immediately despite the backlog!
You need to log in to perform write operations. You can still view the code solution and dashboard.
Loading code...
1
Generate 1000 Expenses
2