1
votes

I have a topology as follows:

Spout --> Bolt 1 --> Bolt2 --> Bolt3

Where Spout has a stream "mystream" that is subscribed by Bolt2 and other stream "bolt1stream" is where Bolt1 receives tuples.

In case of failure of tuples(Bolt2 in my case), I would like to replay it from Bolt2 not again from Bolt1

For this, I'll fail the tuple in Bolt2. When this fail message reaches spout, I emit it to mystream / bolt1stream based on the point where it failed. So it would start processing from the fail point.

However the fail() in BaseRichSpout has Object parameter, instead of Tuple. How would I know the sourceComponent, as I would do with Tuple? Or what is the best way to replay a tuple from wherever it failed.

Thanks in advance

1

1 Answers

0
votes

For each stream, I use a separate class to identify the stream. The alternative is to use the same class and have an integer or enum inside the class which identifies the stream.

@Override
public void fail(Object msgId) {
   if (msgId instanceof MyTupleClass) {
   // Default stream   
   MyTupleClass oneTuple = (MyTupleClass) msgId;
   //---tuple replay logic. Re-emitting the failed tuples    
   ReEmitTheDefaultStreamTuple(oneTuple);
}
else {
   //it's the other stream
   //For this stream you could perhaps use MySecondTupleClass
}