I would like to create a shared producer when using service discovery.
With service discovery I can do this to create ProducerSettings
:
private val producerConfig = system.settings.config.getConfig("discovery-producer")
val producerSettings: ProducerSettings[String, String] = ProducerSettings[String, String](producerConfig, new StringSerializer, new StringSerializer)
.withEnrichAsync(DiscoverySupport.producerBootstrapServers(producerConfig))
With that approach I can call:
val producer: Future[Producer[String, String]] = producerSettings.createKafkaProducerAsync()
How I can pass this future producer to ProducerSettings
when creating a flow? e.g.
Producer.flowWithContext(producerSettings.with???)