Getting Started
This guide will help you set up JoobQ, a high-performance job queue system for the Crystal programming language. Follow these steps to integrate JoobQ into your project and start managing background jobs efficiently.
Prerequisites
Before installing JoobQ, ensure your system meets the following requirements:
Crystal Language: Version 1.0 or later. Install Crystal.
Redis: JoobQ uses Redis as its backend for queue management. Ensure Redis is installed and running on your system.
Install Redis: Redis Installation Guide.
Installation Styles
JoobQ is a robust job queue and scheduler library for the Crystal programming language, designed to handle background tasks efficiently. Depending on your application's architecture, you can set up JoobQ in three distinct configurations:
Client Only: For applications that enqueue jobs without processing them locally.
Client with Embedded Server: For applications that both enqueue and process jobs within the same environment.
Server Only: For dedicated job processing servers that handle jobs from multiple clients.
Below are detailed installation and configuration guides for each setup.
1. Client Only Setup
This configuration is ideal for applications that need to enqueue jobs to be processed by external workers.
Prerequisites
Crystal Language: Ensure Crystal is installed on your system. Install Crystal
Redis Server: JoobQ utilizes Redis for job storage. Install Redis
Installation Steps
Add JoobQ to Your Project
Include JoobQ in your
shard.yml
dependencies:Install Dependencies
Run the following command to install the dependencies:
Configure JoobQ
Set up JoobQ to connect to the Redis server:
Enqueue Jobs
Define your job classes and enqueue jobs as needed:
2. Client with Embedded Server Setup
This setup is suitable for applications that enqueue and process jobs within the same environment.
Prerequisites
Crystal Language: Ensure Crystal is installed on your system. Install Crystal
Redis Server: JoobQ utilizes Redis for job storage. Install Redis
Installation Steps
Add JoobQ to Your Project Include JoobQ in your
shard.yml
dependencies:Install Dependencies Run the following command to install the dependencies:
Configure JoobQ Set up JoobQ with queue definitions and scheduling:
Start the JoobQ Server Run the following command to start processing jobs:
3. Server Only Setup
This configuration is intended for dedicated servers that process jobs from multiple clients.
Prerequisites
Crystal Language: Ensure Crystal is installed on your system. Install Crystal
Redis Server: JoobQ utilizes Redis for job storage. Install Redis
Installation Steps
Add JoobQ to Your Project
Include JoobQ in your
shard.yml
dependencies:Install Dependencies
Run the following command to install the dependencies:
Configure JoobQ
Set up JoobQ with queue definitions:
Start the JoobQ Server
Run the following command to start processing jobs:
By following the appropriate setup guide, you can configure JoobQ to match your application's architecture, ensuring efficient job queuing and processing.
Additional Features
REST API: Enable the REST API for monitoring queues and jobs:
Cron Schedules: Use cron-like expressions for job scheduling:
Middlewares: Customize job execution with middleware:
Troubleshooting
Redis Connection Issues: Ensure Redis is running and accessible at the default host (
localhost
) and port (6379
).Missing Jobs: Confirm that all job classes are required in your application.
Worker Not Processing Jobs: Verify that the worker process is running and that jobs are being enqueued.
Congratulations! JoobQ is now installed and ready to handle your background tasks. Explore the JoobQ Documentation for advanced configurations and features.
Last updated