-
Notifications
You must be signed in to change notification settings - Fork 38.5k
Support 'selector' header for subscriptions with SimpleBrokerMessageHandler [SPR-12884] #17482
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Rossen Stoyanchev commented The SimpleBrokerMessageHandler filters based on destination prefixes, which comes from the base class AbstractBrokerMessageHandler. Since the SimpleBrokerMessageHandler and the DefaultSubscriptionRegistry use PathMatcher for matching destinations, we could add a |
Rossen Stoyanchev commented We'll give this a try for 4.2. |
Rossen Stoyanchev commented Actually based on another comment you made I'm not sure I fully understood what you meant. I thought that you want to filter all messages coming into the |
Christopher Shannon commented This would apply more for the For this ticket, I thought it might be useful to add the ability to build that behavior into the actual framework generically. So for example, a client might subscribe to a specific destination. But instead of receiving all messages, the client could specify they only want to receive messages based on a property in a header. So maybe they only want to receive messages that contain "age > 100". This behavior is a standard part of JMS and is described here: http://docs.oracle.com/cd/E19798-01/821-1841/bncer/index.html Obviously, this is not JMS, but it would be nice to have a similar feature in that a client could filter out what it receives based on the content of a message. Does that make sense? |
Christopher Shannon commented For more clarification, here is how ActiveMQ Apollo supports message selectors over STOMP. https://activemq.apache.org/apollo/documentation/stomp-manual.html#Message_Selectors You specify a selector as a header. This is why in the other comment I made I wanted to be able to access the headers for a subscription to add in custom filtering logic. |
Rossen Stoyanchev commented Okay thanks. I'll try SpEL expressions and see what that looks like. |
Rossen Stoyanchev commented Christopher Shannon I've added SpEL based selector header support. I think that will work out fine but if you could give it a try, that'd be great. See commit b6327a. |
Christopher Shannon commented Thanks for getting that into the build. I will pull down the latest Snapshot and take a look at it sometime in the next few days to play with some test cases but at first glance it looks good. |
Pavel Muravyov commented Hi everyone, I have just found this Jira request which helped me to finally configure selector on the client. But it takes several hours to make it work. For simple custom message header 'person' of type Long this should be placed as a selector:
Not really straightforward. Is there a more simple way for the same result? |
Christopher Shannon opened SPR-12884 and commented
I am currently using STOMP over Websockets and the Simple message broker to publish messages to clients. In my case, the simple message broker support works great, except the one feature that is missing that would be really useful is message selector support to filter out certain messages sent to clients. I could use a full featured message broker for this feature but a full broker is a bit overkill for what I need.
I suggest adding message selector support to the Simple message broker (or to another internal broker in spring). Instead of having to write custom logic to filter messages, it would be nice to be able to register a selector in a header to filter out messages dynamically.
Adding support for a JMS message selector expression (which is based on a subset of SQL92 conditional syntax) would be great but would probably be difficult and might best suited to leave for a full featured broker.
Something else that might work instead would be to use a syntax based on the Spring Expression Language if there is a good way to implement this in a generic way. This should be a lot more straight forward since SpEL is used elsewhere all over the framework.
Even if SpEL wouldn't work really work, just having basic filtering support on headers by using a syntax such as "someProperty = 'true'" or "someProperty > 10" would be useful.
Affects: 4.1.6
Issue Links:
Referenced from: commits 0b43e4e, b6327ac
The text was updated successfully, but these errors were encountered: