Home | About | Sematext search-lucene.com search-hadoop.com
 Search Hadoop and all its subprojects:

Switch to Plain View
Kafka, mail # user - Sending any other object (instead of Message)


+
navneet sharma 2012-06-20, 19:25
+
Jun Rao 2012-06-20, 20:26
Copy link to this message
-
Re: Sending any other object (instead of Message)
navneet sharma 2012-06-28, 09:39
hi Jun,

is there any example to follow? I tried your suggestion but looks like i am
missing something..

Thanks,
Navneet Sharma

On Thu, Jun 21, 2012 at 1:56 AM, Jun Rao <[EMAIL PROTECTED]> wrote:

> Navneet,
>
> The easiest way is to implement an Encoder and a Decoder of your objects
> and specify it in the producer and the consumer, respectively.
>
> Thanks,
>
> Jun
>
> On Wed, Jun 20, 2012 at 12:25 PM, navneet sharma <
> [EMAIL PROTECTED]> wrote:
>
> > Hello,
> >
> > I am following this group from quite some time. Recently i tried sending
> my
> > customized object from producer instead of String.
> >
> > I was successful in that by providing a way to serialize my object and
> > creating Message object like this:
> >
> > Object event = <some object>;
> > Message message = new Message(TestUtils.getBytes(event))
> > producer.send(new ProducerData<Integer, Message>(topic, message));
> >
> > TestUtils.getBytes just uses ObjectOutputStream to give a byte array.
> >
> > while i was succesful in sending the object, but i could not retrieve it
> at
> > consumer end since kafka.message.Message doesnt carry any information
> about
> > underlying object(or maybe its always assuming it to be String).
> >
> > My questions are:
> > 1) Is it possible to send any other object then String?
> > 2) If yes, then Can my approach be rectified? Or am i missing anything?
> >
> > Thanks,
> > Navneet Sharma
> >
>
+
Jun Rao 2012-06-28, 14:34