Inject a producer using ProducerSettings

Hi,

By defining a producerFactory, I can inject my home made KafkaProducer using ProducerSettings.scala

One question, why is this factory requiring to produce a KafkaProducer?
(I would expect to see its interface Producer)

ProducerSettings[K,V] => KafkaProducer[K,V]

By example, for testing purposes, I wanted to use MockProducer in my custom producerFactory

Regards,
Benoit

Hi Benoit,

You may also notice that withProducerFactory is internal API and not available to be used right now.
This feature is used by internal tests within Alpakka Kafka.

Please feel free to suggest the changes you’d like to see in a Pull Request.

Cheers,
Enno.

Hi Enno,

Thanks for the answer.

I saw that withProducerFactory is an internal API but didn’t found any other way to inject a custom Producer.
Is there an official recommended strategy to do that?

I also tested the Interceptors, but it didn’t manage to use my home made retry policy with a simple interceptor.

I created this pr 710 that contains a proposition to change the factory signature.

Cheers,
Benoît