Core MQ client library for RabbitMQ - shared by infrastructure services and connectors
npm install @onlineapps/mq-client-coreCore MQ client library for RabbitMQ - shared by infrastructure services and connectors.
This is the core library extracted from @onlineapps/conn-infra-mq to provide basic MQ functionality for infrastructure services (gateway, registry, validator) without business-specific features.
Architecture Principle: Connectors are exclusively for business services. If a connector contains functionality that should also serve infrastructure services, it must be extracted into a shared library.
``bash`
npm install @onlineapps/mq-client-core
`javascript
const BaseClient = require('@onlineapps/mq-client-core');
const mqClient = new BaseClient({
type: 'rabbitmq',
host: 'amqp://localhost:5672',
queue: 'workflow.init' // Optional default queue
});
await mqClient.connect();
await mqClient.publish('workflow.init', { workflowId: '123', data: '...' });
await mqClient.publish('workflow.control', { workflowId: '123', data: '...' });
`
Flexible Schema - Only type and host are required:
`javascript`
{
type: 'rabbitmq', // Required
host: 'amqp://...', // Required
queue: 'optional', // Optional default queue
exchange: '', // Optional exchange
durable: true, // Optional (default: true)
prefetch: 1, // Optional (default: 1)
noAck: false, // Optional (default: false)
logger: null // Optional custom logger
}
- connect(options?) - Connect to RabbitMQdisconnect()
- - Disconnect from RabbitMQpublish(queue, message, options?)
- - Publish message to queueconsume(queue, handler, options?)
- - Consume messages from queueack(msg)
- - Acknowledge messagenack(msg, options?)
- - Negative acknowledge messageisConnected()
- - Check connection statusonError(callback)
- - Register error handler
`
mq-client-core (this library)
├── BaseClient - Core AMQP operations
├── RabbitMQClient - Transport implementation
└── Basic publish/consume functionality
conn-infra-mq (connector for business services)
├── Uses mq-client-core internally
├── ConnectorMQClient - Orchestrator with layers
├── WorkflowRouter - Business workflow routing
└── Additional business-specific features
Infrastructure services (gateway, registry, validator)
└── Use mq-client-core directly (not the connector)
`
- @onlineapps/conn-infra-mq` - Full connector with business-specific features (uses this library internally)
MIT