Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why are all the low-level (Java) Kafka AdminClient calls wrapped in effectBlocking? #492

Open
guizmaii opened this issue Aug 5, 2022 · 4 comments

Comments

@guizmaii
Copy link
Member

guizmaii commented Aug 5, 2022

AFAIK, and seeing that the Kafka AdminClient is using Java Futures (KafkaFuture implementing java.util.concurrent.Future and being based on CompletionStage since Kafka 3.1 or 3.2), why are all the calls made with this client wrapped in a effectBlocking?

Random example took from the code of zio-kafka:

    /**
     * List offset for the specified partitions.
     */
    override def listOffsets(
      topicPartitionOffsets: Map[TopicPartition, OffsetSpec],
      options: Option[ListOffsetsOptions] = None
    ): Task[Map[TopicPartition, ListOffsetsResultInfo]] = {
      val asJava = topicPartitionOffsets.bimap(_.asJava, _.asJava).asJava
      fromKafkaFuture {
        blocking.effectBlocking(
          options
            .fold(adminClient.listOffsets(asJava))(opts => adminClient.listOffsets(asJava, opts.asJava))
            .all()
        )
      }
    }.map(_.asScala.toMap.bimap(TopicPartition(_), ListOffsetsResultInfo(_)))
@guizmaii guizmaii closed this as completed Aug 5, 2022
@guizmaii
Copy link
Member Author

guizmaii commented Aug 5, 2022

is it because of this synchronized:

image

?? 🤔

@guizmaii guizmaii reopened this Aug 5, 2022
@guizmaii guizmaii changed the title Why are all the low-level (Java) Kafka client calls wrapped in effectBlocking? Why are all the low-level (Java) Kafka AdminClient calls wrapped in effectBlocking? May 12, 2023
@svroonland
Copy link
Collaborator

@guizmaii What shall we do with this one year old issue?

@guizmaii
Copy link
Member Author

guizmaii commented Aug 7, 2023

@svroonland I'm still waiting for an answer/to understand why we need this and if we should keep these usages of blocking
I'd prefer to leave it open if that's ok for you

@svroonland
Copy link
Collaborator

I suppose it was originally written that way as a precaution and probably after some actual experience of blocking in some circumstances.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants