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)

Copy link to this message
Sending any other object (instead of Message)

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?

Navneet Sharma
Jun Rao 2012-06-20, 20:26
navneet sharma 2012-06-28, 09:39
Jun Rao 2012-06-28, 14:34