Message Queue
Message Queue protocol schemas
Message queue protocol for async communication
Supports Kafka, RabbitMQ, AWS SQS, Redis Pub/Sub
Source: packages/spec/src/system/message-queue.zod.ts
TypeScript Usage
import { ConsumerConfig, DeadLetterQueue, MessageQueueConfig, MessageQueueProvider, TopicConfig } from '@objectstack/spec/system';
import type { ConsumerConfig, DeadLetterQueue, MessageQueueConfig, MessageQueueProvider, TopicConfig } from '@objectstack/spec/system';
// Validate data
const result = ConsumerConfig.parse(data);ConsumerConfig
Consumer group configuration for topic consumption
Properties
| Property | Type | Required | Description |
|---|---|---|---|
| groupId | string | ✅ | Consumer group identifier |
| autoOffsetReset | Enum<'earliest' | 'latest'> | ✅ | Where to start reading when no offset exists |
| enableAutoCommit | boolean | ✅ | Automatically commit consumed offsets |
| maxPollRecords | number | ✅ | Maximum records returned per poll |
DeadLetterQueue
Dead letter queue configuration for unprocessable messages
Properties
| Property | Type | Required | Description |
|---|---|---|---|
| enabled | boolean | ✅ | Enable dead letter queue for failed messages |
| maxRetries | number | ✅ | Maximum delivery attempts before sending to DLQ |
| queueName | string | ✅ | Name of the dead letter queue |
MessageQueueConfig
Top-level message queue configuration
Properties
| Property | Type | Required | Description |
|---|---|---|---|
| provider | Enum<'kafka' | 'rabbitmq' | 'aws-sqs' | 'redis-pubsub' | 'google-pubsub' | 'azure-service-bus'> | ✅ | Message queue backend provider |
| topics | Object[] | ✅ | List of topic configurations |
| consumers | Object[] | optional | Consumer group configurations |
| deadLetterQueue | Object | optional | Dead letter queue for failed messages |
| ssl | boolean | ✅ | Enable SSL/TLS for broker connections |
| sasl | Object | optional | SASL authentication configuration |
MessageQueueProvider
Supported message queue backend provider
Allowed Values
kafkarabbitmqaws-sqsredis-pubsubgoogle-pubsubazure-service-bus
TopicConfig
Configuration for a message queue topic
Properties
| Property | Type | Required | Description |
|---|---|---|---|
| name | string | ✅ | Topic name identifier |
| partitions | number | ✅ | Number of partitions for parallel consumption |
| replicationFactor | number | ✅ | Number of replicas for fault tolerance |
| retentionMs | number | optional | Message retention period in milliseconds |
| compressionType | Enum<'none' | 'gzip' | 'snappy' | 'lz4'> | ✅ | Message compression algorithm |