Background service that implements the Outbox Pattern to ensure reliable event publishing for the Thmanyah platform.
The Outbox Publisher service is responsible for:
This service is part of the Thmanyah microservices architecture:
Example :CMS API โ Database (Outbox Table) โ Outbox Publisher โ Redis Queue โ Sync Worker
The Outbox Publisher implements the Outbox Pattern to ensure reliable event publishing.
# Install dependencies (from root)
pnpm install
# Start in development mode
pnpm --filter outbox-publisher dev
# Or from the app directory
cd apps/outbox-publisher
pnpm dev
Required environment variables (see root .env.example
):
# Database
DATABASE_HOST=localhost
DATABASE_PORT=5432
DATABASE_USERNAME=postgres
DATABASE_PASSWORD=password
DATABASE_NAME=thmanyah
# Redis
REDIS_HOST=localhost
REDIS_PORT=6379
REDIS_PASSWORD=
# Node environment
NODE_ENV=development
# Unit tests
pnpm --filter outbox-publisher test
# E2E tests
pnpm --filter outbox-publisher test:e2e
# Test coverage
pnpm --filter outbox-publisher test:cov
# Watch mode
pnpm --filter outbox-publisher test:watch
# Development
pnpm dev # Start in development mode
pnpm start # Start in production mode
pnpm start:dev # Start with watch mode
pnpm start:debug # Start in debug mode
pnpm start:prod # Start in production mode
# Testing
pnpm test # Run unit tests
pnpm test:watch # Run tests in watch mode
pnpm test:cov # Run tests with coverage
pnpm test:debug # Run tests in debug mode
pnpm test:e2e # Run e2e tests
# Building
pnpm build # Build the application
pnpm build:watch # Build in watch mode
# Linting
pnpm lint # Run ESLint
pnpm lint:fix # Fix ESLint issues
apps/outbox-publisher/
โโโ src/
โ โโโ app.module.ts # Main application module
โ โโโ main.ts # Application entry point
โ โโโ common/ # Shared utilities
โ โโโ outbox-publisher/ # Outbox publishing logic
โ โโโ outbox-publisher.service.ts
โ โโโ outbox-publisher.service.spec.ts
โโโ test/ # E2E tests
โโโ package.json
The service expects an outbox table with the following structure:
Example :CREATE TABLE outbox (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
eventType VARCHAR NOT NULL,
payload JSONB NOT NULL,
createdAt TIMESTAMP DEFAULT NOW(),
processed BOOLEAN DEFAULT FALSE
);
REDIS_HOST=localhost
REDIS_PORT=6379
REDIS_PASSWORD=
# Build image
docker build --build-arg TARGET_APP=outbox-publisher -t thmanyah/outbox-publisher .
# Run container
docker run --env-file .env thmanyah/outbox-publisher
# Build for production
pnpm --filter outbox-publisher build
# Start production server
pnpm --filter outbox-publisher start:prod
Events not being processed
High error rates
Performance issues
The service provides detailed logging for:
This project is part of the Thmanyah backend system and is licensed under the MIT License.