Skip to content

Commit 12eec1f

Browse files
Update content/microservices/kafka.md
1 parent 567f257 commit 12eec1f

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

content/microservices/kafka.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -406,14 +406,14 @@ async handleUserCreated(@Payload() data: IncomingMessage) {
406406
await this.client.commitOffsets([ { topic: data.topic, partition: data.partition, offset: data.offset } ])
407407
}
408408
@@switch
409-
410-
constructor(@Inject(KAFKA) client: ClientKafka) {}
411-
412-
@EventPattern('user_created')
413-
async handleUserCreated(data) {
409+
@Bind(Payload(), Ctx())
410+
@EventPattern('user.created')
411+
async handleUserCreated(data, context) {
414412
// business logic
415413

416-
await this.client.commitOffsets([ { topic: data.topic, partition: data.partition, offset: data.offset } ])
414+
const originalMessage = context.getMessage();
415+
const { topic, partition, offset } = originalMessage;
416+
await this.client.commitOffsets([{ topic, partition, offset }])
417417
}
418418
```
419419

0 commit comments

Comments
 (0)