JSPM

  • Created
  • Published
  • Downloads 254
  • Score
    100M100P100Q118606F
  • License MIT

Core MQ client library for RabbitMQ - shared by infrastructure services and connectors

Package Exports

  • @onlineapps/mq-client-core
  • @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-core

Usage

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 RabbitMQ
  • disconnect() - Disconnect from RabbitMQ
  • publish(queue, message, options?) - Publish message to queue
  • consume(queue, handler, options?) - Consume messages from queue
  • ack(msg) - Acknowledge message
  • nack(msg, options?) - Negative acknowledge message
  • isConnected() - Check connection status
  • onError(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)
  • @onlineapps/conn-infra-mq - Full connector with business-specific features (uses this library internally)

License

MIT