
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
A strongly typed, fast, developer friendly job-queue for node.js backed by Redis Streams.
redqueue is a lightweight and flexible library designed for managing message queues using Redis. It simplifies the definition and handling of distributed tasks, making it perfect for situations where you need to process tasks concurrently or in a specific order. By leveraging Redis Streams, redqueue efficiently handles message distribution, persistence, and consumer management.
redqueue is more than just a queue library—it's also an event-driven messaging library. With its simple and strongly typed API, it allows you to easily build event-based architectures. However, it's important to note that redqueue is not your traditional queue library.
redqueue is exceptionally fast, thanks to its use of Redis Streams. However, this performance comes with certain trade-offs. Unlike traditional task-queue libraries, redqueue does not support features like delayed tasks, cron jobs, or anything that isn't an "event to act on now." If your use case requires undelayed action on events, redqueue is the right choice.
To install redqueue, simply use npm or yarn:
npm install redqueue
or
yarn add redqueue
Redis-Based Message Queue: redqueue utilizes Redis for efficient and reliable message queueing, allowing for distributed task processing across multiple consumers.
Task Definition with Handlers: Define tasks with custom handlers that process messages as they are received. Each task is tied to a specific queue, allowing for organized and scalable task management.
Concurrency Control: Set the concurrency level for each queue, controlling the number of simultaneous task executions. This ensures optimal resource utilization and task throughput.
Message Acknowledgment: Messages are acknowledged after successful processing, ensuring that tasks are only marked as completed when they've been fully handled. This prevents message loss or duplication.
Flexible Configuration: Easily configure Redis connection options, queue behaviors, and handler functions to fit your application's needs.
Consumer Management: Start and stop consumers with simple commands. The library handles message dispatch and task execution, making it easy to manage consumers in a distributed environment.
Support for Complex Workflows: Chain tasks together by sending new messages from within handlers, enabling complex workflows like multi-stage processing or task delegation.
TypeScript Support: Written in TypeScript, redqueue provides type safety and IntelliSense support, ensuring a robust development experience.
Automatic Task Re-scheduling: Failed tasks can be retried or moved to a dead-letter queue depending on your specific needs, providing resilience in your task processing pipeline.
Graceful Shutdown: Consumers can be gracefully awaited and stopped, ensuring that all in-progress tasks are completed before shutdown, which helps in maintaining data consistency.
To start using redqueue, you need to define your queues and their associated handlers. Each queue can process messages with a specific concurrency level, allowing you to control how many tasks are handled simultaneously.
import { defineQu, type IQuMessage } from "redqueue";
const redisOptions = {
// Your Redis connection options here
};
const qu = defineQu(redisOptions, {
"order.placed": {
handler: async (message: IQuMessage<{ orderId: string }>) => {
// Handle the order
await qu.send("order.process", { orderId: message.payload.orderId });
await message.ack(); // Acknowledge message completion
},
concurrency: 2, // Process two orders concurrently
},
"order.process": {
handler: async (message: IQuMessage<{ orderId: string }>) => {
console.log(`Processing order ${message.payload.orderId}`);
await message.ack();
},
concurrency: 5, // Process up to five tasks concurrently
},
});
Once you've defined your queues, you need to start the consumers that will process incoming messages.
async function main() {
await qu.startConsumers(); // Start the consumers
console.log("Consumers are running! Stop with ctrl-c");
}
void main();
To send a message to a queue, use the send method. This will place a message in the queue, where it will be picked up by the appropriate handler.
qu.send("order.placed", { orderId: "12345" });
defineQudefineQu(redisOptions: RedisOptions, queues: { [key: string]: QueueDefinition }): QuInstance;
Defines a set of queues with associated handlers and concurrency settings.
redisOptions: Configuration object for Redis connection.queues: An object where keys are queue names and values are queue definitions including handlers and options like concurrency levels.sendsend(queueName: string, payload: any): Promise<void>;
Sends a message to the specified queue.
queueName: The name of the queue to send the message to.payload: The data to be sent with the message.startConsumersstartConsumers(): Promise<void>;
Starts the consumers to begin processing messages.
awaitConsumersawaitConsumers(): Promise<void>;
Waits for the consumers to finish processing messages. Useful for ensuring a graceful shutdown.
awaitConsumers to ensure all in-progress tasks are completed before shutting down your application.redqueue is designed for immediate task execution and does not support delayed tasks or scheduled jobs.Contributions are welcome! Please open an issue or submit a pull request on GitHub if you have ideas for improvements or new features.
redqueue is licensed under the MIT License. See the LICENSE file for more details.
FAQs
Fast, scalable, and reliable queues backed by Redis Streams
We found that redqueue demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.