Skip to content

Commit 48d8368

Browse files
committed
docs: microservice-kafka
- There is no `partition` and `topic` in `context.getMesaage()`
1 parent d20482d commit 48d8368

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

content/microservices/kafka.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -441,8 +441,9 @@ Committing offsets is essential when working with Kafka. Per default, messages w
441441
async handleUserCreated(@Payload() data: IncomingMessage, @Ctx() context: KafkaContext) {
442442
// business logic
443443

444-
const originalMessage = context.getMessage();
445-
const { topic, partition, offset } = originalMessage;
444+
const { offset } = context.getMessage();
445+
const partition = context.getPartition();
446+
const topic = context.getTopic();
446447
await this.client.commitOffsets([{ topic, partition, offset }])
447448
}
448449
@@switch
@@ -451,8 +452,9 @@ async handleUserCreated(@Payload() data: IncomingMessage, @Ctx() context: KafkaC
451452
async handleUserCreated(data, context) {
452453
// business logic
453454

454-
const originalMessage = context.getMessage();
455-
const { topic, partition, offset } = originalMessage;
455+
const { offset } = context.getMessage();
456+
const partition = context.getPartition();
457+
const topic = context.getTopic();
456458
await this.client.commitOffsets([{ topic, partition, offset }])
457459
}
458460
```

0 commit comments

Comments
 (0)