createBus
Overview
Section titled “Overview”createBus is the single entry point for building a Bus. You pass it a BusOptions describing the transport, the queue name, and any optional collaborators (serializer, registry, logger, polling intervals, consume wrapper). It returns a fully wired Bus ready for registerMessage / handle calls and a final await bus.start().
Import
Section titled “Import”import { createBus } from '@serviceconnect/core';Signature
Section titled “Signature”export function createBus(options: BusOptions): Bus;Example
Section titled “Example”import { createBus } from '@serviceconnect/core';import { createRabbitMQTransport } from '@serviceconnect/rabbitmq';
const bus = createBus({ queue: { name: 'orders' }, transport: createRabbitMQTransport({ url: 'amqp://localhost' }),}) .registerMessage<OrderPlaced>('OrderPlaced') .handle<OrderPlaced>('OrderPlaced', async (msg) => { console.log('received', msg.orderId); });
await bus.start();