An enterprise-ready sample application demonstrating how to build message-driven services with activemq, along with other libraries from the Core TS ecosystem.
This project shows how to integrate:
- activemq for messaging
- validation-core for input validation
- mysql2-core for database access
- message-processing for processing pipeline
- health-service for health monitoring
- config-plus for configuration
- logger for structured logging
Rather than being a simple producer/consumer demo, this sample demonstrates how these libraries work together in a real-world message processing application.
HTTP API
│
▼
Application Context
│
┌───────────────┴───────────────┐
│ │
▼ ▼
Sender Receiver
│ │
│ ▼
│ Message Processor
│ │
│ ▼
│ Validation
│ │
│ ▼
│ Retry Logic
│ │
│ ▼
│ MySQL Persistence
│
▼
ActiveMQ
- Send messages to ActiveMQ
- Receive messages from ActiveMQ
- Strongly typed message processing
- Validation pipeline
- Retry handling
- Database persistence
- Dependency Injection
- Configuration management
- Logging
- Health checks
- REST API for testing
src
├── application
│ ├── context.ts
│ ├── processor.ts
│ ├── sender.ts
│ └── receiver.ts
│
├── model
│
├── repository
│
├── validation
│
├── retry
│
├── config
│
├── health
│
└── index.ts
The project is organized into independent layers, making it easy to extend or replace individual components.
- Node.js 18+
- ActiveMQ
- MySQL
npm installConfigure your ActiveMQ and MySQL connection.
Example:
{
"amq": {
"host": "localhost",
"port": 5672,
"username": "admin",
"password": "admin"
},
"mysql": {
"host": "localhost",
"database": "sample",
"user": "root",
"password": "password"
}
}npm startor
npm run devThe application exposes an endpoint for publishing messages.
POST /send
Example:
{
"id": "1001",
"name": "John",
"email": "john@example.com"
}The request is converted into a typed message and published to ActiveMQ.
A background receiver listens to the configured queue.
For every incoming message the application executes the following pipeline:
Receive Message
│
▼
Validate
│
▼
Business Processing
│
▼
Retry Logic
│
▼
Persist to MySQL
Messages are automatically accepted when processing succeeds and rejected when an exception occurs.
Before business logic executes, incoming messages are validated using validation-core.
This keeps validation separate from message processing and ensures only valid data reaches the business layer.
The sample demonstrates a retry pipeline for failed messages.
Instead of mixing retry logic into business code, failures are delegated to a dedicated retry component.
This separation keeps the processor focused on business logic.
Processed messages are persisted using mysql2-core.
The sample demonstrates how messaging and database access can be combined while keeping infrastructure concerns isolated from business logic.
The application exposes a health endpoint.
GET /health
The response includes the status of infrastructure components such as ActiveMQ.
Example:
{
"status": "UP",
"activemq": {
"status": "UP",
"connected": true
}
}This makes the application suitable for Kubernetes readiness and liveness probes.
The application uses an application context to wire together all infrastructure services.
ApplicationContext
│
├── Sender
├── Receiver
├── Processor
├── Repository
├── Validator
└── Health
Keeping dependencies centralized makes the application easier to test and maintain.
This sample demonstrates several enterprise software design principles:
- Layered architecture
- Dependency Injection
- Separation of concerns
- Typed messaging
- Validation pipeline
- Retry pipeline
- Health monitoring
- Infrastructure abstraction
Each responsibility is implemented by a dedicated component, making the system easier to extend and maintain.
- activemq
- rhea
- mysql2-core
- validation-core
- message-processing
- health-service
- config-plus
This sample demonstrates how to:
- Connect to ActiveMQ
- Publish messages
- Consume messages
- Build a processing pipeline
- Validate incoming data
- Persist processed messages
- Implement retry logic
- Monitor application health
- Organize an enterprise TypeScript application
Many messaging examples demonstrate only how to publish or consume messages.
This sample goes further by showing how messaging integrates into a complete application architecture, including validation, persistence, retry handling, health monitoring, and dependency injection.
It provides a practical foundation for building production-ready event-driven applications with activemq.
- activemq — Lightweight ActiveMQ client built on top of rhea
- message-processing — Processing pipeline framework
- validation-core — Object validation
- mysql2-core — MySQL abstraction library
- health-service — Health monitoring framework
MIT