kafka-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Grant Henke <ghe...@cloudera.com>
Subject Re: blocking KafkaProducer call
Date Wed, 01 Apr 2015 17:41:20 GMT
They can. You can read more about configuring the new java producer here:
http://kafka.apache.org/documentation.html#newproducerconfigs

Thanks,
Grant

On Wed, Apr 1, 2015 at 12:34 PM, sunil kalva <sambarcode@gmail.com> wrote:

> Does these config params has effect when i try to simulate "sync" mode by
> not passing callback ?
>
> On Wed, Apr 1, 2015 at 10:32 PM, Mayuresh Gharat <
> gharatmayuresh15@gmail.com> wrote:
>
>> Whats your "linger.ms" and "batch.size" ?
>>
>> Thanks,
>>
>> Mayuresh
>>
>> On Wed, Apr 1, 2015 at 5:51 AM, sunil kalva <sambarcode@gmail.com> wrote:
>>
>> > I am trying to simulate "sync" call using following code,
>> >
>> > try {
>> >
>> >     Future<RecordMetadata> send = producer.send(new
>> > ProducerRecord<byte[],byte[]>("the-topic", "key".getBytes(),
>> > "value".getBytes())).get();
>> >
>> >      send.get();
>> >
>> >     System.out.println("Time = " + (System.currentTimeMillis() - b));
>> > } catch (Exception e) {
>> >
>> > }
>> >
>> > And i am using new "org.apache.kafka.clients.producer.KafkaProducer"
>> > class for sending messages, each  message  is taking more than 100ms,
>> > am i missing something. If i use old "kafka.javaapi.producer.Produce"
>> > it is giving the desired throughput.
>> >
>> > Please advice me hot to fix this.
>> >
>> >
>> > On Tue, Mar 31, 2015 at 11:21 PM, sunil kalva <sambarcode@gmail.com>
>> > wrote:
>> >
>> > > thanks ghenke, that was a quick response. I will test and will let you
>> > > know if i have some questions.
>> > >
>> > > On Tue, Mar 31, 2015 at 11:17 PM, Grant Henke <ghenke@cloudera.com>
>> > wrote:
>> > >
>> > >> I think you are looking at is this section:
>> > >>
>> > >> > If you want to simulate a simple blocking call you can do the
>> > following:
>> > >> >
>> > >> > producer.send(new ProducerRecord<byte[],byte[]>("the-topic",
>> > >> "key".getBytes(), "value".getBytes())).get();
>> > >> >
>> > >> > What that is doing is calling .get() on the Future returned by
the
>> > send
>> > >> method. This will block until the message is sent or an exception is
>> > >> thrown.
>> > >>
>> > >> The documentation for Future is here:
>> > >>
>> > >>
>> >
>> http://docs.oracle.com/javase/7/docs/api/java/util/concurrent/Future.html#get()
>> > >>
>> > >> On Tue, Mar 31, 2015 at 12:30 PM, sunil kalva <sambarcode@gmail.com>
>> > >> wrote:
>> > >>
>> > >> > Hi
>> > >> > According to this
>> > >> >
>> > >> >
>> > >>
>> >
>> http://kafka.apache.org/082/javadoc/index.html?org/apache/kafka/clients/producer/KafkaProducer.html
>> > >> > documentation, if i don't pass callback it will work as blocking
>> call,
>> > >> Does
>> > >> > it mean that message will be immediately sent to kafka cluster
and
>> all
>> > >> > possible exceptions will be throws immediately if not able to
send
>> ?
>> > >> >
>> > >> > --
>> > >> > SunilKalva
>> > >> >
>> > >>
>> > >>
>> > >>
>> > >> --
>> > >> Grant Henke
>> > >> Solutions Consultant | Cloudera
>> > >> ghenke@cloudera.com | 920-980-8979
>> > >> twitter.com/ghenke <http://twitter.com/gchenke> |
>> > >> linkedin.com/in/granthenke
>> > >>
>> > >
>> > >
>> > >
>> > > --
>> > > SunilKalva
>> > >
>> >
>> >
>> >
>> > --
>> > SunilKalva
>> >
>>
>>
>>
>> --
>> -Regards,
>> Mayuresh R. Gharat
>> (862) 250-7125
>>
>
>
>
> --
> SunilKalva
>



-- 
Grant Henke
Solutions Consultant | Cloudera
ghenke@cloudera.com | twitter.com/ghenke <http://twitter.com/gchenke> |
linkedin.com/in/granthenke

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message