Thanks so much for this explanation.

 

Am I right that BasicBolt2 should not emit anything because it’s at the end of the line? Right now I am emitting tuples from the last bolt and it appears to work, but I guess I shouldn’t.

 

From: Stig Rohde Døssing <srdo@apache.org>
Reply-To: "user@storm.apache.org" <user@storm.apache.org>
Date: Monday, November 20, 2017 at 11:37 AM
To: "user@storm.apache.org" <user@storm.apache.org>
Subject: Re: Acking, failing, and anchor tuples

 

****This email did not originate from the Premier, Inc. network. Use caution when opening attachments or clicking on URLs.*****


.

I think you are a little confused about the difference between failing tuples and skipping bolts. Here's a quick rundown:

 

Let's say your spout has emitted a tuple t. BaseBasicBolt has just received t0, which is a tuple anchored to t.

 

If you decide to emit nothing and return from execute(), t0 will be acked. If t0 was the last pending tuple anchored to t, t will be acked on the spout (marked as "done", so it won't be replayed).

 

If you instead throw FailedException t is marked as failed, and the spout will likely replay it.

 

If you emit any tuples they will automatically be anchored to t. This means that the new tuples must also succeed before t gets acked.

 

So here's the answers to your questions:

 

The correct way to ack a tuple from a BaseBasicBolt is to not throw FailedException. Unless you throw FailedException, the tuple will be acked.

The correct way to fail a tuple from a BaseBasicBolt is to throw FailedException.

 

Also because it seems like this is what you're actually asking: If you have a topology like Spout -> BasicBolt1 -> BasicBolt2 and you have a tuple t1 in BasicBolt1 and you want to skip BasicBolt2, BasicBolt1 simply shouldn't emit any tuples while running execute() for t1.

 

I hope this helps.

 

2017-11-20 15:39 GMT+01:00 Hannum, Daniel <Daniel_Hannum@premierinc.com>:

Hi,

 

I’m trying to get clear on how to handle various cases in my BaseBasicBolt.

 

So far, I just have each bolt emit more tuples, pretty standard. But I still do that for the last bolt in the topology. I’m not sure I should do that. Seems dirty.

 

Now, I have a case where I want a bolt to fail a tuple (skip all bolts after). I read that I should just return without emitting any tuples and that functions as a fail. That seems odd to me, that I should emit tuples at the end of my topology for success even when they go nowhere, but not emit anything to show failure.

 

And then there’s always FailedException. Maybe I should forget all of this and just throw that if I want to fail the tuple.

 

So what is the correct way to

  1. Ack a tuple properly in the last bolt
  2. Fail a tuple in the middle

 

Thanks!