🎄 Happy Holidays! 🥳
Most of Solace is closed December 24–January 1 so our employees can spend time with their families. We will re-open Thursday, January 2, 2024. Please expect slower response times during this period and open a support ticket for anything needing immediate assistance.
Happy Holidays!
Please note: most of Solace is closed December 25–January 2, and will re-open Tuesday, January 3, 2023.
jmsListener selector mechanism for new solace bee's :)
while consuming solace messages with selector functionality from message header property, do not include any special characters in header key..
if in case if you are adding key with special character you may able to successfully send messages but while retrieving from queue/topic using jmsListener you may end-up with 400-Unresolved selector error.
eg:-
will not work because of '_' char:
selector = "custom_routing_header='${solace.jms.singletonconsumerservice.message.custom.header.value}'",
instead use
selector = "customroutingheader='${solace.jms.singletonconsumerservice.message.custom.header.value}'",
Comments
-
Hey @maniv, thanks for that tip!
To get the best performance out of PubSub+, it's best not to use selectors. They are an (effectively) unbounded compute problem. We have found that in the vast majority of cases, PubSub+'s dynamic, hierarchical topic structure can achieve the same filtering, simply put the header key in the topic:
message/topic/100/apples/food
header key number = 100
header key fruit = apples
header key type = foodNow to select all apples I just subscribe to:
message/topic//apples/To get all food when the number is between 110 and 119, I do:
message/topic/11//food.To get all pears between 200 and 299 and 358 and 369, use multiple subscriptions:
message/topic/2/pears/
mesage/topic/358/pears/*
mesage/topic/358/pears/*
mesage/topic/36/pears/This means I can have multiple keys (up to 125!).
This only really breaks down when you need a complicated range
3 -
Hi @maniv . I know this is an old post, but I stumbled on it, and was wondering about it. You said that if you used the underscore
_
character in the Selector identifier name, you received errors? I just tried that now using JCSMP and (Solace) JMS and it seemed to work fine. Can you confirm? Thanks!0 -
Hi @TomF ,
I'm trying to route messages in Camel. We consume messages from queues. I've found that I'm able to get the topic from the JmsDestination object.Is it possible to somehow set the topic pattern on the JMS uri ?
Example of a queue consumer:
<from uri="solace:queue:…ACKNOWLEDGEMENT/1.0/ACK/…/IN"/>
The consumer receives topics in JmsDestination that have filtering keys in.I was thinking something like this could be done:
<from uri="solace:queue:…ACKNOWLEDGEMENT/1.0/ACK/…/IN?topic=/my/favourite/*"/>
This the consumer would consume only messages based on the pattern provided in the topic parameter.
Thank you0 -
Hi RadovanB,
I'm not a Camel expert, so I'll leave that part of the question to someone who knows more about that.
However, I would say that you're going about things in an odd way. The broker does topic routing for you, so use that rather than Camel.
What I mean by that is that rather than having a queue attract a range of topics and then have Camel route them, create queues with topic subscriptions to only the topics of interest. That way you won't need to know what the topic is in Camel, because you'll know that only those messages will be received from that queue.
0 -
I understand your point. Unfortunately I'm not in power to change anything in the Solace. I'm in the position of a consumer.
Is there a possibility to setup a selector based on the topic name? I'm trying to figure how to setup multiple consumers on a one queue with different selectors. Otherwise I have to do the routing of messages in Camel. I try to avoid it as I have to resent messages based on the topic.
Thank you,
Radovan0 -
Ah. That's a tricky problem to solve. You can use selectors on header properties:
"Any headers except JMSDestination, JMSExpiration and JMSReplyTo" according to https://timjansen.github.io/jarfiller/guide/jms/selectors.xhtml.So unfortunately, you can't use a selector on your destination/topic.
0 -
https://docs.solace.com/API/API-Developer-Guide/Using-Selectors.htm
Yup, unfortunately. But if the publisher could echo the topic into a User Property, then you'd be good to go.
But that's not the best approach… what Tom said, let broker handle routing. Call your Solace admins and plead your case! 😅🙏🏼
1