MigratoryDataKafkaUtils

This utility class is designed to handle the encoding and decoding of Kafka records that are associated with MigratoryData messages.

Public Functions

Name
ProducerRecord<String, byte[]> createRecord(String topic, String key, byte[] value, boolean compression, MigratoryDataMessage.QoS qos, boolean retained)

Creates a Kafka record to be sent to a specified topic, with customizable quality of service, compression, and retention options for MigratoryData.
ProducerRecord<String, byte[]> createRecord(String topic, int partition, String key, byte[] value, boolean compression, MigratoryDataMessage.QoS qos, boolean retained)

Creates a Kafka record to be sent to a specified topic and partition, with customizable quality of service, compression, and retention options for MigratoryData.
ProducerRecord<String, byte[]> createRecord(String topic, int partition, long timestamp, String key, byte[] value, boolean compression, MigratoryDataMessage.QoS qos, boolean retained)

Creates a Kafka record with a specified timestamp to be sent to a specified topic and partition, with customizable quality of service, compression, and retention options for MigratoryData.
byte[] getRecordValue(ConsumerRecord<String, byte[]> record)

Get the content of a Kafka record corresponding to a MigratoryData message.

Public Functions Documentation

function createRecord

public static ProducerRecord<String, byte[]> createRecord(
    String topic, 
    String key, 
    byte[] value, 
    boolean compression, 
    MigratoryDataMessage.QoS qos, 
    boolean retained
)

Creates a Kafka record to be sent to a specified topic, with customizable quality of service, compression, and retention options for MigratoryData

Parameters:

  • topic The topic the record will be appended to
  • key The key that will be included in the record
  • value The record content
  • compression Specify whether to compress the record content
  • qos Define the quality of service (QoS) for delivery by MigratoryData; either QoS.STANDARD or QoS.GUARANTEED
  • retained Specify if this record should be retained by MigratoryData as a snapshot message

Return:

The Kafka record being created by this method

function createRecord

public static ProducerRecord<String, byte[]> createRecord(
    String topic, 
    int partition,
    String key, 
    byte[] value, 
    boolean compression, 
    MigratoryDataMessage.QoS qos, 
    boolean retained
)

Creates a Kafka record to be sent to a specified topic and partition, with customizable quality of service, compression, and retention options for MigratoryData

Parameters:

  • topic The topic the record will be appended to
  • partition The partition to which the record should be sent
  • key The key that will be included in the record
  • value The record content
  • compression Specify whether to compress the record content
  • qos Define the quality of service (QoS) for delivery by MigratoryData; either QoS.STANDARD or QoS.GUARANTEED
  • retained Specify if this record should be retained by MigratoryData as a snapshot message

Return:

The Kafka record being created by this method

function createRecord

public static ProducerRecord<String, byte[]> createRecord(
    String topic,
    int partition,
    long timestamp, 
    String key, 
    byte[] value, 
    boolean compression, 
    MigratoryDataMessage.QoS qos, 
    boolean retained
)

Creates a Kafka record with a specified timestamp to be sent to a specified topic and partition, with customizable quality of service, compression, and retention options for MigratoryData

Parameters:

  • topic The topic the record will be appended to
  • partition The partition to which the record should be sent
  • timestamp The timestamp of the record, in milliseconds since epoch. If null, the producer will assign the timestamp using System.currentTimeMillis().
  • key The key that will be included in the record
  • value The record content
  • compression Specify whether to compress the record content
  • qos Define the quality of service (QoS) for delivery by MigratoryData; either QoS.STANDARD or QoS.GUARANTEED
  • retained Specify if this record should be retained by MigratoryData as a snapshot message

Return:

The Kafka record being created by this method

function getRecordValue

public static byte[] getRecordValue(
    ConsumerRecord<String, byte[]> record
)

Get the content of a Kafka record corresponding to a MigratoryData message

Parameters:

  • record A Kafka record

Return:

The content of a Kafka record corresponding to a MigratoryData message