Correlation Id in Apache kafka

2019-06-07 18:44发布

问题:

Is there anyway to receive messages in kafka based on a correlationID ( similar to the one in JMS Specification ). I want to create a set of consumers listening from the same topic but with different correlation Id's ?

回答1:

correlationId is a per TCP connection artifact that allows the client (producer or consumer) to map a response from the broker to a previous request by the client, it has no meaning outside that specific TCP connection.

CorrelationId - This is a user-supplied integer. It will be passed back in the response by the server, unmodified. It is useful for matching request and response between the client and server.

https://cwiki.apache.org/confluence/display/KAFKA/A+Guide+To+The+Kafka+Protocol#AGuideToTheKafkaProtocol-Requests