Description
Expected Behavior
Response messages in addition to the kafka_correlationId
Header should have the same keys as their corresponding request messages when constructing the Request-Reply semantics on top of ReplyingKafkaTemplate
and SendTo
.
Current Behavior
The response messages have no keys (null
)
Context
When one sends a message/request it's only natural to expect that the response message have same key as the original message (request). Such an explicit formalization can allow engineers to reason about the workload. Also it might come in handy when there are different consumers listening the reply topic.
Here is a brief example of what this issue is about
Sender:
void sender(ReplyingKafkaTemplate<String, String, String> template) {
final ProducerRecord<String, String> record = new ProducerRecord<>(
"mytopic",
"key",
"value"
);
var replay = template.sendAndReceive(record, responseTimeout);
// THIS ASSERTION FAILS
assert "key".equals(replay.get().key()) : "The response should have the same key";
}
Listener:
@SendTo
@Listener(topics="mytopic")
String listen(String value) {
return "Hello, " + value;
}
If you run this snippet, you will get the assertion error, because the key of the replying message is null.