Choose an Event Adapter
Every Connectum EventBus uses the same EventAdapter contract. Choose a broker from workload and operational requirements, then keep broker-specific tuning in that adapter's generated API reference.
Broker Selection Matrix
| Adapter | Persistence | Consumer coordination | Ordering scope | Best starting fit |
|---|---|---|---|---|
| Memory | No | None | Publish call | Unit tests and local prototypes |
| NATS JetStream | Yes | Durable consumers | Subject | Lightweight, low-latency service events |
| Kafka / Redpanda | Yes | Native consumer groups | Partition | High-throughput streams and retained logs |
| Redis Streams / Valkey | Configurable by Redis | Consumer groups | Stream | Teams already operating Redis-compatible infrastructure |
| AMQP / RabbitMQ / LavinMQ | Durable queues/exchanges when configured | Competing consumers | Queue | Routing topologies and external AMQP contracts |
All production adapters implement at-least-once delivery semantics. Handlers must be idempotent and acknowledge only after their side effects are complete. Broker configuration determines actual durability and retention.
Memory
MemoryAdapter() ships with @connectum/events. It has no external dependency, persistence, or consumer groups and is intended for tests and local development.
import { MemoryAdapter } from '@connectum/events';
const adapter = MemoryAdapter();NATS JetStream
Choose NATS for durable subjects, wildcard routing, and a compact operational footprint.
import { NatsAdapter } from '@connectum/events-nats';
const adapter = NatsAdapter({ servers: 'nats://localhost:4222' });Kafka or Redpanda
Choose Kafka-compatible infrastructure for partitioned ordering, retained logs, and high-throughput stream processing.
import { KafkaAdapter } from '@connectum/events-kafka';
const adapter = KafkaAdapter({
brokers: ['localhost:9092'],
clientId: 'orders-service',
});Redis Streams or Valkey
Choose Redis Streams when the team already operates Redis-compatible infrastructure and needs stream consumer groups without a separate broker stack.
import { RedisAdapter } from '@connectum/events-redis';
const adapter = RedisAdapter({ url: 'redis://localhost:6379' });AMQP or RabbitMQ
Choose AMQP for exchange/queue topology, competing consumers, or integration with an externally governed AMQP contract.
import { AmqpAdapter } from '@connectum/events-amqp';
const adapter = AmqpAdapter({
url: 'amqp://localhost:5672',
exchange: 'events',
exchangeType: 'topic',
});Automatic Client Identification
When an adapter-specific client or connection name is not supplied, the EventBus derives a service identifier from registered proto service names and the host. An explicit adapter option always wins. Use explicit names when broker ACLs, dashboards, or support procedures depend on stable identifiers.
Custom Adapters
Implement the generated EventAdapter contract when a broker is not covered. Keep serialization, connection lifecycle, subscription cancellation, acknowledgement behavior, and error semantics explicit.