Kafka Protocol Guide
Best practices for produce/consume correlation at scale.
Throughput and Lag
Tune poll intervals, batch sizes, and timeout windows for stable correlation.
Feature Usage Samples
How to use snippets for Kafka Protocol Guide.
Switch between C#, Java, Python, TypeScript, and JavaScript to see the native SDK shape for this sample.
Licensing note: every runnable sample requires a valid runner key via WithRunnerKey("...") or config key LoadStrike:RunnerKey.
Kafka Protocol Setup
var source = new KafkaEndpointDefinition { Name = "in", Mode = TrafficEndpointMode.Produce, TrackingField = TrackingFieldSelector.Parse("json:$.trackingId"), BootstrapServers = "localhost:9092", Topic = "orders.in" };
var destination = new KafkaEndpointDefinition { Name = "out", Mode = TrafficEndpointMode.Consume, TrackingField = TrackingFieldSelector.Parse("json:$.trackingId"), BootstrapServers = "localhost:9092", Topic = "orders.out", ConsumerGroupId = "orders-tests" };
var source = new KafkaEndpointDefinition();
source.name = "orders-in";
source.mode = LoadStrikeTransports.TrafficEndpointMode.Produce;
source.trackingField = TrackingFieldSelector.parse("json:$.trackingId");
source.bootstrapServers = "localhost:9092";
source.topic = "orders.in";
var destination = new KafkaEndpointDefinition();
destination.name = "orders-out";
destination.mode = LoadStrikeTransports.TrafficEndpointMode.Consume;
destination.trackingField = TrackingFieldSelector.parse("json:$.trackingId");
destination.bootstrapServers = "localhost:9092";
destination.topic = "orders.out";
destination.consumerGroupId = "orders-tests";
tracking = {
"Source": {
"Kind": "Kafka",
"Name": "orders-in",
"Mode": "Produce",
"TrackingField": "json:$.trackingId",
"BootstrapServers": "localhost:9092",
"Topic": "orders.in",
},
"Destination": {
"Kind": "Kafka",
"Name": "orders-out",
"Mode": "Consume",
"TrackingField": "json:$.trackingId",
"BootstrapServers": "localhost:9092",
"Topic": "orders.out",
"ConsumerGroupId": "orders-tests",
},
}
const tracking = {
Source: {
Kind: "Kafka",
Name: "orders-in",
Mode: "Produce",
TrackingField: "json:$.trackingId",
BootstrapServers: "localhost:9092",
Topic: "orders.in"
},
Destination: {
Kind: "Kafka",
Name: "orders-out",
Mode: "Consume",
TrackingField: "json:$.trackingId",
BootstrapServers: "localhost:9092",
Topic: "orders.out",
ConsumerGroupId: "orders-tests"
}
};
const tracking = {
Source: {
Kind: "Kafka",
Name: "orders-in",
Mode: "Produce",
TrackingField: "json:$.trackingId",
BootstrapServers: "localhost:9092",
Topic: "orders.in"
},
Destination: {
Kind: "Kafka",
Name: "orders-out",
Mode: "Consume",
TrackingField: "json:$.trackingId",
BootstrapServers: "localhost:9092",
Topic: "orders.out",
ConsumerGroupId: "orders-tests"
}
};
Goal
Same tracking selector
Use the same tracking field on the producer and consumer sides so the two messages can be matched correctly.
Stable message shape
Keep the tracked field in a stable header or JSON location so the selector resolves consistently.