Home > Mobile >  Kolin Overload resolution ambiguity. All these functions match
Kolin Overload resolution ambiguity. All these functions match

Time:10-18

I am trying to add a global state store to my topology , but getting error as Overload resolution ambiguity. All these functions match.

 val stateStoreBuilder =
            Stores.keyValueStoreBuilder(
                Stores.persistentKeyValueStore("my_global_store"),
                Serdes.String(),
                Serdes.String()
            )

topology.addGlobalStore(
            stateStoreBuilder,
            "source_name",
            KEY_JSON_DE,
            VALUE_JSON_DE,
            "topic_name",
            "processor_name",
            { MyStoreProcessor::class.java },
        )

Getting error for addGlobalStore method. Using below versions in Gradle file :-

kotlin("jvm") version "1.7.10" kotlin("plugin.spring") version "1.7.10"

implementation("org.apache.kafka:kafka-streams:3.3.1") implementation("org.springframework.kafka:spring-kafka")

enter image description here

CodePudding user response:

I think the problem is shows in the small letter of the error.

The Kotlin compiler cannot figure out which method to use. In particular to what class it should map the last lambda, to org.apache.kafka.streams.processor.ProcessSupplier or org.apache.kafka.streams.processor.api.ProcessSupplier (notice the later has an api package in the middle).

I reckon that if you cast the lambda, it should work. I've never tried this, but I wonder if changing the line to the following would work

{ MyStoreProcessor::class.java } as org.apache.kafka.streams.processor.api.ProcessSupplier
  • Related