Dear Guozhang,
Sorry for the late reply.
Please see the sample code which i written to send the bean object.
import java.util.Properties;
import kafka.producer.KeyedMessage;
import kafka.producer.ProducerConfig;
public class KafkaProducerBean {
final static String TOPIC = "*alarm*";
public static void main(String[] args) {
Properties properties = new Properties();
properties.put("metadata.broker.list","x.x.x.227:9092");
properties.put("serializer.class","TestBean");
ProducerConfig producerConfig = new ProducerConfig(properties);
kafka.javaapi.producer.Producer<String,TestBean> producer = new
kafka.javaapi.producer.Producer<String, TestBean>(producerConfig);
TestBean tb = new TestBean();
tb.setName("Olive");
tb.setAge(25);
KeyedMessage<String, TestBean> message =new KeyedMessage<String,
TestBean>(*TOPIC*, tb);
producer.send(message);
producer.close();
}
}
Error :
Exception in thread "main" java.lang.NoSuchMethodException:
TestBean.<init>(kafka.utils.VerifiableProperties)
Thanks
Ramesh K
On Wed, Dec 3, 2014 at 1:03 AM, Guozhang Wang <[email protected]> wrote:
> Ramesh,
>
> Which producer are you using in 0.8.1? kafka.api.producer or
> org.apache.kafka.clients.producer?
>
> Guozhang
>
> On Tue, Dec 2, 2014 at 2:12 AM, Ramesh K <[email protected]> wrote:
>
> > Hi,
> >
> > I have written the basic program to send String or byte[] messages to
> > consumer from producer by using java & Kafka 0.8.1 .
> > It Works perfectly.But i wanted to send serialized object(Java Bean
> > Object).
> >
> > Is it possible to send the serialized object from producer to consumer?
> >
> > if possible, please share the ideas/samples.
> >
> > Thanks in advance..
> > Ramesh Kasi
> >
>
>
>
> --
> -- Guozhang
>