Skip to content

Repository files navigation

ServiceConnect for Node.js

cidocs

Asynchronous messaging for Node.js. ServiceConnect gives you a typed, ergonomic bus on top of RabbitMQ with first-class support for pub/sub, point-to-point, request/reply, scatter-gather, polymorphic dispatch, process managers (sagas), aggregators, routing slips, streaming, and a pluggable pipeline.

It is the Node.js sibling of ServiceConnect for .NET and is wire-compatible with it.

Documentation:https://r-suite.github.io/ServiceConnect-NodeJS/

Why?

Most Node.js AMQP clients give you a connection and a channel. You then write the same plumbing every project: typed handlers, retry queues, error queues, correlation, request/reply, sagas, streaming. ServiceConnect provides all of that out of the box, with a small, composable API and a clean transport abstraction so you can swap the broker (or persistence layer) without touching your handlers.

Install

npm install @serviceconnect/core @serviceconnect/rabbitmq

Optional packages:

npm install @serviceconnect/persistence-memory # in-memory saga / aggregator stores (dev + tests)
npm install @serviceconnect/persistence-mongodb # MongoDB-backed stores (production)
npm install @serviceconnect/telemetry # OpenTelemetry hooks
npm install @serviceconnect/healthchecks # producer / consumer health probes

Quickstart

import{createBus,createMessageTypeRegistry,typeMessage}from'@serviceconnect/core';import{rabbitMQWithRegistry}from'@serviceconnect/rabbitmq';interfaceOrderPlacedextendsMessage{orderId: string;total: number;}constregistry=createMessageTypeRegistry();registry.register<OrderPlaced>('OrderPlaced');constbus=createBus({queue: {name: 'orders'},transport: rabbitMQWithRegistry({url: 'amqp://localhost'},registry,),
registry,});bus.handle<OrderPlaced>('OrderPlaced',async(msg,ctx)=>{console.log('charging',msg.orderId,msg.total);});awaitbus.start();awaitbus.publish<OrderPlaced>('OrderPlaced',{correlationId: 'c-1',orderId: 'o-1',total: 49.99,});

Packages

PackagePurpose
@serviceconnect/coreBus, handlers, pipeline, sagas, aggregators, routing slip, streaming.
@serviceconnect/rabbitmqRabbitMQ transport.
@serviceconnect/persistence-memoryIn-memory saga / aggregator / timeout stores.
@serviceconnect/persistence-mongodbMongoDB-backed stores.
@serviceconnect/telemetryOpenTelemetry producer / consumer wrappers.
@serviceconnect/healthchecksProducer + consumer health checks.

Examples

Runnable end-to-end examples live under examples/. Each example uses the examples/docker-compose.yml to spin up RabbitMQ:

cd examples
docker compose up -d
bash run-all.sh

Migration from v2

The legacy service-connect v2.x package (on the master branch) is preserved unchanged. v3 is a complete redesign with typed handlers, ESM-only, Node 22 LTS, and a pluggable transport.

See the migration guide for a side-by-side mapping of every v2 concept to its v3 replacement.

Engine support

Node 22 LTS or later. ESM only. TypeScript users: NodeNext module resolution.

Contributing

Issues and PRs are welcome. See CONTRIBUTING.md for project layout, build/test instructions, coding conventions, and the release process.

License

MIT — see LICENSE.

About

A simple, easy to use asynchronous messaging framework for Node.JS

Resources

Contributing

Stars

6 stars

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages