Automation: Queue

Background

vikadata#4581

Concepts

  1. Flow(Robot): contains nodes (trigger and actions).

  2. Flow Queue: contains flow execution requests from multiple sources.

  3. Flow Worker: consume flow queue and obtaining the flow results.

Requirements

  1. Functional Requirements

    1. Create Flow Queue to add flow execution requests from multiple place(Datasheet OT, Form Submit...).

    2. Consume flow requests and executes flow(waiting).

  2. Non-Functional Requirements

    1. Queue tasks should be durable, doesn't get lost after shutting down the server.

    2. Flow requests should be ordered.

    3. When process flow requests unsuccessfully, it should be retry.

Implements

Concepts

Operation: A data structure that records the operations of a datasheet.

Changeset: The set of datasheet operations.

OP Event: Operation event is converted from operation.

Flow: contains nodes (trigger and actions).

Flow Run(Robot Histroy): The flow running record.

Process


Original robot process

Original robot process


New robot process

New robot process


Task status

Task status


Terminology

The flow queue is based on BullMQ, which would make it durable since it stores the tasks on redis

and the library also supports repeatable tasks.

BullMQ

BullMQ is a Node.js library that implements a fast and robust queue system built on top of Redis that helps in resolving many modern age micro-services architectures. Feature:

  • LIFO and FIFO jobs

  • Priorities

  • Delayed jobs

  • Scheduled and repeatable jobs according to cron specifications

  • Retries of failed jobs

  • ... ...

Q & A

  1. What are the advantages of BullMQ compared to message broker systems like RabbitMQ?

BullMQ is a Redis-based queue specifically designed for Node.js. It is best suited for the following scenarios:

Simple and lightweight: When you need a simple, lightweight, and easy-to-use queue system with a smaller footprint.

Redis compatibility: If your project already utilizes Redis as a data store, using BullMQ could be a natural choice for leveraging the same infrastructure.

Rate limiting: BullMQ has built-in support for rate limiting, which can be useful for scenarios where you want to control the processing rate of jobs.

Error handling: BullMQ has a well-defined error handling mechanism, which provides better control over job retries and failures.

  1. Why not use traditional message broker systems like RabbitMQ?

RabbitMQ is a better fit for complex, high-throughput, and advanced message routing scenarios. Moreover, the entity that is required to act as a job queue in this case is aimed at improving stability and decoupling modules. Currently, it is understood that BullMQ can meet the requirements of the queue.