How to emit tuple in diffrent for each loops and declare in single Fields method of storm bolt?
<p>I'm getting the required strings from the tuple.My Strings are appended one so I’m splitting them and emitting in a for each loop.if I write a single emit (if I emit only "id")bolt shows no exceptions it works fine,but when I add one more for-each to split other strings and on emitting them bolt is throwing the exception as follow </p>

<pre><code>java.lang.IllegalArgumentException: Tuple created with wrong number of fields. Expected 2 fields but got 1 fields at backtype.storm.tuple.TupleImpl.&lt;init&gt;(TupleImpl.java:58) at backtype.storm.daemon.executor$fn__5694$fn__5707$bolt_emit__5736.invoke(executor.clj:739) at backtype.storm.daemon.executor$fn__5694$fn$reify__5742.emit(executor.clj:763) at backtype.storm.task.OutputCollector.emit(OutputCollector.java:203) at backtype.storm.task.OutputCollector.emit(OutputCollector.java:63) at backtype.storm.task.OutputCollector.emit(OutputCollector.java:101) at test.bolts.TInserts.execute(TInsert.java:264)
</code></pre>

<p>Here is Mybolt code</p>

<pre><code> public void execute(Tuple tuple) {
   try {
String screenname=tuple.getStringByField("s_name");
    String mentionname=tuple.getStringByField("n_name");
    String mentionid=tuple.getStringByField("n_id");

                 if(mentionid != null &amp;&amp; !mentionid.isEmpty()){
                     for(String id:mentionid.split(",")){ 
                        id = id.trim();
                          this.collector.emit(new Values(id));
 this.collector.ack(tuple);
 }//for close
 }//if condtion for id
 if(mentionname != null &amp;&amp; !mentionname.isEmpty()){
                     for(String mns:mentionname.split(",")){ 
                        mns = mns.trim();
                          this.collector.emit(new Values(mns));
this.collector.ack(tuple);
   }//for close
 }//if condtion for mentionname

  } //if close
    }
             catch (Exception e) {
           this.collector.reportError(e);
          this.collector.fail(tuple);
             }
       } 


@Override
   public void declareOutputFields(OutputFieldsDeclarer outputFieldsDeclarer) {

//   outputFieldsDeclarer.declare(new Fields("id","mns"));//doesn't throw any   exception if i emit only id(1st for)                     
    outputFieldsDeclarer.declare(new Fields("id","mns"));//thows exception 
}
}
</code></pre>

<p>How to emit id and mns in single emit method? I think that doesn't throw any error or exception.Is there a way to do so ?</p>

<pre><code>this.collector.emit(new Values(id,mns));
</code></pre>