'Apache Kafka SRMSG18304: Unknown channel

I'm implementing Apache Kafka in my Kotlin Quarkus application. I've followed the guides from Quarkus and I'm now at the testing phase.

This is my test class:

import com.abnamro.ddc.pigeon.domain.core.models.events.ClassificationFinishedEvent
import io.mockk.impl.annotations.InjectMockKs
import io.mockk.impl.annotations.MockK
import io.mockk.junit5.MockKExtension
import io.quarkus.test.common.QuarkusTestResource
import io.quarkus.test.junit.QuarkusTest
import io.smallrye.reactive.messaging.providers.connectors.InMemoryConnector
import io.smallrye.reactive.messaging.providers.connectors.InMemorySink
import org.eclipse.microprofile.reactive.messaging.Emitter
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.extension.ExtendWith

@QuarkusTest
@QuarkusTestResource(KafkaTestResourceLifecycleManager::class)
internal class CaptureCaseCompletedTopicPublisherTest {

    @MockK(relaxed = true)
    lateinit var emitter: Emitter<ClassificationFinishedEvent>

    @InjectMockKs
    lateinit var topicPublisher: CaptureCaseCompletedTopicPublisher

    var connector = InMemoryConnector()

    @MockK
    lateinit var classificationFinishedEvent: ClassificationFinishedEvent

    @Test
    internal fun `A proper ClassificationFinishedEvent should return a successful response`() {
        val incoming: InMemorySink<ClassificationFinishedEvent> = connector.sink("dial-out")

        topicPublisher.send(classificationFinishedEvent)
    }
}

And my lifecycle manager:

import io.quarkus.test.common.QuarkusTestResourceLifecycleManager
import io.smallrye.reactive.messaging.providers.connectors.InMemoryConnector

class KafkaTestResourceLifecycleManager : QuarkusTestResourceLifecycleManager {
    override fun start(): MutableMap<String, String> {
        val env: MutableMap<String, String> = HashMap()
        val props1 = InMemoryConnector.switchIncomingChannelsToInMemory("dial-in")
        val props2 = InMemoryConnector.switchOutgoingChannelsToInMemory("dial-out")
        env.putAll(props1)
        env.putAll(props2)
        return env
    }

    override fun stop() {
        InMemoryConnector.clear()
    }
}

The error I'm getting is the following: java.lang.IllegalArgumentException: SRMSG18304: Unknown channel dial-out

Now I've set my channel in my application.yml file like this:

"%test":
  mp:
    messaging:
      outgoing:
        dial-out:
          connector: smallrye-in-memory
          topic: test
      incoming:
        dial-in:
          connector: smallrye-in-memory
          topic: test

So I'm a bit lost on why the channel isn't being picked up. Does anyone have an idea?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source