Kafka サーバーをセットアップし、プロデューサーを使用してメッセージを送信することで、コードをローカルでテストしようとしましたが、このコードの単体テストを作成する方法があるかどうか疑問に思っています (メッセージが受信されたかどうかをテストします)。消費者が正しい)。
val consumerSettings = ConsumerSettings(system,
new ByteArrayDeserializer, new StringDeserializer)
.withBootstrapServers("localhost:9092")
.withGroupId("group1")
.withProperty(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, "earliest")
val done = Consumer.committableSource(consumerSettings,
Subscriptions.topics("topic1"))
.map { msg =>
msg.committableOffset.commitScaladsl()
}
.runWith(Sink.ignore)