create_contentfilteredtopic returns nil

5 posts / 0 new
Last post
Offline
Last seen: 7 years 5 months ago
Joined: 03/09/2016
Posts: 6
create_contentfilteredtopic returns nil

SOLVED: See edit at bottom of post


Note: I am using RTI Connext DDS 5.1.0 and C++.

I have decided to rework an existing datareader into a datareader that uses a content filtered topic. The class I have written already has a working participant, DDS topic, subscriber, and data reader. What I am adding is a new content filtered topic, and I am changing the topic of the DataReader to this new CFT. I've followed examples as closely as possible, but I am encountering a nil as the return value for the create_contentfilteredtopic call.

My order of operations when creating the topic entities is as follows (assume the related topic has been created successfully):

  1. Set up filter params. In this case the filter params are two strings. (dds_filter_params)
  2. Initialize the filtered topic name to something unique. (cft_topic_name)
  3. Check if the filtered topic already exists
  4. Create the filtered topic using the participant.

A filter string exists as a const char * called FILTER. It is performing filtering with multiple conditions, which look like "(var1 MATCH %0) OR (var1 MATCH %0 AND var2 MATCH %1) OR (var1 MATCH '' AND var2 MATCH '')". I've tried replacing this filter with an empty string to see if it was my filter causing the null.

this->cft_ = this->participant_->create_contentfilteredtopic(cft_topic_name, related_topic.in(), FILTER, dds_filter_params); 

Given that the cft_topic_name is uniquely generated, the other case for failure is that the related topic isn't registered to the DomainParticipant that I am using. I find this hard to believe since I am adapting code that was working using the related_topic.

Solution: The problem ended up being a malformed query. Due to the way my system's logging is output, the RTIDDS logging that explained this fairly plainly was being cut off. My filter parameters, which are strings, were missing single quotes in my DDS StringSeq. Once I added these in the filter was compiled succesfully, and my topic was created succesfully.

Offline
Last seen: 7 years 5 months ago
Joined: 03/09/2016
Posts: 6

I was able to up the RTIDDS logging a bit and finally get some insight into what is going wrong. It appears that my error lies within the SQL compiler failing to parse one or more of my parameters. The specific error I am encountering is "SQL compiler failed to parse parameter string 'publisher'." Is there something I need to do to enable string matching, or is "<message field name> MATCH %0" where %0 is some string not a valid filter?

jwillemsen's picture
Offline
Last seen: 2 years 10 months ago
Joined: 09/24/2013
Posts: 55

The FILTER string you mention looks strange, especially the last part, is that what you really pass?

Also check the example at https://community.rti.com/examples/content-filtered-topic-string-filter

jwillemsen's picture
Offline
Last seen: 2 years 10 months ago
Joined: 09/24/2013
Posts: 55

Just as note, create_contentfilteredtopic_with_filter is a RTI Connext DDS specific extension which is not (yet) part of the DDS specification.

Offline
Last seen: 7 years 5 months ago
Joined: 03/09/2016
Posts: 6

I have not had a chance to test my filter in action completely, so I am not sure what I have written will work. What I have provided in my post also does not exactly match what my actual filter is. The hope with the empty string match is that it will capture a broadcast from our utility that publishes the message. If the publisher specifies no parameters, then everyone receives the message. If the publisher specifies parameters, then only the subscribers that match those parameters receives the message. I'll have to see if this filter works in practice.