dart_pgmq 1.0.0 copy "dart_pgmq: ^1.0.0" to clipboard
dart_pgmq: ^1.0.0 copied to clipboard

A dart client for Postgres Message Queue (PGMQ).

Dart PGMQ #

A dart client for Postgres Message Queue (PGMQ).

Usage #

# Start a Postgres instance
docker run -d --name postgres -e POSTGRES_PASSWORD=postgres -p 5432:5432 quay.io/tembo/pg16-pgmq:latest
# Connect to Postgres
psql postgres://postgres:postgres@0.0.0.0:5432/postgres
-- create the pgmq schema
CREATE SCHEMA pgmq;
-- create the extension in the "pgmq" schema
CREATE EXTENSION pgmq;

Then #

// Create a database connection
final databaseParam = DatabaseConnection(
      host: 'localhost',
      database: 'postgres',
      password: 'postgres',
      username: 'postgres',
      ssl: false,
      port: 5432);
// Create a pgmq connection with DatabaseConnection param
final pgmq = await Pgmq.createConnection(param: databaseParam);
// Create a queue [queueName]
final queue = await pgmq.createQueue(queueName: queueName);
// Send a message
queue.send({"foo": "bar"});
// Read a message with visibilityTimeOut
queue.read(visibilityTimeOut: vt);
// Archive a message [messageID]
queue.archive(messageID);
// Delete a message [messageID]
queue.delete(messageID);
// Pull messages from queue with a specified polling duration
queue.pull(duration: duration);
// Pausable pull
final (pausableTimer, stream) = queue.pausablePull(duration: duration);
// Start the pausable pull
pausableTimer.start();
// Pause the pulling
pausableTimer.pause();
// Read a message from queue and delete it upon read
queue.pop();
// Purge all messages from queue
queue.purgeQueue();
// Drops the queue
queue.dropQueue();

Supported Functionalities #

Customs Features #

  • ✅ Pausable Queue