How 1 subscriber identify diffrent partition joined.

9 posts / 0 new
Last post
kapilgupta123's picture
Offline
Last seen: 1 year 5 months ago
Joined: 06/18/2022
Posts: 6
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: 4 days 1 hour ago
Joined: 11/29/2012
Posts: 573

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: 1 year 6 months 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: 4 days 1 hour ago
Joined: 11/29/2012
Posts: 573

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);

 

kapilgupta123's picture
Offline
Last seen: 1 year 5 months ago
Joined: 06/18/2022
Posts: 6

Hi Howard,

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

 how to get that topic is disposed  due to writer kill or dispose function
Howard's picture
Offline
Last seen: 4 days 1 hour ago
Joined: 11/29/2012
Posts: 573

First, a Topic (or key of Topic) may not be disposed just because the writer is killed.  It depends on QoS settings like WriterDataLifeCycle.autodispose_unregistered_instances.

But if you want to detect that a writer has called the disposed() API on an instance/Topic, then you need to check for the InstanceState as provided in the SampleInfo structure when your code takes data from the DataReader.

A disposed() call will result in a data sample sent to the DataReader with "invalid" data.  i.e., the user data itself isn't "real"/data actually sent by the user, but the associated SampleInfo does have new information.

In your processing code, after determining that a data sample is "invalid", you can check the sample.info().state().instance_state() and see if the state is equal to non_alive_disposed.

 

kapilgupta123's picture
Offline
Last seen: 1 year 5 months ago
Joined: 06/18/2022
Posts: 6

Thanks Howard 

kapilgupta123's picture
Offline
Last seen: 1 year 5 months ago
Joined: 06/18/2022
Posts: 6

Hi Howard,

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

how to coherent access for subscriber and publisher?
Howard's picture
Offline
Last seen: 4 days 1 hour ago
Joined: 11/29/2012
Posts: 573