6.1 Content-Filtered Topics Example

A content-filtered topic is a very useful feature if you want to filter data received by the Subscriber. It also helps to control network and CPU usage on the subscriber side because only data that is of interest to the subscriber is sent.

For example, assume your application is a radar monitor that draws flights detected within a 20-mile radius. The application can subscribe to the track data with a content filtered topic for a 20-mile radius on the coordinates of all flights. With the filter, only coordinates that are within the 20-mile radius will be sent to the application.

  1. Start two copies of Shapes Demo, which we will call Publisher1 and Subscriber1. If you are reusing demo windows from a previous section, delete any existing publishers and subscribers (under Controls, click Delete All.)
  2. In Publisher1, create a circle publisher (any color):
    1. Under Publish, click on Circle.
    2. In the Create New Publisher window, click OK.
  3. In Subscriber1, create a circle subscriber with a content filtered topic:
    1. Under Subscribe, click on Circle.
    2. In the Create New Subscriber window:
      • Check Use filter.
      • Click OK.

    You will see a shaded rectangle appear in the subscriber canvas. This is the filter for the coordinates of the Circle topic.

    The subscriber will receive position data for the Circle only when it is with the area defined by the content filter.

  4. To see the effect of dynamic filters, use your mouse to move and resize the shaded area in Subscriber1.