Home | About | Sematext search-lucene.com search-hadoop.com
NEW: Monitor These Apps!
elasticsearch, apache solr, apache hbase, hadoop, redis, casssandra, amazon cloudwatch, mysql, memcached, apache kafka, apache zookeeper, apache storm, ubuntu, centOS, red hat, debian, puppet labs, java, senseiDB
 Search Hadoop and all its subprojects:

Switch to Threaded View
Kafka >> mail # user >> Sending any other object (instead of Message)


Copy link to this message
-
Sending any other object (instead of Message)
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
NEW: Monitor These Apps!
elasticsearch, apache solr, apache hbase, hadoop, redis, casssandra, amazon cloudwatch, mysql, memcached, apache kafka, apache zookeeper, apache storm, ubuntu, centOS, red hat, debian, puppet labs, java, senseiDB