You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@storm.apache.org by eric perler <er...@hotmail.com> on 2014/03/26 14:40:16 UTC

storm best practice

hello

i just started using storm today .. and i have a very newbie question to make sure that i am using storm correctly...

i set up s simple local cluster by following the tutorial.. and its working fine.. but i have a question regarding best practice... basically.. i want to know if my spout and bolt code is following best pratice.. the pseudo code is below... i have a spout the listens for messages on a tibco ems queue, and then does a simple transformation.. and then writes the data to cassandra

class EMSSpout  extends BaseRichSpout{
    public void nextTuple() {
         String word = TibcoEMSQueueListener.receiveMessage(); 
        _collector.emit(new Values(word));
    }
}

class TransformBolt extends BaseRichBolt {
    public void execute(Tuple tuple) {
             String newTuple = transformTuple(tuple);
            _collector.emit(tuple, new Values(newTuple.getString(0)));
            _collector.ack(tuple);
    }
}

class WriteToCassandraBolt extends BaseRichBolt {

    public void execute(Tuple tuple) {

            DataStaxCassandraDriver.insert(tuple.getString(0));

    }

}

my newbie question is.. is it correct to make IO calls (i.e. JMS and JDBC) from within the "Spout.nextTuple" and "Bolt.execute" methods... or is there a better design practice for doing this ?

sorry in advance if this is a stupid question :)  





there a better design practice for doing this