Sample Catalog
A feature-by-feature index of the samples. Browse the source under
sample/ in the
repository.
00-showcase
The full integration baseline. Producer and consumers wired together across
feature modules, the full enhancer pipeline, request-scoped DI, parameter
decorators, a chained consumer, a transactional producer, a batch consumer
with per-topic concurrency, an activity consumer subscribed by topic
pattern, and a health check through KafkaHealthIndicator. Never simplified for brevity — richness proves the
integration depth.
Related docs: Consumers, Producer, Transactions.
01-producer-basics
The smallest runnable app: KafkaModule.forRoot, the KafkaProducerService, and
a single handler that logs every message it receives.
Related docs: Quick Start, Producer.
02-consumer-enhancers
@KafkaConsumer / @KafkaHandler running through guards, interceptors, pipes, and
filters — a focused walkthrough of the enhancer pipeline on the Kafka transport.
Related docs: Consumers.
03-headers-context-errors
The @KafkaMessage / @KafkaHeaders / @KafkaCtx parameter decorators, error
mapping, dead letters written by an exception filter with toDeadLetterMessage
and read back with readDeadLetterHeaders, and graceful shutdown.
Related docs: Parameter Decorators, Error Mapping, Graceful Shutdown.
04-batch-concurrency
Batch consumption (@KafkaHandler({batch: true}), @KafkaBatch()), per-topic
concurrency (nestjs/nest#12703),
and batch offsets that are resolved only once the batch is handled.
Related docs: Batch & Concurrency.
05-transactions
The transactional producer helper (KafkaProducerService.transactional): atomic
multi-topic writes, abort on throw, and the consume-process-produce sendOffsets
pattern.
Related docs: Transactions.
06-microservice-migration
Porting a @nestjs/microservices Kafka handler to @nest-native/kafka and
testing it with KafkaTestModule and its in-memory broker.
Related docs: Migration Guide, Testing.
07-request-reply
The opt-in request-reply bridge: @KafkaHandler(topic, { reply: true })
answering KafkaRequestReplyService.request(), the error reply a 'commit'
mapping produces, what a timeout means, and fire-and-forget handlers left
untouched on the same consumer class.
Related docs: Request-Reply, Migration Guide.