Class KafkaAvroMessageSubscriber

java.lang.Object
org.mockserver.async.subscribe.KafkaAvroMessageSubscriber
All Implemented Interfaces:
MessageSubscriber

public class KafkaAvroMessageSubscriber extends Object implements MessageSubscriber
A MessageSubscriber that consumes Confluent wire-format Avro messages from Kafka and records them as JSON — the consume/verify counterpart of KafkaAvroMessagePublisher.

For each consumed record the wire-format header (ConfluentWireFormat) is stripped to recover the schema id and Avro binary, the schema is resolved (from the SchemaRegistryClient by id, or the configured inline schema in registry-less mode), and the Avro binary is decoded back to JSON (AvroPayloadCodec). The recorded payload is therefore JSON, so the existing substring / JSON-path verification works unchanged.

Mirrors KafkaMessageSubscriber's poll-thread confinement: all KafkaConsumer access happens on the single background poll thread.

  • Constructor Details

    • KafkaAvroMessageSubscriber

      public KafkaAvroMessageSubscriber(String bootstrapServers, String groupId, int maxRecordedMessages, KafkaSecurity security, SchemaRegistryClient registryClient, String inlineSchemaJson)
      Parameters:
      bootstrapServers - comma-separated host:port pairs
      groupId - the consumer group id
      maxRecordedMessages - max recorded messages per channel
      security - Kafka security (may be null)
      registryClient - Schema Registry client, or null for registry-less mode
      inlineSchemaJson - inline Avro schema for registry-less decoding (may be null when a registry is used)
  • Method Details