which filter is run first, lower or higher order/priority/ranking number? | Community
Skip to main content
Level 8
Aug 18, 2022 3:52 PM UTC
Solved

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

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).

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
TB3dockAccepted solution
Level 8
Aug 20, 2022 12:54 PM UTC

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.

6 replies

TB3dockAuthorAccepted solution
Level 8
Aug 20, 2022 12:54 PM UTC

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.

Translate
arunpatidar
New Participant
Aug 19, 2022 10:11 AM UTC

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).

Translate
Arun Patidar
TB3dockAuthor
Level 8
Aug 19, 2022 2:26 PM UTC

Unfortunately, this is opposite to what @santoshsai is saying?

Translate
SantoshSai
New Participant
Aug 19, 2022 10:00 AM UTC

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

Translate
Santosh Sai
TB3dockAuthor
Level 8
Aug 19, 2022 2:26 PM UTC

Unfortunately, this is opposite to what @arunpatidar  is saying?

Translate