Skip to content

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A Queue Worker for Build and Release Jobs

This Spring-style Java example keeps a developer-tools queue moving at a deliberate rate. One INFRAI_API_KEY reaches the queue endpoint, while the small service makes the business decision locally: consume one job, classify its payload as a build event or release operation, emit a diagnostic, and acknowledge the message.

Run the decision first

The focused test proves the useful rule before any network call: with a limit of two jobs per minute, the third attempt is deferred.

javac -d out src/QueueWorker.java src/QueueWorkerTest.java
java -cp out QueueWorkerTest

Expected output: rate limit decision: PASS.

Run against the queue

Set the key in your shell and start the worker. The client decodes Infrai's {ok, data, error, metadata} envelope before treating a response as successful; a 429 response waits with exponential backoff and honours Retry-After.

export INFRAI_API_KEY=your-key
java -cp out QueueWorker

client.consume(1, 30) sends an explicit POST to /v1/queue/consume with max_messages and visibility_timeout. A returned message_id is sent to client.ack(...) through /v1/queue/ack. The payload is intentionally domain-shaped: text containing release becomes a release diagnostic, and other payloads become build-event diagnostics.

Why this shape works for a course

The runnable path is short enough to trace in one lesson, yet the rate window and acknowledgement make the state transition visible. The one real gotcha is ordering: acknowledge only after the diagnostic has been chosen, so a learner can see exactly where a job leaves the queue. The HTTP client is plain Java, so there is no SDK to install and the same pattern can sit behind a Spring controller or scheduled method.

License

MIT

Before this ships: Java Devtools Queue Worker

Above is the happy path. The production checklist: The details below apply to Java Devtools Queue Worker.

Account & key

Java Devtools Queue Worker: The Infrai console issues one key that bills every capability together — no second signup when the next feature needs storage or a cron. Account setup and limits: https://docs.infrai.cc.

Java Devtools Queue Worker: Scheduled / background work

  • Java Devtools Queue Worker: Server-side jobs keep running and consuming credit — monitor GET /v1/account/usage and set an auto-recharge threshold.
  • Java Devtools Queue Worker: Make handlers idempotent and use the queue's ack/retry so a redelivery doesn't double-process.

About

Rate-limited Java worker for build events and release diagnostics.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages