Queue Browse with Selector: Problem with some properties

Is it possible to use a property with dashes (hyphens) in the name?

Here is my test: I am sending three batches of message in a queue using sdkperf:

./sdkperf/sdkperf_java.sh -cip=tcp://localhost:9555 -cu=admin@default -cp=admin -pql=“queue-football” -mn=10 -mr=1000 -mt=persistent -md -pal sample-20.json -cpl “String,dd-trace-tag-info,FW5,String,ddTraceTagInfo,FW5” -q
./sdkperf/sdkperf_java.sh -cip=tcp://localhost:9555 -cu=admin@default -cp=admin -pql=“queue-football” -mn=10 -mr=1000 -mt=persistent -md -pal sample-20.json -cpl “String,dd-trace-tag-info,FW6,String,ddTraceTagInfo,FW6” -q
./sdkperf/sdkperf_java.sh -cip=tcp://localhost:9555 -cu=admin@default -cp=admin -pql=“queue-football” -mn=10 -mr=1000 -mt=persistent -md -pal sample-20.json -cpl “String,dd-trace-tag-info,FW7,String,ddTraceTagInfo,FW7” -q

→ port 9555 is my docker exposed SMF port (mapped to 55555 in the docker container)

here are the SQL-92 expression to filter my message using a selector:

ddTraceTagInfo = 'FW6'

→ this is working fine

dd-trace-tag-info = 'FW6'

→ this generates an Exception: com.solacesystems.jcsmp.JCSMPErrorResponseException: 400: Invalid Selector

in standard SQL, I think it is supported as the table field can be wrapped in backticks: `dd-trace-tag-info`

but this is not working in Solace.

Is there another way to escape the dashes/hyphens?

Hi there, I’m Solly AI, I generate responses to your questions using the power of the Solace Agent Mesh:

Please remember that AI technology can make mistakes so ensure that you read our Disclaimer.

AI Generated responses are a work in progress, your help in evaluating my response would be awesome! If my response makes sense, please mark it as a solution or give a :+1:. If my response doesn’t make sense for your topic, please react to it with a :shaking_face:.

Let me analyze the information about SQL-92 selectors in the Solace documentation.

The documentation mentions that selectors use a conditional expression syntax that is a subset of SQL92, but there is no explicit mention of whether dashes/hyphens are allowed in property names. However, looking at the examples and context:

  1. The documentation states that selectors are limited to 2,000 bytes and use SQL92 syntax subset.

  2. In the examples shown, property names are simple identifiers without special characters.

  3. The documentation emphasizes using topic matching instead of selectors for better performance, suggesting that simpler property names would be preferred.

  4. None of the provided examples show properties with dashes in their names.

Since there is no explicit confirmation in the documentation about whether dashes are allowed in property names for SQL-92 selectors, I cannot provide a definitive answer. I recommend:

  1. Using camelCase or underscore_notation for property names to ensure compatibility
  2. Testing any properties with dashes in a non-production environment first
  3. Consulting the Solace documentation for the most up-to-date information on selector syntax and limitations

Relevant documentation:

Hi there @pruffieux. I was interested to test whether this is an SdkPerf thing, or a Solace thing, or a JMS thing. Specifically, seeing if I could get your Selector to work with my own queue browsing tool PrettyDump, which I made to look like SdkPerf dump -md output, but formats JSON and XML and stuff nicer.

Anyway, short answer: I couldn’t. I was getting the same exceptions. So I went digging.

Publishing a message with a specified user property with a hyphen in it works fine:

./sdkperf_java.sh -cip=0 -pql=q1 -mn=1 -msa=16 -cpl='string,aa-bb,test1'

But, couldn’t get the browser selector working. In the JMS 1.1 specification, page 42, Section 3.8.1.1 - Message Selector Syntax, there is the following para:

Identifiers: – An identifier is an unlimited-length character sequence that must begin with a Java identifier start character; all following characters must be Java identifier part characters. An identifier start character is any character for which the method Character.isJavaIdentifierStart returns true. This includes ‘_’ and ‘$’. An identifier part character is any character for which the method Character.isJavaIdentifierPart returns true.

So need to double-check Character.isJavaIdentifierPart().

So I wrote a little Java app to test out the hyphen, b/c it’s been a while since I’ve coded Java and can’t remember if hypthen is allowed in variable names.

	public static void main(String... args) {
		System.out.println(Character.isJavaIdentifierPart('-'));
		System.out.println(Character.isJavaIdentifierPart('_'));
	}

Guess what I got? false and true. So hyphens are illegal as part of Selector identifier names according to the JMS spec. So that’s why it’s not working.

You could use underscores _ instead..?

Hope that helps!

2 Likes

Thanks Aaron,

I also found later on the JMS spec paragraph and as we cannot also create a java variable containing hyphens, it seems logical.

What I am surprised is that you can still publish messages with those properties but cannot use them for filtering later.

I will do as you say: suggest to rename the properties to our client as it seem to be a wider limitation than just Solace.

Well… a user property could get used for other things besides Selectors, I guess? Like, a receiving app might just look at the user props to figure out message contents, format, etc..? Would just be a String then. I guess the Selector processing engine inside brokers compile Selectors into some code, so you’d have to have restrictions on the identifier name.

And yeah, not a Solace limitation… it’s JMS. Meaning any JMS broker/API that doesn’t error on that is out-of-spec..! :nerd_face:

Camel case would also work..? Anyhow, good luck! Thanks for replying.

1 Like