Interface ClusterResourceListener
Users who need access to cluster metadata in interceptors, metric reporters, serializers and deserializers can implement this interface. The order of method calls for each of these types is described below.
Clients
There will be one invocation ofonUpdate(ClusterResource)
after each metadata response.
Note that the cluster id may be null when the Kafka broker version is below 0.10.1.0. If you receive a null cluster id, you can expect it to always be null unless you have a cluster with multiple broker versions which can happen if the cluster is being upgraded while the client is running.
ProducerInterceptor
: The onUpdate(ClusterResource)
method will be invoked after ProducerInterceptor.onSend(org.apache.kafka.clients.producer.ProducerRecord)
but before ProducerInterceptor.onAcknowledgement(org.apache.kafka.clients.producer.RecordMetadata, Exception)
.
ConsumerInterceptor
: The onUpdate(ClusterResource)
method will be invoked before ConsumerInterceptor.onConsume(org.apache.kafka.clients.consumer.ConsumerRecords)
Serializer
: The onUpdate(ClusterResource)
method will be invoked before Serializer.serialize(String, Object)
Deserializer
: The onUpdate(ClusterResource)
method will be invoked before Deserializer.deserialize(String, byte[])
MetricsReporter
: The onUpdate(ClusterResource)
method will be invoked after first KafkaProducer.send(org.apache.kafka.clients.producer.ProducerRecord)
invocation for Producer metrics reporter
and after first KafkaConsumer.poll(java.time.Duration)
invocation for Consumer metrics
reporters. The reporter may receive metric events from the network layer before this method is invoked.
Broker
There is a single invocationonUpdate(ClusterResource)
on broker start-up and the cluster metadata will never change.
KafkaMetricsReporter : The onUpdate(ClusterResource)
method will be invoked during the bootup of the Kafka broker. The reporter may receive metric events from the network layer before this method is invoked.
MetricsReporter
: The onUpdate(ClusterResource)
method will be invoked during the bootup of the Kafka broker. The reporter may receive metric events from the network layer before this method is invoked.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
onUpdate
(ClusterResource clusterResource) A callback method that a user can implement to get updates forClusterResource
.
-
Method Details
-
onUpdate
A callback method that a user can implement to get updates forClusterResource
.- Parameters:
clusterResource
- cluster metadata
-