You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@storm.apache.org by William Oberman <ob...@civicscience.com> on 2014/11/12 22:19:28 UTC

ack and fail

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

Re: ack and fail

Posted by William Oberman <ob...@civicscience.com>.
Thanks for settling the bet!

will

On Wed, Nov 12, 2014 at 4:53 PM, Vladi Feigin <vl...@gmail.com> wrote:

> Hi
> It doesn't make sense to call both on the same tuple
> Vladi
>
> On Wed, Nov 12, 2014 at 11:19 PM, William Oberman <
> oberman@civicscience.com> 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
>>
>
>

Re: ack and fail

Posted by Vladi Feigin <vl...@gmail.com>.
Hi
It doesn't make sense to call both on the same tuple
Vladi

On Wed, Nov 12, 2014 at 11:19 PM, William Oberman <ob...@civicscience.com>
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
>

Re: ack and fail

Posted by Michael Rose <mi...@fullcontact.com>.
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/>
michael@fullcontact.com

On Wed, Nov 12, 2014 at 2:19 PM, William Oberman <ob...@civicscience.com>
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
>