RTI Connext Java API  Version 6.0.0
 All Classes Namespaces Functions Variables Groups Pages
Topic Queries

com.rti.dds.subscription.TopicQuery and associated elements. More...

Classes

interface  TopicQuery
 <<extension>> Allows a com.rti.dds.subscription.DataReader to query the sample cache of its matching com.rti.dds.publication.DataWriter. More...
 
class  TopicQueryData
 <<extension>> Provides information about a com.rti.dds.subscription.TopicQuery More...
 
class  TopicQueryHelper
 Helpers to provide utility operations related to com.rti.dds.subscription.TopicQuery. More...
 
class  TopicQuerySelection
 <<extension>> Specifies the data query that defines a com.rti.dds.subscription.TopicQuery More...
 
class  TopicQuerySelectionKind
 Kinds of TopicQuerySelection. More...
 

Variables

static final TopicQuerySelection TOPIC_QUERY_SELECTION_USE_READER_CONTENT_FILTER
 Special value for creating a com.rti.dds.subscription.TopicQuery that applies the same filter as the DataReader's com.rti.dds.topic.ContentFilteredTopic.
 
static final TopicQuerySelection TOPIC_QUERY_SELECTION_SELECT_ALL
 Special value for creating a com.rti.dds.subscription.TopicQuery that selects all the samples in a com.rti.dds.publication.DataWriter cache.
 

Detailed Description

com.rti.dds.subscription.TopicQuery and associated elements.

TopicQueries allow a com.rti.dds.subscription.DataReader to query the sample cache of its matching com.rti.dds.publication.DataWriter. A user can create a com.rti.dds.subscription.TopicQuery with the com.rti.dds.subscription.DataReader.create_topic_query API. When a DataReader creates a TopicQuery, DDS will propagate it to other DomainParticipants and their DataWriters. When a DataWriter matching with the DataReader that created the TopicQuery receives it, it will send the cached samples that pass the TopicQuery's filter.

To configure how to dispatch a TopicQuery, the com.rti.dds.publication.DataWriterQos includes the com.rti.dds.infrastructure.TopicQueryDispatchQosPolicy policy. By default, a DataWriter ignores TopicQueries unless they are explicitly enabled using this policy.

The delivery of TopicQuery samples occurs in a separate RTPS channel. This allows DataReaders to receive TopicQuery samples and live samples in parallel. This is a key difference with respect to the Durability QoS policy.

Late-joining DataWriters will also discover existing TopicQueries. To delete a TopicQuery you must use com.rti.dds.subscription.DataReader.delete_topic_query.

After deleting a TopicQuery, new DataWriters won't discover it and existing DataWriters currently publishing cached samples may stop before delivering all of them.

By default, a TopicQuery queries the samples that were in the DataWriter cache at the time the DataWriter receives the TopicQuery. However a TopicQuery can be created in a "continuous" mode. A DataWriter will continue delivering samples that pass a continuous TopicQuery filter until the DataReader application explicitly deletes it.

The samples received in response to a TopicQuery are stored in the associated DataReader's cache. Any of the read/take operations can retrieve TopicQuery samples. The field com.rti.dds.subscription.SampleInfo.topic_query_guid associates each sample to its TopicQuery. If the read sample is not in response to a TopicQuery then this field will be com.rti.dds.infrastructure.GUID_t.GUID_UNKNOWN. Note that the same data may be received several times, depending on how many TopicQueries the DataReader creates and their TopicQuerySelection.

You can choose to read or take only TopicQuery samples, only live samples, or both. To support this ReadConditions and QueryConditions provide the com.rti.dds.subscription.DataReader.create_querycondition_w_params and com.rti.dds.subscription.DataReader.create_readcondition_w_params APIs.

Each TopicQuery is identified by a GUID that can be accessed using the com.rti.dds.subscription.TopicQuery.get_guid method.

Debugging Topic Queries

There are a number of ways in which to gain more insight into what is happening in an application that is creating Topic Queries.

The Built-in ServiceRequest DataReader

TopicQueries are communicated to publishing applications through a built-in com.rti.dds.topic.builtin.ServiceRequest channel. The ServiceRequest channel is designed to be generic so that it can be used for many different purposes, one of which is TopicQueries.

When a DataReader creates a TopicQuery, a com.rti.dds.topic.builtin.ServiceRequest message is sent containing the TopicQuery information. Just as there are built-in DataReaders for com.rti.dds.domain.builtin.ParticipantBuiltinTopicData, com.rti.dds.subscription.builtin.SubscriptionBuiltinTopicData, and com.rti.dds.publication.builtin.PublicationBuiltinTopicData, there is a fourth built-in DataReader for ServiceRequests.

The new built-in DataReader can be retrieved using the built-in subscriber and com.rti.dds.subscription.Subscriber.lookup_datareader. The topic name is com.rti.dds.topic.builtin.ServiceRequestTypeSupport.SERVICE_REQUEST_TOPIC_NAME. Installing a listener with the com.rti.dds.subscription.DataReaderListener.on_data_available callback implemented will allow a publishing application to be notified whenever a TopicQuery has been received from a subscribing application.

The builtin.ServiceRequest.service_id of a com.rti.dds.topic.builtin.ServiceRequest corresponding to a com.rti.dds.subscription.TopicQuery will be com.rti.dds.topic.builtin.ServiceRequest.TOPIC_QUERY_SERVICE_ID and the builtin.ServiceRequest.instance_id will be equal to the GUID of the com.rti.dds.subscription.TopicQuery (see com.rti.dds.subscription.TopicQuery.get_guid).

The builtin.ServiceRequest.request_body is a sequence of bytes containing more information about the TopcQuery. This information can be retrieved using the com.rti.dds.subscription.TopicQueryHelper.topic_query_data_from_service_request function. The resulting com.rti.dds.subscription.TopicQueryData contains the com.rti.dds.subscription.TopicQuerySelection that the com.rti.dds.subscription.TopicQuery was created with, the GUID of the original DataReader that created the TopicQuery, and the topic name of that DataReader. Note: When TopicQueries are propagated through one or more Routing Services, the last DataReader that issued the TopicQuery will be a Routing Service DataReader. The com.rti.dds.subscription.TopicQueryData.original_related_reader_guid, however, will be that of the first DataReader to have created the TopicQuery.

The on_service_request_accepted DataWriter Listener Callback

It is possible that a com.rti.dds.topic.builtin.ServiceRequest for a com.rti.dds.subscription.TopicQuery is received but is not immediately dispatched to a DataWriter. This can happen, for example, if a DataWriter was not matching with a DataReader at the time that the TopicQuery was received by the publishing application. The com.rti.dds.publication.DataWriterListener.on_service_request_accepted callback notifies a DataWriter when a ServiceRequest has been dispatched to that DataWriter. The com.rti.dds.publication.ServiceRequestAcceptedStatus provides information about how many ServiceRequests have been accepted by the DataWriter since the last time that the status was read. The status also includes the com.rti.dds.publication.ServiceRequestAcceptedStatus.last_request_handle, which is the com.rti.dds.infrastructure.InstanceHandle_t of the last ServiceRequest that was accepted. This instance handle can be used to read samples per instance from the built-in ServiceRequest DataReader and correlate which ServiceRequests have been dispatched to which DataWriters.

Reading TopicQuery Samples

Data samples that are received by a DataReader in response to a TopicQuery can be identified with two pieces of information from the corresponding com.rti.dds.subscription.SampleInfo to the sample. First, if the com.rti.dds.subscription.SampleInfo.topic_query_guid is not equal to com.rti.dds.infrastructure.GUID_t.GUID_UNKNOWN then the sample is in response to the TopicQuery with that GUID (see com.rti.dds.subscription.TopicQuery.get_guid). Second, if the sample is in response to a TopicQuery and the com.rti.dds.subscription.SampleInfo.flag com.rti.dds.infrastructure.SampleFlagBits.INTERMEDIATE_TOPIC_QUERY_SAMPLE flag is set then this is not the last sample in response to the TopicQuery for a DataWriter identified by com.rti.dds.subscription.SampleInfo.original_publication_virtual_guid. If that flag is not set then there will be no more samples corresponding to that TopicQuery coming from the DataWriter.

Variable Documentation

final TopicQuerySelection TOPIC_QUERY_SELECTION_USE_READER_CONTENT_FILTER
static
final TopicQuerySelection TOPIC_QUERY_SELECTION_SELECT_ALL
static

Special value for creating a com.rti.dds.subscription.TopicQuery that selects all the samples in a com.rti.dds.publication.DataWriter cache.


RTI Connext Java API Version 6.0.0 Copyright © Sun Mar 3 2019 Real-Time Innovations, Inc