Package Exports
- @onlineapps/mq-client-core
- @onlineapps/mq-client-core/src/config/defaultConfig
- @onlineapps/mq-client-core/src/config/defaultConfig.js
- @onlineapps/mq-client-core/src/config/queueConfig
- @onlineapps/mq-client-core/src/config/queueConfig.js
- @onlineapps/mq-client-core/src/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@onlineapps/mq-client-core) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
@onlineapps/mq-client-core
Core MQ client library for RabbitMQ - shared by infrastructure services and connectors.
Overview
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.
Installation
npm install @onlineapps/mq-client-coreUsage
For Infrastructure Services
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: '...' });Configuration
Flexible Schema - Only type and host are required:
{
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
}API
BaseClient
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
Architecture
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)Related Packages
@onlineapps/conn-infra-mq- Full connector with business-specific features (uses this library internally)
License
MIT