Interface Transformation<R extends ConnectRecord<R>>

Type Parameters:
R - The type of record (must be an implementation of ConnectRecord)
All Superinterfaces:
AutoCloseable, Closeable, Configurable, ConnectPlugin, Versioned

public interface Transformation<R extends ConnectRecord<R>> extends Configurable, Closeable, ConnectPlugin
Single message transformation for Kafka Connect record types.

Connectors can be configured with transformations to make lightweight message-at-a-time modifications.

Kafka Connect may discover implementations of this interface using the Java ServiceLoader mechanism. To support this, implementations of this interface should also contain a service provider configuration file in META-INF/services/org.apache.kafka.connect.transforms.Transformation.

Implement Monitorable to enable the transformation to register metrics. The following tags are automatically added to all metrics registered: connector set to connector name, task set to the task id and transformation set to the transformation alias.

  • Method Summary

    Modifier and Type
    Method
    Description
    apply(R record)
    Apply transformation to the record and return another record object (which may be record itself) or null, corresponding to a map or filter operation respectively.
    void
    Signal that this transformation instance will no longer will be used.
    default String
    Get the version of this component.

    Methods inherited from interface org.apache.kafka.common.Configurable

    configure

    Methods inherited from interface org.apache.kafka.connect.components.ConnectPlugin

    config
  • Method Details

    • apply

      R apply(R record)
      Apply transformation to the record and return another record object (which may be record itself) or null, corresponding to a map or filter operation respectively.

      A transformation must not mutate objects reachable from the given record (including, but not limited to, Headers, Structs, Lists, and Maps). If such objects need to be changed, a new ConnectRecord should be created and returned.

      The implementation must be thread-safe.

      Parameters:
      record - the record to be transformed; may not be null
      Returns:
      the transformed record; may be null to indicate that the record should be dropped
    • version

      default String version()
      Get the version of this component.
      Specified by:
      version in interface Versioned
      Returns:
      the version, formatted as a String. The version may not be null or empty.
    • close

      void close()
      Signal that this transformation instance will no longer will be used.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable