-Re: Sending any other object (instead of Message)
navneet sharma 2012-06-28, 09:39
is there any example to follow? I tried your suggestion but looks like i am
On Thu, Jun 21, 2012 at 1:56 AM, Jun Rao <[EMAIL PROTECTED]> wrote:
> The easiest way is to implement an Encoder and a Decoder of your objects
> and specify it in the producer and the consumer, respectively.
> 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
> > 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
> > consumer end since kafka.message.Message doesnt carry any information
> > 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