Publisher PreviousNext
Data Distribution Service (DDS) Forum > DDS FAQ >
Next message Gurpreet Singh  posted on Thursday, January 14, 2010 - 05:51 pm
Is there is any way that a publisher will know that how many subscriber are subscribing its data at an instance?
Next message Erik Hendriks  posted on Friday, January 15, 2010 - 09:30 am
The main concept behind DDS is to decouple Publishers from Subscribers as much as possible, so most of the time you don't need to know and you don't want to know how many subscribers are subscribed to your data. (Using this knowledge inherently re-intoduces this coupling into your system). A smart networking implementation (one that uses discovery like OpenSplice DDS and probably some others as well) will make sure no samples are transmitted over the network when there is no-one else who is interested in that data: that is normally something that the middleware should solve for you, you don't want to do that kind of optimization in your application code.

But if you really want to know: you can probably look it up using the builtin topics. Each Writer in your Domain is represented by a separate instance of the DCPSPublication topic, and each Reader by an instance of the DCPSSubscription topic. By comparing the DCPSPublication instances with the DCPSSubscription instances you can find out which Readers and Writers are able to communicate: that is the case when they operate on the same topic and have compatible Qos settings. (Be aware: for QosPolicies that are labeled as RxO the rule applies that when the Qos on the Writer is of lesser quality than the Qos on the Reader no communication is established.)

Hope that answers your question.

Erik Hendriks.
Next message Gurpreet Singh  posted on Saturday, January 16, 2010 - 09:09 am
Hi Erik,
Thanx for answering my question. I know a little about the builtin topic and how to read instance from it. Can you please elaborate more on it?
Next message Erik Hendriks  posted on Monday, January 25, 2010 - 10:06 am
Every DomainParticipant you create contains a builtin subscriber, that gives you access to these builtin topics. Simply use the get_builtin_subscriber operation on the DomainParticipant to access its builtin subscriber.

The builtin subscriber contains separate datareaders for each individual builtin topic, which you can access by invoking its lookup_datareader operation, passing the name of the builtin topic you want to read from as its parameter.

The builtin topic reader works like an ordinary DDS datareader, you can either read all builtin topics from it, or use a query to find a particular builtin topic sample.

In the example above, if you are interested in which readers are subscribing to your writer (let's say a writer for topic "Foo"), you would need to look up the reader for the "DCPSSubscription" builtin topic. You can create a query to receive only the readers that subscribe to topic "Foo" by specifyinf an SQL expression like:

topic_name = "Foo"

in this expression, "topic_name" is the field of the DCPSSubscription topic that specifies to which topic a DataReader is subscribed.

Hope that answers your quedtion.

Back to top
Add Your Message Here
Username: Posting Information:
This is a private posting area. Only registered users and moderators may post messages here.
Options: Post as "Anonymous"
Enable HTML code in message
Automatically activate URLs in message