Storm does this automatically. Take a look at
https://stackoverflow.com/a/51384243/8845188.

The default is a flat wait that just sleeps if nothing is emitted when
nextTuple is called.

If you want to implement your own wait strategy (e.g. a progressive one),
you can implement
https://github.com/apache/storm/blob/v1.2.2/storm-core/src/jvm/org/apache/storm/spout/ISpoutWaitStrategy.java.
You use it in your topology by setting the

topology.spout.wait.strategy to the fully qualified class name
pointing to your implementation.

In Storm 2.0.0 the wait strategy is progressive by default
https://github.com/apache/storm/blob/21bb1388414d373572779289edc785c7e5aa52aa/storm-client/src/jvm/org/apache/storm/policy/WaitStrategyProgressive.java


Den tir. 26. mar. 2019 kl. 13.21 skrev Jayant Sharma <
sharmajayan...@gmail.com>:

> Hi,
>
> We are using *apache storm 1.2.1*. We have spouts which keep polling
> queues which contain input messages for us. My question is, how can I delay
> my nextTuple() calls on the spout thread when there are no input messages
> available in the queue. Does storm provide an exponential backoff mechanism
> for such scenarios? If not, can I implement my own exponential backoff by
> calling org.apache.storm.utils.Utils.sleep() function? I am worried if
> ack() or fail() calls come on the spout thread when it is sleeping, can we
> face some sleep interrupted exceptions?
>
> Thanks,
> Jayant Sharma
>

Reply via email to