Your coworker is incorrect. You call "ack" OR "fail". If you call both,
you'll probably get an NPE.

When ack/fail is called, ack or fail is called on the spout with the ID the
spout assigned to the root tuple (e.g. a message ID from a message queue,
or other external identifier). This does not halt any other in-flight
tuples in the same tuple graph.

try {
  ...
  collector.ack(tuple);
} catch(Exception e) {
  collector.fail(tuple);
}

Michael Rose (@Xorlev <https://twitter.com/xorlev>)
Senior Platform Engineer, FullContact <http://www.fullcontact.com/>
[email protected]

On Wed, Nov 12, 2014 at 2:19 PM, William Oberman <[email protected]>
wrote:

> A coworker & I are debating this code:
> ----------
> try {
>   ...
> } catch(Exception e) {
>    collector.fail(tuple);
> }
> collector.ack(tuple);
> -----------
>
> His claim is ack() is acknowledgement of end of processing.  E.g. you
> ALWAYS have to call ack() (to stop the implicit timeout you're working
> against), and if you want to fail() you should call it before the ack()
> (e.g. the code above).
>
> My claim is fail() "is a" ack in the sense of it being an acknowledgement,
> an acknowledgement of failure.  Thus the ack() should be before the catch,
> and Bolts should end with one or the other, but not both.
>
> A followup question if I'm right: what does Storm do when a bolt calls
> fail() and ack() on the same tuple?  :-)
>
> will
>

Reply via email to