How 1 subscriber identify diffrent partition joined.

4 posts / 0 new
Last post
kapilgupta123's picture
Offline
Last seen: 2 months 17 hours ago
Joined: 06/18/2022
Posts: 3
How 1 subscriber identify diffrent partition joined.

Hi,

Iin my application, I have one subscriber and I have attached one datareader to it. I have attached multiple partitions to this subscriber.

The topic data corresponding to this data reader can be sent by multiple applications in different partitions.

Is it possible to know which of the partition of my subscriber has recieved the data from the instance i have recieved ?

I do not want to have more than one subscriber.

thanks & regards

Kapil

Howard's picture
Offline
Last seen: 7 hours 28 min ago
Joined: 11/29/2012
Posts: 447

Hi Kapil,

In the SampleInfo structure that comes with a Data sample, there is a publication_handle that you can use to get the matched_publication_data, from which you can get the partition to which the DataWriter belongs.

Offline
Last seen: 3 weeks 4 days ago
Joined: 09/13/2015
Posts: 3

Hi Howard,

I am using the RTI DDS 6.1 and its modern c++ api.

when I get samples, i iterate through them to get each sample and then as you answered I tried following 3 code segments, but none of them provides the matched_publication_data or the partition to which the DataWriter belongs.

Could you please look into it to provide me a solution:

dds::sub::LoanedSamples<T> samples {data_reader->take()};
for(auto sample : samples)
{
	auto t = sample.info().instance_handle()
}

dds::sub::LoanedSamples<T> samples {data_reader->take()};
for(auto sample : samples)
{
	auto t = sample.info().publication_handle()	
}
dds::sub::LoanedSamples<T> samples {data_reader->take()};
for(auto sample : samples)
{
	auto t = sample.info()->related_subscription_guid()
}
Howard's picture
Offline
Last seen: 7 hours 28 min ago
Joined: 11/29/2012
Posts: 447

Hi, I noticed that the hyperlinks in my last post were wrong (to my local installation directory).  I've updated them to point at web-accessible URLs.

You need to use

auto publication_handle = sample.info().publication_handle();

and then

auto publication_matched_data = dds::sub::matched_publication_data(data_reader, publication_handle);