All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.devonfw.module.kafka.common.messaging.api.client.MessageSender Maven / Gradle / Ivy

There is a newer version: 2023.01.001
Show newest version
package com.devonfw.module.kafka.common.messaging.api.client;

import java.util.concurrent.TimeoutException;

import org.apache.kafka.clients.producer.ProducerRecord;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.kafka.support.SendResult;
import org.springframework.util.concurrent.ListenableFuture;

/**
 * The interface used to send message to kafka broker with the help of multiple methods. For example, the method
 * {@link #sendMessage(ProducerRecord)}} sends the message by interacting with
 * {@link KafkaTemplate#send(org.apache.kafka.clients.producer.ProducerRecord)}}.
 *
 * @param  the key type.
 * @param  the value type.
 * @deprecated The implementation of devon4j-kafka will be abandoned. It is superseeded by Springs Kafka
 *             implementation.
 */
@Deprecated
public interface MessageSender {

  /**
   * Send the provided {@link ProducerRecord}} to kafka.
   *
   * @param producerRecord the {@link ProducerRecord}
   * @return the {@link ListenableFuture}.
   */
  ListenableFuture> sendMessage(ProducerRecord producerRecord);

  /**
   * Send the provided {@link ProducerRecord}} to kafka and waits for the default timeout seconds by default 60.
   *
   * @param producerRecord {@link ProducerRecord}}
   * @throws Exception generic exception. Throws {@link TimeoutException}} when timeout seconds exceeds.
   */
  void sendMessageAndWait(ProducerRecord producerRecord) throws Exception;

  /**
   * Send the provided {@link ProducerRecord}} to kafka and waits for the given timeout seconds.
   *
   * @param producerRecord producerRecord the {@link ProducerRecord}
   * @param timeout the seconds needs to wait for the operation to complete
   * @throws Exception generic exception. Throws {@link TimeoutException}} when timeout seconds exceeds.
   */
  void sendMessageAndWait(ProducerRecord producerRecord, int timeout) throws Exception;

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy