Ordering Advices within Advice Chain

建议类是“around”建议,并以嵌套方式使用。第一个建议是最外的,而最后一个建议是最内的(也就是说,最接近被建议的处理程序)。将建议类按正确顺序放置很重要,以实现所需的函数性。

Advice classes are “around” advices and are applied in a nested fashion. The first advice is the outermost, while the last advice is the innermost (that is, closest to the handler being advised). It is important to put the advice classes in the correct order to achieve the functionality you desire.

例如,假设您想要添加重试建议和事务建议。您可能想首先放置重试建议,然后是事务建议。因此,每项重试都在新事务中执行。另一方面,如果您希望所有尝试和任何恢复操作(在重试 RecoveryCallback 中)在事务中进行范围限定,则可以首先放置事务建议。

For example, suppose you want to add a retry advice and a transaction advice. You may want to place the retry advice first, followed by the transaction advice. Consequently, each retry is performed in a new transaction. On the other hand, if you want all the attempts and any recovery operations (in the retry RecoveryCallback) to be scoped within the transaction, you could put the transaction advice first.