Class AutoCreateTopicsInterceptor

  • All Implemented Interfaces:
    StreamsLifecycleInterceptor

    public class AutoCreateTopicsInterceptor
    extends Object
    implements StreamsLifecycleInterceptor
    This StreamsLifecycleInterceptor create both topics source and sink before starting the streams instance. Optionally, this interceptor can also be used to automatically delete all topics used by the applications when it's closed. This interceptor is state-full and thus a new instance must be created for each topology.
    • Constructor Detail

      • AutoCreateTopicsInterceptor

        public AutoCreateTopicsInterceptor​(org.apache.kafka.clients.admin.AdminClient adminClient)
        Creates a new AutoCreateTopicsInterceptor instance.
        Parameters:
        adminClient - the AdminClient to be used.
    • Method Detail

      • setReplicationFactor

        public void setReplicationFactor​(short replicationFactor)
        Sets the default replication factor uses for creating topics.
        Parameters:
        replicationFactor - the replication factor.
      • setNumPartitions

        public void setNumPartitions​(int numPartitions)
        Sets the default number of partitions uses for creating topics.
        Parameters:
        numPartitions - the number of partitions.
      • setTopics

        public void setTopics​(Collection<org.apache.kafka.clients.admin.NewTopic> topics)
        Sets the list of new topics to create.
        Parameters:
        topics - the list of NewTopic instances.
      • setDeleteTopicsOnStreamsClosed

        public void setDeleteTopicsOnStreamsClosed​(boolean delete)
        Sets if topics should be automatically deleted once the streams is closed.
        Parameters:
        delete - true to enable, otherwise false.