Solace PubSub+ Connector Consume "Selector" Feature

Hi

I’m trying to use the solace “consume” operation and attempting to use the “selector” to only consume a subset of messages.

When publishing a message I have passed in a userProperties: (refer to attachment publish.png)

counter: 1

As per this link - PubSub+ Messaging API Developer Guide, it should be possible to limit what messages are consumed.

As per the attachment (consume.png), I have configured the “selector” feature of the consume operation.

However, I’m not receiving any messages.

Does anyone have an example or documentation on this feature?

Thank you


I assume you are using Mule JMS to connect to Solace. In that case, the Selector needs to be a standard JMS selector string.

The three characters # converted the whole thing into a Mule Expression Language. In your example, you don’t need the complexity of Mule Expression. So you should uncheck the “fx” button there, and simply use this string:

counter=1

In case that JMS header is not numberic then you should try:

counter='abc'

For more information regarding the selector syntax:

actually it looks like @etc is using the Solace PubSub+ connector for MuleSoft. But the answer @ivan_lkc provides should still work. As said, no need for a Mule expression, just a simple string of counter=1 should work. Under the covers, the connector will use JCSMP to do a ConsumerFlowProperties.setSelector() with the string you put in the property page field for Selector.

Hi

@ivan_lkc and @amackenzie

I am using the Solace PubSub+ connector for MuleSoft that use JCSMP.

Just for clarification, attributes.userProperties.counter is a dataweave expression and not MEL. It’s used to retrieve header attributes.

Just for reference, I have attached Consumer_NoSelector.PNG to show the counter=1 property being set.

However in the connector when I set the selector to counter=1 (as a string only and not as a dataweave expression), I also get null result. (Attached solaceconnector.log and Consumer_WithSelector.PNG)

To sum up I have tried the following:

  1. dataweave expression: attributes.attributes.userProperties.counter == 1
  2. plain string: counter=1

Both return null result.

Thanks for your help



solaceconnector.log (5.07 MB)

Hi @etc , from the NoSelector screen capture, it seems “counter” is a String which equals “1”; It is not an Integer. Please try to replace selector string from
counter=1
to
counter='1'

And see if that worked.

Hi @ivan_lkc

Thank you for the suggestion.

After some testing, I discovered the following:

Setting userProperties via the Publish Operation

  1. setting integer is not possible - its is always interpreted as a string
  2. Double quotes (“”) are interpreted as a literal text

(refer to UserPropertiesSetGui.PNG and UserPropertiesSetXML.PNG) eg counter

Setting selector via the Consume Operation

  1. only supports single quotes (‘’). eg counter=‘1’
  2. Double quotes (“”) eg counter=“1” will result in an exception - “Invalid Selector”

I personally think there is a defect if only single quotes are supported.

Thank you for your help.