nsqdelay can be used for sending delayed messages on top of NSQ, it listens on the delayed topic by default (configurable) and receives JSON encoded messages with the following structure:
{
"topic": "my_topic",
"body": "message_body",
"send_at": 1234567890
}It persists the messages to an SQLite file database and publishes them when the time comes.
- Delayed message delivery based on Unix timestamps
- SQLite persistence for reliability
- Automatic retry for failed message publishing
- Configurable delayed topic name
- Docker and Docker Compose support
For all command line arguments use:
docker run --rm gbenhaim/nsqdelay -hRun with Docker:
docker run -d --name nsqdelay \
-v /path/to/data:/data \
gbenhaim/nsqdelay \
-lookupd_http_address=http://nsqlookupd:4161 \
-nsqd_tcp_address=nsqd:4150A docker-compose.yml file is included for easy setup with NSQ:
docker-compose up -dThis will start:
- nsqlookupd (ports 4160-4161)
- nsqd (ports 4150-4151)
- nsqdelay (connected to the NSQ cluster)
-lookupd_http_address: NSQ lookupd HTTP address (default: "http://127.0.0.1:4161")-nsqd_tcp_address: NSQ daemon TCP address (default: "127.0.0.1:4150")-topic: Topic to subscribe for delayed messages (default: "delayed")-db_path: Path to SQLite database file (default: "/data/nsqdelay.db")
# Clone the repository
git clone https://github.com/bsphere/nsqdelay.git
cd nsqdelay
# Build with Go modules
go build -o nsqdelay .
# Or build with Docker
docker build -t nsqdelay .- Mount the
/datavolume to persist delayed messages across container restarts - The SQLite database file is stored at
/data/nsqdelay.dbby default - Messages are automatically retried if publishing fails