Examples
Explore practical examples of using amqp-contract.
Available Examples
Basic Order Processing
A complete example demonstrating:
- Contract definition with exchanges, queues, and bindings
- Type-safe message publishing
- Type-safe message consuming
- Multiple consumers (pub/sub pattern)
Technologies: RabbitMQ • TypeScript • Zod
Running Examples
All examples are in the examples/ directory.
Prerequisites
- RabbitMQ running on
localhost:5672
bash
docker run -d --name rabbitmq -p 5672:5672 -p 15672:15672 rabbitmq:4-management- Build packages (in repository root)
bash
pnpm buildRun Basic Order Processing
bash
# Terminal 1: Start the worker
pnpm --filter @amqp-contract-examples/basic-order-processing-worker dev
# Terminal 2: Run the client
pnpm --filter @amqp-contract-examples/basic-order-processing-client devExample Structure
The basic order processing example uses three packages:
examples/
├── basic-order-processing-contract/
│ └── src/index.ts # Shared contract
├── basic-order-processing-client/
│ └── src/index.ts # Publisher
└── basic-order-processing-worker/
└── src/index.ts # ConsumerThis separation mirrors real-world microservices architecture.
Architecture Overview
Next Steps
- Try the Basic Order Processing example
- Read the Getting Started guide