-
-
Notifications
You must be signed in to change notification settings - Fork 95
Open
Labels
component/integrationWeb framework integrationWeb framework integrationcomponent/mqMessage queue relatedMessage queue relateddriver/mysqlMySQL/MariaDB driver (@fedify/mysql)MySQL/MariaDB driver (@fedify/mysql)
Milestone
Description
Summary
Add a MysqlMessageQueue class to the @fedify/mysql package, implementing the MessageQueue interface backed by MySQL or MariaDB.
Motivation
Developers already using MySQL or MariaDB as their primary database should be able to use it as a Fedify message queue backend without introducing additional infrastructure such as Redis or RabbitMQ. This complements the MysqlKvStore implementation in the same package (#585).
Proposed API
import { createFederation } from "@fedify/fedify";
import { MysqlMessageQueue } from "@fedify/mysql";
import mysql from "mysql2/promise";
const pool = mysql.createPool("mysql://user:pass@localhost/db");
const federation = createFederation<void>({
queue: new MysqlMessageQueue(pool),
// ...
});Implementation notes
- Unlike
PostgresMessageQueue, which benefits from PostgreSQL'sLISTEN/NOTIFYfor real-time message delivery, MySQL and MariaDB have no equivalent mechanism. The implementation should use polling instead. SELECT ... FOR UPDATE SKIP LOCKEDshould be used to safely dequeue messages in concurrent multi-worker environments without contention. This syntax is available from MySQL 8.0 and MariaDB 10.6.- The polling interval should be configurable, with a sensible default (e.g., 1 second).
- Delayed message delivery (the
delayoption inMessageQueueEnqueueOptions) should be supported by storing adeliver_aftertimestamp and skipping messages that are not yet due. - The
enqueueMany()method should be implemented for better performance when enqueuing multiple messages at once. - The
nativeRetrialproperty should befalse, as retry logic is handled by Fedify itself. - Document the polling-based nature of this implementation and its latency characteristics compared to
PostgresMessageQueue.
Checklist
- Implement
MysqlMessageQueueclass in the@fedify/mysqlpackage - Support
enqueue(),enqueueMany(), andlisten()with polling - Support delayed delivery via
deliver_aftertimestamp - Write unit tests (with a real MySQL/MariaDB instance via Docker)
- Document the new
MessageQueuein docs/manual/mq.md
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
component/integrationWeb framework integrationWeb framework integrationcomponent/mqMessage queue relatedMessage queue relateddriver/mysqlMySQL/MariaDB driver (@fedify/mysql)MySQL/MariaDB driver (@fedify/mysql)
Type
Projects
Status
Backlog