You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@kafka.apache.org by Li Tao <ah...@gmail.com> on 2015/09/28 05:40:28 UTC

which producer should be used

Hi there,
I noticed that there are several producers our there:

**  **org.apache.kafka.clients.producer.KafkaProducer<K,V>*
**  **kafka.javaapi.producer.Producer*

What's the difference between them? Which one should be used?

Re: which producer should be used

Posted by Sharninder <sh...@gmail.com>.
Sorry, you're correct. Looks like a silly mistake on my side. I'll check my
imports

--
Sharninder


On Mon, Sep 28, 2015 at 6:24 PM, Gwen Shapira <gw...@confluent.io> wrote:

> KafkaProducer takes ProducerRecord as an argument to send().
>
> See the code:
>
> https://github.com/apache/kafka/blob/trunk/clients/src/main/java/org/apache/kafka/clients/producer/KafkaProducer.java#L298
>
> and a usage example here:
>
> https://github.com/gwenshap/kafka-examples/blob/master/SimpleCounter/src/main/java/com/shapira/examples/producer/simplecounter/DemoProducerNewJava.java
>
> If you can send Seq<KeyedMessage> instead, it looks like you are still
> using an older Scala producer. Please check your import statements and
> which object you are instantiating.
>
> Gwen
>
> On Sun, Sep 27, 2015 at 10:58 PM, Sharninder <sh...@gmail.com> wrote:
>
> > Hi Gwen,
> >
> > We were using kafka.javaapi.producer.Producer so far and I'm trying to
> move
> > the code to use KafkaProducer now but it seems the send api for producer
> > takes Seq<KeyedMessage> as arguement instead of ProducerRecord as the
> > documentation for 0.8.2 says:
> >
> >
> >
> http://kafka.apache.org/082/javadoc/org/apache/kafka/clients/producer/KafkaProducer.html
> >
> > Is there an equivalent Java API for 0.8.2 yet or is the older one the
> most
> > current?
> >
> > --
> > Sharninder
> >
> >
> > On Mon, Sep 28, 2015 at 9:15 AM, Gwen Shapira <gw...@confluent.io> wrote:
> >
> > > KafkaProducer is the most current and full-featured one, and it should
> be
> > > used.
> > >
> > > The other producers will be deprecated in a release or two, so I
> > recommend
> > > not to use them.
> > >
> > > On Sun, Sep 27, 2015 at 8:40 PM, Li Tao <ah...@gmail.com>
> wrote:
> > >
> > > > Hi there,
> > > > I noticed that there are several producers our there:
> > > >
> > > > **  **org.apache.kafka.clients.producer.KafkaProducer<K,V>*
> > > > **  **kafka.javaapi.producer.Producer*
> > > >
> > > > What's the difference between them? Which one should be used?
> > > >
> > >
> >
> >
> >
> > --
> > --
> > Sharninder
> >
>



-- 
--
Sharninder

Re: which producer should be used

Posted by Gwen Shapira <gw...@confluent.io>.
KafkaProducer takes ProducerRecord as an argument to send().

See the code:
https://github.com/apache/kafka/blob/trunk/clients/src/main/java/org/apache/kafka/clients/producer/KafkaProducer.java#L298

and a usage example here:
https://github.com/gwenshap/kafka-examples/blob/master/SimpleCounter/src/main/java/com/shapira/examples/producer/simplecounter/DemoProducerNewJava.java

If you can send Seq<KeyedMessage> instead, it looks like you are still
using an older Scala producer. Please check your import statements and
which object you are instantiating.

Gwen

On Sun, Sep 27, 2015 at 10:58 PM, Sharninder <sh...@gmail.com> wrote:

> Hi Gwen,
>
> We were using kafka.javaapi.producer.Producer so far and I'm trying to move
> the code to use KafkaProducer now but it seems the send api for producer
> takes Seq<KeyedMessage> as arguement instead of ProducerRecord as the
> documentation for 0.8.2 says:
>
>
> http://kafka.apache.org/082/javadoc/org/apache/kafka/clients/producer/KafkaProducer.html
>
> Is there an equivalent Java API for 0.8.2 yet or is the older one the most
> current?
>
> --
> Sharninder
>
>
> On Mon, Sep 28, 2015 at 9:15 AM, Gwen Shapira <gw...@confluent.io> wrote:
>
> > KafkaProducer is the most current and full-featured one, and it should be
> > used.
> >
> > The other producers will be deprecated in a release or two, so I
> recommend
> > not to use them.
> >
> > On Sun, Sep 27, 2015 at 8:40 PM, Li Tao <ah...@gmail.com> wrote:
> >
> > > Hi there,
> > > I noticed that there are several producers our there:
> > >
> > > **  **org.apache.kafka.clients.producer.KafkaProducer<K,V>*
> > > **  **kafka.javaapi.producer.Producer*
> > >
> > > What's the difference between them? Which one should be used?
> > >
> >
>
>
>
> --
> --
> Sharninder
>

Re: which producer should be used

Posted by Sharninder <sh...@gmail.com>.
Hi Gwen,

We were using kafka.javaapi.producer.Producer so far and I'm trying to move
the code to use KafkaProducer now but it seems the send api for producer
takes Seq<KeyedMessage> as arguement instead of ProducerRecord as the
documentation for 0.8.2 says:

http://kafka.apache.org/082/javadoc/org/apache/kafka/clients/producer/KafkaProducer.html

Is there an equivalent Java API for 0.8.2 yet or is the older one the most
current?

--
Sharninder


On Mon, Sep 28, 2015 at 9:15 AM, Gwen Shapira <gw...@confluent.io> wrote:

> KafkaProducer is the most current and full-featured one, and it should be
> used.
>
> The other producers will be deprecated in a release or two, so I recommend
> not to use them.
>
> On Sun, Sep 27, 2015 at 8:40 PM, Li Tao <ah...@gmail.com> wrote:
>
> > Hi there,
> > I noticed that there are several producers our there:
> >
> > **  **org.apache.kafka.clients.producer.KafkaProducer<K,V>*
> > **  **kafka.javaapi.producer.Producer*
> >
> > What's the difference between them? Which one should be used?
> >
>



-- 
--
Sharninder

Re: which producer should be used

Posted by Gwen Shapira <gw...@confluent.io>.
KafkaProducer is the most current and full-featured one, and it should be
used.

The other producers will be deprecated in a release or two, so I recommend
not to use them.

On Sun, Sep 27, 2015 at 8:40 PM, Li Tao <ah...@gmail.com> wrote:

> Hi there,
> I noticed that there are several producers our there:
>
> **  **org.apache.kafka.clients.producer.KafkaProducer<K,V>*
> **  **kafka.javaapi.producer.Producer*
>
> What's the difference between them? Which one should be used?
>