Interface KafkaRequestReply<Req,Rep>

Type Parameters:
Req - the type of the request value
Rep - the type of the response value
All Superinterfaces:
io.smallrye.reactive.messaging.EmitterType
All Known Implementing Classes:
KafkaRequestReplyImpl

@Experimental("Experimental API") public interface KafkaRequestReply<Req,Rep> extends io.smallrye.reactive.messaging.EmitterType
KafkaRequestReply is an experimental API that provides functionality for sending requests and receiving responses over Kafka.
  • Field Details

    • DEFAULT_REPLY_CORRELATION_ID_HEADER

      static final String DEFAULT_REPLY_CORRELATION_ID_HEADER
      The default header key used for correlating replies to requests.
      See Also:
    • REPLY_CORRELATION_ID_HEADER_KEY

      static final String REPLY_CORRELATION_ID_HEADER_KEY
      The config key for specifying the header key used to store the correlation ID in the reply record header.
      See Also:
    • DEFAULT_REPLY_TOPIC_HEADER

      static final String DEFAULT_REPLY_TOPIC_HEADER
      The default header key used for indicating the topic of the reply record.
      See Also:
    • REPLY_TOPIC_HEADER_KEY

      static final String REPLY_TOPIC_HEADER_KEY
      The config key for specifying the header key used to store the reply topic in the reply record header.
      See Also:
    • DEFAULT_REPLY_PARTITION_HEADER

      static final String DEFAULT_REPLY_PARTITION_HEADER
      The default header key used for indicating the partition of the reply record.
      See Also:
    • REPLY_PARTITION_HEADER_KEY

      static final String REPLY_PARTITION_HEADER_KEY
      The config key for specifying the header key used to store the reply partition in the reply record header.
      See Also:
    • DEFAULT_REPLIES_TOPIC_SUFFIX

      static final String DEFAULT_REPLIES_TOPIC_SUFFIX
      The default suffix used to create a separate topic for sending reply messages.
      See Also:
    • REPLY_TOPIC_KEY

      static final String REPLY_TOPIC_KEY
      The config key for the reply topic.
      See Also:
    • REPLY_PARTITION_KEY

      static final String REPLY_PARTITION_KEY
      The config key for the reply partition.
      See Also:
    • REPLY_TIMEOUT_KEY

      static final String REPLY_TIMEOUT_KEY
      The config key for the reply timeout.
      See Also:
    • REPLY_INITIAL_ASSIGNMENT_TIMEOUT_KEY

      static final String REPLY_INITIAL_ASSIGNMENT_TIMEOUT_KEY
      The config key for the initial assignment timeout. This timeout is used at start when the auto.offset.reset is set to latest. The value -1 disables waiting for initial assignment.
      See Also:
    • REPLY_CORRELATION_ID_HANDLER_KEY

      static final String REPLY_CORRELATION_ID_HANDLER_KEY
      The config key for the correlation ID handler identifier.

      This config is used to select a CDI-managed implementation of CorrelationIdHandler identified with this config.

      The correlation ID handler is responsible for generating and handling the correlation ID when replying to a request.

      See Also:
    • DEFAULT_CORRELATION_ID_HANDLER

      static final String DEFAULT_CORRELATION_ID_HANDLER
      The default correlation ID handler identifier.

      The "uuid" correlation ID handler generates unique correlation IDs using universally unique identifiers (UUIDs).

      See Also:
    • REPLY_FAILURE_HANDLER_KEY

      static final String REPLY_FAILURE_HANDLER_KEY
      The config key for the reply failure handler identifier.

      This config is used to select a CDI-managed implementation of ReplyFailureHandler

      The Reply Failure Handler is responsible for extracting failure from the reply record.

      See Also:
  • Method Details

    • request

      io.smallrye.mutiny.Uni<Rep> request(Req request)
      Sends a request and receives a response.
      Parameters:
      request - the request object to be sent
      Returns:
      a Uni object representing the result of the send and receive operation
    • request

      io.smallrye.mutiny.Uni<org.eclipse.microprofile.reactive.messaging.Message<Rep>> request(org.eclipse.microprofile.reactive.messaging.Message<Req> request)
      Sends a request and receives a response.
      Parameters:
      request - the request object to be sent
      Returns:
      a Uni object representing the result of the send and receive operation
    • waitForAssignments

      io.smallrye.mutiny.Uni<Set<org.apache.kafka.common.TopicPartition>> waitForAssignments()
      Blocks until the consumer has been assigned all partitions for consumption. If a reply.partition is provided, waits only for the assignment of that particular partition. Otherwise, does a lookup for topic partitions and waits for the assignment of all partitions.
      Returns:
      a Uni object that resolves to a Set of TopicPartition once the assignments have been made.
    • waitForAssignments

      io.smallrye.mutiny.Uni<Set<org.apache.kafka.common.TopicPartition>> waitForAssignments(Collection<org.apache.kafka.common.TopicPartition> topicPartitions)
      Blocks until the consumer has been assigned given partitions for consumption.
      Parameters:
      topicPartitions - the number of partitions to wait for assignments
      Returns:
      a Uni object that resolves to a Set of TopicPartition once the assignments have been made.
    • getPendingReplies

      Map<CorrelationId,PendingReply> getPendingReplies()
      Retrieves the pending replies for each topic.
      Returns:
      a map containing the pending replies for each topic. The map's keys are the topic names and the values are instances of PendingReply.
    • getConsumer

      KafkaConsumer<?,Rep> getConsumer()
      Retrieves the Kafka Consumer used for consuming messages.
      Returns:
      the Kafka Consumer used for consuming messages.
    • complete

      void complete()
      Sends the completion event to the channel indicating that no other events will be sent afterward.
    • replyPartitionFromBytes

      static int replyPartitionFromBytes(byte[] bytes)
      Calculates the partition header from the given byte array.
      Parameters:
      bytes - the byte array from which the partition header is calculated
      Returns:
      the calculated partition header as an integer
    • replyPartitionToBytes

      static byte[] replyPartitionToBytes(int partition)
      Converts the given partition header integer into a byte array.
      Parameters:
      partition - the partition header integer to be converted
      Returns:
      the byte array representation of the partition header