Skip to content

Add MySQL support for delayed message publishing#51

Merged
m110 merged 3 commits intoThreeDotsLabs:masterfrom
AdrianZajkowski:add-delayed-mysql-publisher
Oct 22, 2025
Merged

Add MySQL support for delayed message publishing#51
m110 merged 3 commits intoThreeDotsLabs:masterfrom
AdrianZajkowski:add-delayed-mysql-publisher

Conversation

@AdrianZajkowski
Copy link
Copy Markdown
Contributor

@AdrianZajkowski AdrianZajkowski commented Oct 22, 2025

Motivation / Background

This PR adds MySQL support for delayed message publishing. It is based on PostgreSQL implementation adapted to MySQL.
Currently only PostgreSQL is supported.

Details

The implementation adds five new files that provide MySQL - specific functionality:

delayed_mysql.go:
• DelayedMySQLPublisher wraps the standard publisher with Watermill's delay component
• DelayedMySQLSubscriber uses MySQL's new column delayed_until
• Automatically creates indexes on the delay metadata for optimal query performance
• Supports both required delays and optional "no delay" messages

queue_schema_adapter_mysql.go:
• Provides an alternative to consumer group-based processing
• Supports custom WHERE clauses for flexible message filtering
• Configurable batch sizes for performance tuning
• Uses FOR UPDATE locking to prevent message duplication

queue_offsets_adapter_mysql.go:
• Handles message acknowledgment through either deletion or marking as acked
• Supports batch acknowledgment for better performance
• No consumer group support (by design - uses simple queue semantics)

Checklist

The resources of our team are limited. There are a couple of things that you can do to help us merge your PR faster:

  • I wrote tests for the changes.
  • All tests are passing.
    • If you are testing a Pub/Sub, you can start Docker with make up.
    • You can start with make test_short for a quick check.
    • If you want to run all tests, use make test.
  • Code has no breaking changes.
  • (If applicable) documentation on watermill.io is updated.

@m110
Copy link
Copy Markdown
Member

m110 commented Oct 22, 2025

@AdrianZajkowski thanks for contributing! Can you check the tests? It seems the index is broken.

could not initialize schema: Error 3753: Cannot create a functional index on a function that returns a JSON or GEOMETRY value.

@AdrianZajkowski
Copy link
Copy Markdown
Contributor Author

@m110 should be fixed now ;)

@m110 m110 merged commit 4683792 into ThreeDotsLabs:master Oct 22, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants