public 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.
onUpdate(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.
onUpdate(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.
Modifier and Type | Method and Description |
---|---|
void |
onUpdate(ClusterResource clusterResource)
A callback method that a user can implement to get updates for
ClusterResource . |
void onUpdate(ClusterResource clusterResource)
ClusterResource
.clusterResource
- cluster metadata