ContentFilterTopic compile error

3 posts / 0 new
Last post
Offline
Last seen: 9 years 12 months ago
Joined: 07/29/2013
Posts: 7
ContentFilterTopic compile error

Hello,

I have a problem that is driving me absolutely nuts because I can't figure out what I'm doing wrong when trying to create a content filter topic. I have attached my IDL and java code.

This is the error I get:

Exception in thread "main" java.lang.Exception: Unable to create confent filtered topic
    at ContentFilterTest.ContentFilterTopic.main(ContentFilterTopic.java:93)
[D0000|CREATE CFTopic|T=messageTopic_FILTER]PRESParticipant_createContentFilteredTopic:content filter compile error 1
[D0000|CREATE CFTopic|T=messageTopic_FILTER]DDS_ContentFilteredTopic_createI:!create DDS_ContentFilteredTopic
[D0000|CREATE CFTopic|T=messageTopic_FILTER]DDS_DomainParticipant_create_contentfilteredtopic_with_filter:!create content filtered topic


Essentially what I'm trying to do is filter topics based on a UUID represented by an array of 16 octets. The documentation mentioned that I can use &hex() but I can't get that to work. I ended up having to manually type them out and got it to "work" when I used another method to add the byte values to the parameter list (DatatypeConvert.printByte(byte val)). However, even when it compiled I could not get it to receive any data from another sender using the same UUID. I am really hoping I am just overlooking something in my code.

Any help would be appreciated.

AttachmentSize
Binary Data octetfilter.idl177 bytes
File contentfiltertopic.java3.61 KB
Offline
Last seen: 5 years 8 months ago
Joined: 01/31/2011
Posts: 37

Hi shez23,

You can't use parameters with the &hex() shorthand, so what you're trying to do won't work in the first case.

In the second case, where you specify the value for each byte in the filter expression, you're not setting up the filter parameters correctly.  The code should be:

for (int i = 0; i < 16; i++)
 {
     params.add(String.format("0x%X", (byte) i));
 }

Note the missing single quote, which you had in your code. And note the "0x"; if using a hex value, it needs to have the 0x.

A third alternative for you: in the newest release (Connext 5.1.0), we support the ability to change the filter expression - not just the parameters. So you can do something like:

// note no parameters in the filter expression
String filterExpression = "producer_id = &hex( 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f )";
...// do some work ....
//change filter expression
cft.set_expression("producer_id = &hex( 0f 0e 0d 0c 0b 0a 09 08 07 06 05 04 03 02 01 00 )", emptyParamSeq);

 -sumeet

Offline
Last seen: 9 years 12 months ago
Joined: 07/29/2013
Posts: 7

Thanks Sumeet, that did the trick.