spring-projects / spring-projects/spring-framework
Allow customizing of DefaultSubscriptionRegistry messageEvalContext [SPR-17485]
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 60.2k
- Forks
- 38.8k
- Avg merge
- 5d 2h
- Merged PRs (30d)
- 27
Description
David Melia opened SPR-17485 and commented
Hi,
org.springframework.messaging.simp.broker.DefaultSubscriptionRegistry contains
private static EvaluationContext messageEvalContext =
SimpleEvaluationContext.forPropertyAccessors(new SimpMessageHeaderPropertyAccessor()).build();
but with no way to override it.
If you think about a stock broking site contain 1000s of price updates I need the ability to add a selector header to filter only the stocks that the customer is interested in. To do that using the default cut down EvaluationContext the selector would be very clunky.
If I can add my own function to the evaluation context i.e
messageEvalContext.setVariable("myCustomStockSymbolFilterFunction" . . .
then the selector would be simplified i.e.
#myCustomStockSymbolFilterFunction(headers['simpDestination'],{'MSFT','BARC'})
Therefore:
-
Could you add the ability to override the EvaluationContext?
-
If so would it be possible to make SimpMessageHeaderPropertyAccessor available somehow?
Thanks
Affects: 5.1.2
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with org.springframework.messaging.simp.broker.DefaultSubscriptionRegistry and inspect how its messageEvalContext is used for selector evaluation. Review SimpMessageHeaderPropertyAccessor and determine the supported customization boundary. Done means the EvaluationContext can be overridden and the accessor can be used for custom selector functions.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100