Communication between Publisher and Subscriber using different topics

4 posts / 0 new
Last post
Offline
Last seen: 5 years 6 months ago
Joined: 10/12/2018
Posts: 7
Communication between Publisher and Subscriber using different topics

I am currently working on rti dds along with netbeans. There are 2 java applications running, each with a separate set of Publisher and Subscriber files. Publisher and Subcriber of Application 1 use Topic T1 to communicate. Similarly those of Application 2 use Topic T2 to communicate. Now I want to know, is it possible to make communicate Publisher P1 and Subscriber S2 using Topic T2? or P2 and S1 using Topic T1?

Offline
Last seen: 3 months 6 days ago
Joined: 02/11/2016
Posts: 144

Hey,

I'll break down the answer into two parts:

1. One subscriber can have multiple readers attached to it, each reading different topics. (similarly for publishers and writers). That means P1 can have a writer for T2 which should be able to send data to S2 (and more specifically to its reader already working with T2).

2. Assuming T1 and T2 are different (perhaps by type but definitely by name), a writer that sends data on T1 cannot write data on T2 (and a reader receiving data from T1 cannot receive data from T2).

I hope this answers your question,

Roy.

 

Offline
Last seen: 5 years 6 months ago
Joined: 10/12/2018
Posts: 7

Thanks very much for answering. I got the concept behind this.

Can I get a reference of any tutorial or code that explains how to add a data reader with a different topic for a particular subscriber that can read data from publisher apart from the subscriber's already available data reader and its corresponding topic?

As I am unable to figure out the additions to be made in the code for creating a new data reader with a new topic.  

Attached is the screenshot of the java application in which I want to add a new reader for the ''myfileSubscriber.java" as the file name of the subscriber.

Gerardo Pardo's picture
Offline
Last seen: 3 weeks 1 day ago
Joined: 06/02/2010
Posts: 601

If you want to create a second DataReader you just need to create a new Topic ( see DomainParticipant.create_topic()) and then call the Subscriber.create_datareader() to create the new DataReader. Just like you did for the first DataReader...

As far as examples you can take a look at the different ones on the Case+Code.  These are more elaborate examples where a simple application creates multiple DataReader and DataWriter objects.