Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

which filter is run first, lower or higher order/priority/ranking number?

Avatar

Level 8

you can specify the "ranking", "prioritisation" or "order" (called different things in different places) using this:

@ServiceRanking(-200)

 

The give the following situation:

 

600 : class com.day.cq.wcm.foundation.forms.impl.FormsHandlingServlet (id: 2255, property: service.ranking=600); called: 23; time: 97ms; time/call: 4217µs
0 : class com.adobe.aem.graphql.sites.ui.admin.impl.FeatureToggleFilter (id: 1373, property: none); called: 0; time: 122ms; time/call: -1µs

 

which is run first, the filter with 600, or the one with zero as the raking order?

 

so does 

 

a) FormsHandlingServlet fitler call FeatureToggleFilter

  or

b) FeatureToggleFilter call FormsHandlingServlet

 

 

The documentation says:

 

Filter ordering is defined by the filter.order property whose default value is Integer.MAX_VALUE where smaller values have higher priority over higher values.

 

This would imply  b), but most people think its a).

1 Accepted Solution

Avatar

Correct answer by
Level 8

Due to conflicting documentation, I added debug statements to see what was happening.  the answer is in fact a), so it appears that @SantoshSai could be wrong, and @arunpatidar could be right, at least for the current AEM cloud local dev environment.

View solution in original post

0 Replies

Avatar

Community Advisor

Hi @TB3dock ,

They invoked in order of their service ranking, that is lowest to highest. service ranking status can be found here: https://sling.apache.org/documentation/bundles/models.html#available-injectors 

Hope that helps!

Regards,

Santosh

Avatar

Community Advisor

Please check

service.ranking Integer 0 Any Integer value Indication of where to place the filter in the filter chain. The higher the number the earlier in the filter chain. This value may span the whole range of integer values. Two filters with equal service.ranking property value (explicitly set or default value of zero) will be ordered according to their service.id service property as described in section 5.2.5, Service Properties, of the OSGi Core Specification R 4.2.

 

Please note that the ordering is actually depending on the used Apache Sling Engine bundle version. Version older than 2.3.4 of that bundle are sorting the filters in the wrong reverse order. Make sure to run a newer version of the Sling engine to get the correct ordering (see also SLING-2920).

Avatar

Level 8

FYI, we are using cloud AEM, so presumably we dont have any say in which sling version is used.

Avatar

Correct answer by
Level 8

Due to conflicting documentation, I added debug statements to see what was happening.  the answer is in fact a), so it appears that @SantoshSai could be wrong, and @arunpatidar could be right, at least for the current AEM cloud local dev environment.