Hi good people, 

I looking at an example from storm-starter project 
https://github.com/apache/storm/blob/master/examples/storm-starter/src/jvm/org/apache/storm/starter/BasicDRPCTopology.java
If works for me, drpc replies with exclamation and everything is fine. 
But now I modified it like this:

public class MyTopology {
    public static class ExclamationBolt extends BaseBasicBolt {

        @Override
        public void declareOutputFields(OutputFieldsDeclarer declarer) {
            declarer.declare(new Fields("id", "result"));
        }

        @Override
        public void execute(Tuple tuple, BasicOutputCollector collector) {
            String arg = tuple.getString(1);
            for (int i = 0; i < 3; i++) {
                String res = arg + "-> " + i;
                System.out.println("emit -> " + res);
                collector.emit(new Values(tuple.getValue(0), res));
            }
        }

    }

    public static void main(String ... args) throws InvalidTopologyException, 
AuthorizationException, AlreadyAliveException {
        LinearDRPCTopologyBuilder builder = new 
LinearDRPCTopologyBuilder("exclamation");
        LocalDRPC drpc = new LocalDRPC();
        builder.addBolt(new ExclamationBolt(), 1);
        Config config = new Config();
        LocalCluster cluster = new LocalCluster();
        cluster.submitTopology("mytopology", config, 
builder.createLocalTopology(drpc));
        System.out.println("drpc replies: " + drpc.execute("exclamation", 
"aaa"));
    }
}

As you can see I’ve added small loop into the bolt so it emits several tuples 
per one input. But drpc.execute method returns only one tuple! In the logs I 
see several emits: 

emit -> aaa-> 0
emit -> aaa-> 1
emit -> aaa-> 2

But only one response:

drpc replies: aaa-> 0

Does it mean that each my bolt should emit only single output per input? 
How can I get all three tuples in response? 
Documentation suggest to use CoordinatedBolt directly, but I can’t find any 
example…

P. s. I’ve also tried the same with manual drpc 
(https://github.com/apache/storm/blob/master/examples/storm-starter/src/jvm/org/apache/storm/starter/ManualDRPC.java)
 - same issue.

Thank you 



Reply via email to