Skip to content

Commit 3c76357

Browse files
committed
Rename docs to Kafka Consumer and add line highlights for code examples.
1 parent fa29f60 commit 3c76357

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

docs/utilities/kafka.md

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: Kafka
2+
title: Kafka Consumer
33
description: Utility
44
status: new
55
---
@@ -132,7 +132,7 @@ The Kafka utility transforms raw Lambda Kafka events into an intuitive format fo
132132

133133
=== "Avro Messages"
134134

135-
```java
135+
```java hl_lines="13 16"
136136
package org.example;
137137

138138
import com.amazonaws.services.lambda.runtime.Context;
@@ -158,7 +158,7 @@ The Kafka utility transforms raw Lambda Kafka events into an intuitive format fo
158158

159159
=== "Protocol Buffers"
160160

161-
```java
161+
```java hl_lines="13 16"
162162
package org.example;
163163

164164
import com.amazonaws.services.lambda.runtime.Context;
@@ -184,7 +184,7 @@ The Kafka utility transforms raw Lambda Kafka events into an intuitive format fo
184184

185185
=== "JSON Messages"
186186

187-
```java
187+
```java hl_lines="13 16"
188188
package org.example;
189189

190190
import com.amazonaws.services.lambda.runtime.Context;
@@ -200,7 +200,7 @@ The Kafka utility transforms raw Lambda Kafka events into an intuitive format fo
200200
@Deserialization(type = DeserializationType.KAFKA_JSON)
201201
public String handleRequest(ConsumerRecords<String, User> records, Context context) {
202202
for (ConsumerRecord<String, User> record : records) {
203-
User user = record.value(); // Deserialized JSON object
203+
User user = record.value(); // Deserialized JSON object into User POJO
204204
System.out.printf("Processing user: %s, age %d%n", user.getName(), user.getAge());
205205
}
206206
return "OK";
@@ -218,7 +218,7 @@ The `@Deserialization` annotation deserializes both keys and values based on you
218218

219219
=== "Key and Value Deserialization"
220220

221-
```java
221+
```java hl_lines="17"
222222
package org.example;
223223

224224
import com.amazonaws.services.lambda.runtime.Context;
@@ -248,7 +248,7 @@ The `@Deserialization` annotation deserializes both keys and values based on you
248248

249249
=== "Value-Only Deserialization"
250250

251-
```java
251+
```java hl_lines="17"
252252
package org.example;
253253

254254
import com.amazonaws.services.lambda.runtime.Context;
@@ -289,7 +289,7 @@ When working with primitive data types (strings, integers, etc.) rather than str
289289

290290
=== "Primitive key"
291291

292-
```java
292+
```java hl_lines="17 19"
293293
package org.example;
294294

295295
import com.amazonaws.services.lambda.runtime.Context;
@@ -322,7 +322,7 @@ When working with primitive data types (strings, integers, etc.) rather than str
322322

323323
=== "Primitive key and value"
324324

325-
```java
325+
```java hl_lines="17 20"
326326
package org.example;
327327

328328
import com.amazonaws.services.lambda.runtime.Context;
@@ -367,7 +367,7 @@ The Kafka utility supports multiple serialization formats to match your existing
367367
| **JSON** | `KAFKA_JSON` | Human-readable text format | Jackson |
368368
| **Avro** | `KAFKA_AVRO` | Compact binary format with schema | Apache Avro |
369369
| **Protocol Buffers** | `KAFKA_PROTOBUF` | Efficient binary format | Protocol Buffers |
370-
| **Lambda Default** | `LAMBDA_DEFAULT` | Uses Lambda's built-in deserialization (equivalent to removing the @Deserialization annotation) | None |
370+
| **Lambda Default** | `LAMBDA_DEFAULT` | Uses Lambda's built-in deserialization (equivalent to removing the `@Deserialization` annotation) | None |
371371

372372
=== "Format Comparison"
373373

@@ -579,7 +579,7 @@ The Idempotency utility automatically stores the result of each successful opera
579579

580580
<!-- prettier-ignore -->
581581
???+ tip "Ensuring exactly-once processing"
582-
The @Idempotent annotation will use the JSON representation of the Payment object to make sure that the same object is only processed exactly once. Even if a batch fails and Lambda retries the messages, each unique payment will be processed exactly once.
582+
The `@Idempotent` annotation will use the JSON representation of the Payment object to make sure that the same object is only processed exactly once. Even if a batch fails and Lambda retries the messages, each unique payment will be processed exactly once.
583583

584584
### Best practices
585585

@@ -625,7 +625,7 @@ When using binary serialization formats across multiple programming languages, e
625625

626626
=== "Using Python naming convention"
627627

628-
```java
628+
```java hl_lines="28 31 34 35 37 38 51"
629629
package org.example;
630630

631631
import com.amazonaws.services.lambda.runtime.Context;
@@ -821,7 +821,9 @@ sequenceDiagram
821821
Lambda->>+KafkaUtility: Pass Kafka event
822822
KafkaUtility->>KafkaUtility: Parse event structure
823823
loop For each record
824+
KafkaUtility->>KafkaUtility: Decode base64 data
824825
KafkaUtility->>KafkaUtility: Record is already deserialized
826+
KafkaUtility->>KafkaUtility: Map to POJO (if specified)
825827
end
826828
KafkaUtility->>+YourCode: Provide ConsumerRecords
827829
YourCode->>YourCode: Process records

0 commit comments

Comments
 (0)