Advising Filters

建议 Filter 建议时还需考虑其他事项。默认情况下,任何丢弃操作(当过滤器返回 false 时)都在建议链的范围内执行。这可能包括丢弃通道下游的所有流。因此,例如,如果丢弃通道下游的元素引发异常,并且有重试建议,则会重试该过程。此外,如果将 throwExceptionOnRejection 设置为 true(异常在建议的范围内引发)。

There is an additional consideration when advising Filter advices. By default, any discard actions (when the filter returns false) are performed within the scope of the advice chain. This could include all the flow downstream of the discard channel. So, for example, if an element downstream of the discard channel throws an exception and there is a retry advice, the process is retried. Also, if throwExceptionOnRejection is set to true (the exception is thrown within the scope of the advice).

discard-within-advice 设置为 false 会修改此行为,并且丢弃(或异常)发生在调用建议链之后。

Setting discard-within-advice to false modifies this behavior and the discard (or exception) occurs after the advice chain is called.