Interface KafkaOperations2<K,V>

Type Parameters:
K - the key type.
V - the value type.

@Deprecated(since="3.0", forRemoval=true) public interface KafkaOperations2<K,V>
Deprecated, for removal: This API element is subject to removal in a future version.
no longer needed; use KafkaOperations.
The basic Kafka operations contract returning CompletableFutures.
Since:
2.9
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final Duration
    Deprecated, for removal: This API element is subject to removal in a future version.
    Default timeout for receive(String, int, long).
  • Method Summary

    Modifier and Type
    Method
    Description
    <T> T
    Deprecated, for removal: This API element is subject to removal in a future version.
    Execute some arbitrary operation(s) on the producer and return the result.
    <T> T
    Deprecated, for removal: This API element is subject to removal in a future version.
    Execute some arbitrary operation(s) on the operations and return the result.
    void
    Deprecated, for removal: This API element is subject to removal in a future version.
    Flush the producer.
    Deprecated, for removal: This API element is subject to removal in a future version.
    Return the producer factory used by this template.
    default boolean
    Deprecated, for removal: This API element is subject to removal in a future version.
    Return true if the template is currently running in a transaction on the calling thread.
    default boolean
    Deprecated, for removal: This API element is subject to removal in a future version.
    Return true if this template, when transactional, allows non-transactional operations.
    boolean
    Deprecated, for removal: This API element is subject to removal in a future version.
    Return true if the implementation supports transactions (has a transaction-capable producer factory).
    Map<org.apache.kafka.common.MetricName,? extends org.apache.kafka.common.Metric>
    Deprecated, for removal: This API element is subject to removal in a future version.
    See Producer.metrics().
    List<org.apache.kafka.common.PartitionInfo>
    Deprecated, for removal: This API element is subject to removal in a future version.
    See Producer.partitionsFor(String).
    default org.apache.kafka.clients.consumer.ConsumerRecord<K,V>
    receive(String topic, int partition, long offset)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Receive a single record with the default poll timeout (5 seconds).
    org.apache.kafka.clients.consumer.ConsumerRecord<K,V>
    receive(String topic, int partition, long offset, Duration pollTimeout)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Receive a single record.
    default org.apache.kafka.clients.consumer.ConsumerRecords<K,V>
    Deprecated, for removal: This API element is subject to removal in a future version.
    Receive a multiple records with the default poll timeout (5 seconds).
    org.apache.kafka.clients.consumer.ConsumerRecords<K,V>
    receive(Collection<TopicPartitionOffset> requested, Duration pollTimeout)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Receive multiple records.
    send(String topic, Integer partition, Long timestamp, K key, V data)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Send the data to the provided topic with the provided key and partition.
    send(String topic, Integer partition, K key, V data)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Send the data to the provided topic with the provided key and partition.
    send(String topic, K key, V data)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Send the data to the provided topic with the provided key and no partition.
    send(String topic, V data)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Send the data to the provided topic with no key or partition.
    send(org.apache.kafka.clients.producer.ProducerRecord<K,V> record)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Send the provided ProducerRecord.
    send(org.springframework.messaging.Message<?> message)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Send a message with routing information in message headers.
    sendDefault(Integer partition, Long timestamp, K key, V data)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Send the data to the default topic with the provided key and partition.
    sendDefault(Integer partition, K key, V data)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Send the data to the default topic with the provided key and partition.
    sendDefault(K key, V data)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Send the data to the default topic with the provided key and no partition.
    sendDefault(V data)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Send the data to the default topic with no key or partition.
    default void
    sendOffsetsToTransaction(Map<org.apache.kafka.common.TopicPartition,org.apache.kafka.clients.consumer.OffsetAndMetadata> offsets, org.apache.kafka.clients.consumer.ConsumerGroupMetadata groupMetadata)
    Deprecated, for removal: This API element is subject to removal in a future version.
    When running in a transaction, send the consumer offset(s) to the transaction.
  • Field Details

    • DEFAULT_POLL_TIMEOUT

      static final Duration DEFAULT_POLL_TIMEOUT
      Deprecated, for removal: This API element is subject to removal in a future version.
      Default timeout for receive(String, int, long).
  • Method Details

    • sendDefault

      CompletableFuture<SendResult<K,V>> sendDefault(V data)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Send the data to the default topic with no key or partition.
      Parameters:
      data - The data.
      Returns:
      a Future for the SendResult.
    • sendDefault

      CompletableFuture<SendResult<K,V>> sendDefault(K key, V data)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Send the data to the default topic with the provided key and no partition.
      Parameters:
      key - the key.
      data - The data.
      Returns:
      a Future for the SendResult.
    • sendDefault

      CompletableFuture<SendResult<K,V>> sendDefault(Integer partition, K key, V data)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Send the data to the default topic with the provided key and partition.
      Parameters:
      partition - the partition.
      key - the key.
      data - the data.
      Returns:
      a Future for the SendResult.
    • sendDefault

      CompletableFuture<SendResult<K,V>> sendDefault(Integer partition, Long timestamp, K key, V data)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Send the data to the default topic with the provided key and partition.
      Parameters:
      partition - the partition.
      timestamp - the timestamp of the record.
      key - the key.
      data - the data.
      Returns:
      a Future for the SendResult.
    • send

      CompletableFuture<SendResult<K,V>> send(String topic, V data)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Send the data to the provided topic with no key or partition.
      Parameters:
      topic - the topic.
      data - The data.
      Returns:
      a Future for the SendResult.
    • send

      CompletableFuture<SendResult<K,V>> send(String topic, K key, V data)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Send the data to the provided topic with the provided key and no partition.
      Parameters:
      topic - the topic.
      key - the key.
      data - The data.
      Returns:
      a Future for the SendResult.
    • send

      CompletableFuture<SendResult<K,V>> send(String topic, Integer partition, K key, V data)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Send the data to the provided topic with the provided key and partition.
      Parameters:
      topic - the topic.
      partition - the partition.
      key - the key.
      data - the data.
      Returns:
      a Future for the SendResult.
    • send

      CompletableFuture<SendResult<K,V>> send(String topic, Integer partition, Long timestamp, K key, V data)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Send the data to the provided topic with the provided key and partition.
      Parameters:
      topic - the topic.
      partition - the partition.
      timestamp - the timestamp of the record.
      key - the key.
      data - the data.
      Returns:
      a Future for the SendResult.
    • send

      CompletableFuture<SendResult<K,V>> send(org.apache.kafka.clients.producer.ProducerRecord<K,V> record)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Send the provided ProducerRecord.
      Parameters:
      record - the record.
      Returns:
      a Future for the SendResult.
    • send

      CompletableFuture<SendResult<K,V>> send(org.springframework.messaging.Message<?> message)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Send a message with routing information in message headers. The message payload may be converted before sending.
      Parameters:
      message - the message to send.
      Returns:
      a Future for the SendResult.
      See Also:
    • partitionsFor

      List<org.apache.kafka.common.PartitionInfo> partitionsFor(String topic)
      Deprecated, for removal: This API element is subject to removal in a future version.
      See Producer.partitionsFor(String).
      Parameters:
      topic - the topic.
      Returns:
      the partition info.
    • metrics

      Map<org.apache.kafka.common.MetricName,? extends org.apache.kafka.common.Metric> metrics()
      Deprecated, for removal: This API element is subject to removal in a future version.
      See Producer.metrics().
      Returns:
      the metrics.
    • execute

      @Nullable <T> T execute(KafkaOperations.ProducerCallback<K,V,T> callback)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Execute some arbitrary operation(s) on the producer and return the result.
      Type Parameters:
      T - the result type.
      Parameters:
      callback - the callback.
      Returns:
      the result.
    • executeInTransaction

      @Nullable <T> T executeInTransaction(KafkaOperations.OperationsCallback<K,V,T> callback)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Execute some arbitrary operation(s) on the operations and return the result. The operations are invoked within a local transaction and do not participate in a global transaction (if present).
      Type Parameters:
      T - the result type.
      Parameters:
      callback - the callback.
      Returns:
      the result.
    • flush

      void flush()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Flush the producer.
    • sendOffsetsToTransaction

      default void sendOffsetsToTransaction(Map<org.apache.kafka.common.TopicPartition,org.apache.kafka.clients.consumer.OffsetAndMetadata> offsets, org.apache.kafka.clients.consumer.ConsumerGroupMetadata groupMetadata)
      Deprecated, for removal: This API element is subject to removal in a future version.
      When running in a transaction, send the consumer offset(s) to the transaction. It is not necessary to call this method if the operations are invoked on a listener container thread (and the listener container is configured with a KafkaAwareTransactionManager) since the container will take care of sending the offsets to the transaction. Use with 2.5 brokers or later.
      Parameters:
      offsets - The offsets.
      groupMetadata - the consumer group metadata.
      See Also:
      • Producer.sendOffsetsToTransaction(Map, ConsumerGroupMetadata)
    • isTransactional

      boolean isTransactional()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Return true if the implementation supports transactions (has a transaction-capable producer factory).
      Returns:
      true or false.
    • isAllowNonTransactional

      default boolean isAllowNonTransactional()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Return true if this template, when transactional, allows non-transactional operations.
      Returns:
      true to allow.
    • inTransaction

      default boolean inTransaction()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Return true if the template is currently running in a transaction on the calling thread.
      Returns:
      true if a transaction is running.
    • getProducerFactory

      default ProducerFactory<K,V> getProducerFactory()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Return the producer factory used by this template.
      Returns:
      the factory.
    • receive

      @Nullable default org.apache.kafka.clients.consumer.ConsumerRecord<K,V> receive(String topic, int partition, long offset)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Receive a single record with the default poll timeout (5 seconds).
      Parameters:
      topic - the topic.
      partition - the partition.
      offset - the offset.
      Returns:
      the record or null.
      See Also:
    • receive

      @Nullable org.apache.kafka.clients.consumer.ConsumerRecord<K,V> receive(String topic, int partition, long offset, Duration pollTimeout)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Receive a single record.
      Parameters:
      topic - the topic.
      partition - the partition.
      offset - the offset.
      pollTimeout - the timeout.
      Returns:
      the record or null.
    • receive

      default org.apache.kafka.clients.consumer.ConsumerRecords<K,V> receive(Collection<TopicPartitionOffset> requested)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Receive a multiple records with the default poll timeout (5 seconds). Only absolute, positive offsets are supported.
      Parameters:
      requested - a collection of record requests (topic/partition/offset).
      Returns:
      the records
      See Also:
    • receive

      org.apache.kafka.clients.consumer.ConsumerRecords<K,V> receive(Collection<TopicPartitionOffset> requested, Duration pollTimeout)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Receive multiple records. Only absolute, positive offsets are supported.
      Parameters:
      requested - a collection of record requests (topic/partition/offset).
      pollTimeout - the timeout.
      Returns:
      the record or null.