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

Embedded Kafka does not work with Spark 3.5 #521

Open
adeshrd opened this issue Sep 10, 2024 · 0 comments
Open

Embedded Kafka does not work with Spark 3.5 #521

adeshrd opened this issue Sep 10, 2024 · 0 comments

Comments

@adeshrd
Copy link

adeshrd commented Sep 10, 2024

I have been using Embedded Kafka in my batch job to test if my output is correct.
It works correctly upto Spark 3.4.3 but fails at Spark 3.5.0.
I have tried different versions of Embedded Kafka as well upto the latest version.

This is the exception I get:

io.github.embeddedkafka.KafkaUnavailableException was thrown.
io.github.embeddedkafka.KafkaUnavailableException
at io.github.embeddedkafka.ops.ProducerOps.publishToKafka(ProducerOps.scala:219)
at io.github.embeddedkafka.ops.ProducerOps.publishToKafka(ProducerOps.scala:82)
at io.github.embeddedkafka.ops.ProducerOps.publishToKafka$(ProducerOps.scala:72)
at MySpec.publishToKafka(MySpec.scala:5)

This is my test code:

import io.github.embeddedkafka.{EmbeddedKafka, EmbeddedKafkaConfig}
import org.scalatest.matchers.should.Matchers // Corrected import
import org.scalatest.wordspec.AnyWordSpecLike

class MySpec extends AnyWordSpecLike with Matchers with EmbeddedKafka {

  "runs with embedded kafka on arbitrary available ports" should {

    "work" in {
      val userDefinedConfig = EmbeddedKafkaConfig(kafkaPort = 0, zooKeeperPort = 0)

      withRunningKafkaOnFoundPort(userDefinedConfig) { implicit actualConfig =>
        // A Kafka broker is listening on actualConfig.kafkaPort
        publishStringMessageToKafka("topic", "message")
        consumeFirstStringMessageFrom("topic") shouldBe "message"
      }
    }
  }
}

These are the relevant libraries:

<spark.version>3.5.0</spark.version>
<scala.version>2.12.15</scala.version>
<embedded.kafka.version>3.8.0</embedded.kafka.version>

I have reproduced this by just including Spark Core and Embedded Kafka as dependencies.

Please help. Thank you

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

1 participant