You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In this stage, you'll replace the hard-coded correlation ID with the actual correlation ID from the request.
1
+
In this stage, you'll replace the hardcoded correlation ID with the actual correlation ID from the request.
2
2
3
-
### Request message
3
+
### Kafka Message Structure
4
4
5
-
A request message has three parts:
6
-
1.`message_size`
7
-
2. Header
8
-
3. Body
5
+
As a recap, Kafka request and response messages have the following format:
9
6
10
-
To get the `correlation_id` field, you need to find its offset. You already know that `message_size` is 4 bytes long. And here's what the request header looks like (in this stage, we're using [request header v2](https://kafka.apache.org/protocol.html#protocol_messages)):
In a previous stage, you sent a response with a hardcoded `correlation_id`. Now you'll extract the actual `correlation_id` from the incoming request header and echo it back.
19
12
20
-
To learn more about the different data types, see [Protocol Primitive Types](https://kafka.apache.org/protocol.html#protocol_types).
13
+
### Parsing the Request Header
21
14
22
-
#### Example
15
+
To extract the `correlation_id`, you need to parse the request header. For this stage, you'll work with [request header v2](https://kafka.apache.org/protocol.html#protocol_messages).
16
+
17
+
Here’s what the structure looks like:
18
+
19
+
| Field | Data type | Size (bytes) | Description |
Your broker must send a response with the correct correlation ID:
46
-
```java
47
-
00000000// message_size: 0 (any value works)
58
+
Your broker must extract the correlation ID from the request and echo it back:
59
+
```
60
+
00 00 00 00 // message_size: 0 (any value works for this stage)
48
61
6f 7f c6 61 // correlation_id: 1870644833
49
62
```
50
63
51
64
### Notes
52
65
53
-
- For this stage, you don't need to worry about what the request is asking for. You'll handle that in the next stage.
66
+
- For this stage, you don't need to worry about what the request is asking for. You'll handle that at a later stage.
54
67
- For this stage, the tester will only assert that your `message_size` field is 4 bytes long—it won't check the value. You'll implement correct `message_size` values in a later stage.
55
-
- The request header version and response header version are unrelated to each other and do not have to match.
68
+
- The request header version and response header version are unrelated to each other and do not have to match.
0 commit comments