Skip to content
业余布道师 edited this page Aug 13, 2016 · 2 revisions

If you want to use the kafka new producer api KafkaProducer, since kafka 0.8.2.0.

 * The producer is thread safe and sharing a single producer instance
 * across threads will generally be faster than having multiple instances.

Use the new sender pool, config like this

<!-- Kafka New Sender Pool -->
<bean id="messageSenderPool" class="org.darkphoenixs.kafka.pool.KafkaMessageNewSenderPool" 
      init-method="init" destroy-method="destroy">
    <!-- producer config file -->
    <property name="config" value="kafka/newproducer.properties"/>
    <!-- it doesn't matter -->
    <property name="poolSize" value="10"/>
</bean>

config : the producer config file.

pros : the producer config properties(same as config).

poolSize : deprecated(the producer is singleton).

Note: init-method and destroy-method are required.