{"id":43605,"library":"pgdb-queue","title":"pgdb-queue","description":"pgdb-queue v1.1.2 is a lightweight, Kafka-style asynchronous message queue built on PostgreSQL, eliminating the need for Kafka, Redis, or additional infrastructure. It uses PostgreSQL's LISTEN/NOTIFY for efficient, zero-polling wake-ups after draining, and row-level locking with FOR UPDATE SKIP LOCKED for concurrency. The library is ideal for startups or small apps needing reliable background processing with minimal operational overhead. It ships TypeScript types and provides a simple producer/consumer API with automatic retries and FIFO ordering.","status":"active","version":"1.1.2","language":"javascript","source_language":"en","source_url":"https://github.com/SHIVAJIKUMAR007/dbqueue","tags":["javascript","queue","messaging queue","async communication","typescript"],"install":[{"cmd":"npm install pgdb-queue","lang":"bash","label":"npm"},{"cmd":"yarn add pgdb-queue","lang":"bash","label":"yarn"},{"cmd":"pnpm add pgdb-queue","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"PostgreSQL client driver required for database connectivity","package":"pg","optional":false}],"imports":[{"note":"ESM-only; CommonJS require must use default import or named property access.","wrong":"const initQueue = require('pgdb-queue').initQueue","symbol":"initQueue","correct":"import { initQueue } from 'pgdb-queue'"},{"note":"Named export; use destructured import in ESM.","wrong":"const produce = require('pgdb-queue').produce","symbol":"produce","correct":"import { produce } from 'pgdb-queue'"},{"note":"startConsumer is a named export, not default. TypeScript users must use named import.","wrong":"import startConsumer from 'pgdb-queue'","symbol":"startConsumer","correct":"import { startConsumer } from 'pgdb-queue'"}],"quickstart":{"code":"import { initQueue, produce, startConsumer } from 'pgdb-queue';\n\n// Initialize queue (table autocreated)\nawait initQueue(\n  process.env.DATABASE_URL ?? 'postgres://user:pass@localhost:5432/mydb',\n  'public.message_queue'\n);\n\n// Produce a message\nawait produce('email-topic', JSON.stringify({ to: 'user@example.com', subject: 'Welcome!' }));\n\n// Start consumer with auto-wake\nawait startConsumer('email-topic', async (msg: string, id: number) => {\n  const data = JSON.parse(msg);\n  console.log(`Processing message ${id}:`, data);\n}, { rateLimitMs: 10 });","lang":"typescript","description":"Demonstrates initializing the queue, producing a JSON message, and starting a continuous consumer with auto-wake via LISTEN/NOTIFY."},"warnings":[{"fix":"Wrap objects with JSON.stringify() before producing.","message":"Messages must be string type; use JSON.stringify for non-string data.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Ensure initQueue is awaited exactly once at startup.","message":"initQueue must be called before any produce/consume/startConsumer.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use 'schema.table' format when passing table name to initQueue.","message":"Table name must include schema (e.g., 'public.my_queue'), not just table name.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use startConsumer() for automatic wake and drainage.","message":"consume() is a manual consumer; prefer startConsumer() for continuous processing.","severity":"deprecated","affected_versions":">=1.0.0"}],"env_vars":null,"search_vec":"'addit':27 'api':82 'app':64 'async':93 'asynchron':14 'automat':84 'background':67 'built':17 'communic':94 'concurr':55 'drain':43 'effici':35 'elimin':20 'fifo':87 'ideal':59 'infrastructur':28 'javascript':89 'kafka':12,24 'kafka-styl':11 'level':47 'librari':57 'lightweight':10 'listen/notify':33 'lock':48,53 'messag':15,91 'minim':70 'need':22,65 'oper':71 'order':88 'overhead':72 'pgdb':2,5 'pgdb-queue':1,4 'poll':38 'postgresql':19,31 'process':68 'producer/consumer':81 'provid':78 'queue':3,6,16,90,92 'redi':25 'reliabl':66 'retri':85 'row':46 'row-level':45 'ship':74 'simpl':80 'skip':52 'small':63 'startup':61 'style':13 'type':76 'typescript':75,95 'up':41 'updat':51 'use':30 'v1.1.2':7 'wake':40 'wake-up':39 'zero':37 'zero-pol':36","created_at":"2026-06-05T17:00:36.149398+00:00","updated_at":"2026-06-05T17:00:36.149398+00:00","problems":[{"fix":"Ensure initQueue completes before any other operations.","cause":"Missing or incorrect pg client version or pool not initialized via initQueue.","error":"Error: listen is not a function"},{"fix":"Call await initQueue(...) with correct schema-qualified table name.","cause":"initQueue was not called or table creation failed due to missing schema.","error":"error: relation \"public.message_queue\" does not exist"},{"fix":"Check database connection string and ensure initQueue resolves successfully.","cause":"initQueue failed or pool not initialized.","error":"TypeError: Cannot read properties of undefined (reading 'query')"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/SHIVAJIKUMAR007/dbqueue#readme","github":"https://github.com/SHIVAJIKUMAR007/dbqueue","docs":null,"changelog":null,"pypi":null,"npm":"pgdb-queue","openapi_spec":null,"status_page":null,"smithery":null,"categories":["messaging"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-05","next_check":"2026-09-03","install_tag":null}}