spring-projects / spring-projects/spring-framework

Allow customizing of DefaultSubscriptionRegistry messageEvalContext [SPR-17485]

Open
#22,017 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

in: messaging type: enhancement
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.