Hi, For your bolt: YourBean yb = new YourBean(); yb.setFoo(“foo”);
outputCollector.emit(anchor, new Values(yb)); For your spout: https://github.com/nathanmarz/storm-starter/blob/master/src/jvm/storm/starter/spout/RandomSentenceSpout.java You might want to register a custom serializer though – see http://storm.apache.org/documentation/Serialization.html Regards, Tom From: Ankur Garg [mailto:[email protected]] Sent: Mittwoch, 16. September 2015 15:37 To: [email protected]; [email protected] Subject: Emitting Custom Object as Tuple from spout Hi , I am new to apache Storm . To understand it I was looking at storm examples provided in the storm tutorial (https://github.com/apache/storm/tree/master/examples/storm-starter) . In all the examples , we are emitting prmitive types (String,int etc) as Tuples . In my use case I am having a Java Object which i want to emit as tuple to bolts . I am not sure how to do it . It seems I have to implement a custom Tuple producer to convert java Object to Values . Can anyone provide me some example how to do that : For ex my Java Object is : class Bean { int A ; String B; Bean2 b; //setters and getters } and Class Bean2 { //Some Attributes } Now , in my nextTuple() method for Spout , I have an instance of Bean object . How do I translate into Tuple and emit it and consume it through my bolt. Any ideas please. Thanks ankur
