Class AbstractKafkaResumeStrategy<K,​V>

  • All Implemented Interfaces:
    AutoCloseable, org.apache.camel.Service, org.apache.camel.UpdatableConsumerResumeStrategy<K,​V,​org.apache.camel.Resumable<K,​V>>

    public abstract class AbstractKafkaResumeStrategy<K,​V>
    extends Object
    implements org.apache.camel.UpdatableConsumerResumeStrategy<K,​V,​org.apache.camel.Resumable<K,​V>>, org.apache.camel.Service
    • Constructor Detail

      • AbstractKafkaResumeStrategy

        public AbstractKafkaResumeStrategy​(String bootstrapServers,
                                           String topic,
                                           org.apache.camel.ResumeCache<K,​V> resumeCache)
      • AbstractKafkaResumeStrategy

        public AbstractKafkaResumeStrategy​(String topic,
                                           org.apache.camel.ResumeCache<K,​V> resumeCache,
                                           Properties producerConfig,
                                           Properties consumerConfig)
    • Method Detail

      • createProducer

        public static Properties createProducer​(String bootstrapServers)
        Creates a basic string-based producer
        Parameters:
        bootstrapServers - the Kafka host
        Returns:
        A set of default properties for producing string-based key/pair records from Kafka
      • createConsumer

        public static Properties createConsumer​(String bootstrapServers)
        Creates a basic string-based consumer
        Parameters:
        bootstrapServers - the Kafka host
        Returns:
        A set of default properties for consuming string-based key/pair records from Kafka
      • updateLastOffset

        public void updateLastOffset​(org.apache.camel.Resumable<K,​V> offset)
                              throws Exception
        Specified by:
        updateLastOffset in interface org.apache.camel.UpdatableConsumerResumeStrategy<K,​V,​org.apache.camel.Resumable<K,​V>>
        Throws:
        Exception
      • checkAndSubscribe

        public void checkAndSubscribe​(String topic)
        Parameters:
        topic - the topic to consume the messages from
      • checkAndSubscribe

        public void checkAndSubscribe​(String topic,
                                      long remaining)
        Parameters:
        topic - the topic to consume the messages from
      • unsubscribe

        public void unsubscribe()
      • consume

        public org.apache.kafka.clients.consumer.ConsumerRecords<K,​V> consume()
        Consumes message from the given topic until the predicate returns false
        Returns:
      • consume

        public org.apache.kafka.clients.consumer.ConsumerRecords<K,​V> consume​(int retries)
      • getErrorCount

        public long getErrorCount()
      • getSentItems

        public List<Future<org.apache.kafka.clients.producer.RecordMetadata>> getSentItems()
      • build

        public void build()
        Specified by:
        build in interface org.apache.camel.Service
      • init

        public void init()
        Specified by:
        init in interface org.apache.camel.Service
      • stop

        public void stop()
        Specified by:
        stop in interface org.apache.camel.Service
      • start

        public void start()
        Specified by:
        start in interface org.apache.camel.Service
      • getPollDuration

        public Duration getPollDuration()
      • setPollDuration

        public void setPollDuration​(Duration pollDuration)
      • getConsumer

        protected org.apache.kafka.clients.consumer.Consumer<K,​V> getConsumer()
      • getProducer

        protected org.apache.kafka.clients.producer.Producer<K,​V> getProducer()