Class KafkaRequestReplyImpl<Req,Rep>

All Implemented Interfaces:
io.smallrye.mutiny.subscription.MultiSubscriber<KafkaRecord<?,Rep>>, io.smallrye.reactive.messaging.EmitterType, KafkaRequestReply<Req,Rep>, io.smallrye.reactive.messaging.MessagePublisherProvider<Req>, io.smallrye.reactive.messaging.MutinyEmitter<Req>, Flow.Subscriber<KafkaRecord<?,Rep>>

@Experimental("Experimental API") public class KafkaRequestReplyImpl<Req,Rep> extends MutinyEmitterImpl<Req> implements KafkaRequestReply<Req,Rep>, io.smallrye.mutiny.subscription.MultiSubscriber<KafkaRecord<?,Rep>>
  • Constructor Details

    • KafkaRequestReplyImpl

      public KafkaRequestReplyImpl(io.smallrye.reactive.messaging.EmitterConfiguration config, long defaultBufferSize, org.eclipse.microprofile.config.Config channelConfiguration, jakarta.enterprise.inject.Instance<Map<String,Object>> configurations, io.vertx.mutiny.core.Vertx vertx, KafkaCDIEvents kafkaCDIEvents, jakarta.enterprise.inject.Instance<io.opentelemetry.api.OpenTelemetry> openTelemetryInstance, jakarta.enterprise.inject.Instance<KafkaCommitHandler.Factory> commitHandlerFactory, jakarta.enterprise.inject.Instance<KafkaFailureHandler.Factory> failureHandlerFactories, jakarta.enterprise.inject.Instance<DeserializationFailureHandler<?>> deserializationFailureHandlers, jakarta.enterprise.inject.Instance<CorrelationIdHandler> correlationIdHandlers, jakarta.enterprise.inject.Instance<ReplyFailureHandler> replyFailureHandlers, jakarta.enterprise.inject.Instance<KafkaConsumerRebalanceListener> rebalanceListeners)
  • Method Details

    • getPublisher

      public Flow.Publisher<org.eclipse.microprofile.reactive.messaging.Message<? extends Req>> getPublisher()
      Specified by:
      getPublisher in interface io.smallrye.reactive.messaging.MessagePublisherProvider<Req>
      Overrides:
      getPublisher in class AbstractEmitter<Req>
    • complete

      public void complete()
      Description copied from interface: KafkaRequestReply
      Sends the completion event to the channel indicating that no other events will be sent afterward.
      Specified by:
      complete in interface KafkaRequestReply<Req,Rep>
      Specified by:
      complete in interface io.smallrye.reactive.messaging.MutinyEmitter<Req>
      Overrides:
      complete in class AbstractEmitter<Req>
    • request

      public io.smallrye.mutiny.Uni<Rep> request(Req request)
      Description copied from interface: KafkaRequestReply
      Sends a request and receives a response.
      Specified by:
      request in interface KafkaRequestReply<Req,Rep>
      Parameters:
      request - the request object to be sent
      Returns:
      a Uni object representing the result of the send and receive operation
    • request

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

      public io.smallrye.mutiny.Uni<Set<org.apache.kafka.common.TopicPartition>> waitForAssignments()
      Description copied from interface: KafkaRequestReply
      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.
      Specified by:
      waitForAssignments in interface KafkaRequestReply<Req,Rep>
      Returns:
      a Uni object that resolves to a Set of TopicPartition once the assignments have been made.
    • waitForAssignments

      public io.smallrye.mutiny.Uni<Set<org.apache.kafka.common.TopicPartition>> waitForAssignments(Collection<org.apache.kafka.common.TopicPartition> topicPartitions)
      Description copied from interface: KafkaRequestReply
      Blocks until the consumer has been assigned given partitions for consumption.
      Specified by:
      waitForAssignments in interface KafkaRequestReply<Req,Rep>
      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

      public Map<CorrelationId,PendingReply> getPendingReplies()
      Description copied from interface: KafkaRequestReply
      Retrieves the pending replies for each topic.
      Specified by:
      getPendingReplies in interface KafkaRequestReply<Req,Rep>
      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

      public KafkaConsumer<?,Rep> getConsumer()
      Description copied from interface: KafkaRequestReply
      Retrieves the Kafka Consumer used for consuming messages.
      Specified by:
      getConsumer in interface KafkaRequestReply<Req,Rep>
      Returns:
      the Kafka Consumer used for consuming messages.
    • onSubscribe

      public void onSubscribe(Flow.Subscription subscription)
      Specified by:
      onSubscribe in interface Flow.Subscriber<Req>
    • onItem

      public void onItem(KafkaRecord<?,Rep> record)
      Specified by:
      onItem in interface io.smallrye.mutiny.subscription.MultiSubscriber<Req>
    • onFailure

      public void onFailure(Throwable failure)
      Specified by:
      onFailure in interface io.smallrye.mutiny.subscription.MultiSubscriber<Req>
    • onCompletion

      public void onCompletion()
      Specified by:
      onCompletion in interface io.smallrye.mutiny.subscription.MultiSubscriber<Req>