0

I would like to understand why OpenDDS resends the same last data n times (where n is the number of messages already sent) when a DataWriter is deleted ?

Is that the effect of a specific QoS I have missed ?

An output of a little test I have made :

Received data ! ID = 0 Text = Hello world !
Received data ! ID = 1 Text = Hello world !
Received data ! ID = 2 Text = Hello world !
Received data ! ID = 3 Text = Hello world !
Received data ! ID = 4 Text = Hello world !
Received data ! ID = 5 Text = Hello world !
Received data ! ID = 6 Text = Hello world !
Received data ! ID = 7 Text = Hello world !
Received data ! ID = 8 Text = Hello world !
Received data ! ID = 9 Text = Hello world !
Received data ! ID = 9 Text = Hello world !
Received data ! ID = 9 Text = Hello world !
Received data ! ID = 9 Text = Hello world !
Received data ! ID = 9 Text = Hello world !
Received data ! ID = 9 Text = Hello world !
Received data ! ID = 9 Text = Hello world !
Received data ! ID = 9 Text = Hello world !
Received data ! ID = 9 Text = Hello world !
Received data ! ID = 9 Text = Hello world !
Received data ! ID = 9 Text = Hello world !

We see clearly in that example 10 messages were sent and received by the DataReader. Then, once the DataWriter has been deleted (or during the deletion ?), appears 10 repetitions of the last message received.

MSch8791
  • 41
  • 6
  • Did you check the `valid_data` flag on the `SampleInfo` before printing the sample contents? – Reinier Torenbeek Jan 12 '17 at 03:23
  • In fact I didn't check this flag. Enabling this verification in my code I have been able to filter it, thanks. However I have found the answer to my entire question on internet... – MSch8791 Jan 13 '17 at 12:39

2 Answers2

0

Searching on the web, I have found the answer to my own question :

In fact, there were no data inside the DataSample. The valid_data flag is useful to identify if the DataSample has data or not.

These empty DataSample symbolized notifications of changes of states internally in OpenDDS when the DataWriter went off. They should not be read but just be considered as notifications.

MSch8791
  • 41
  • 6
0

Although I have no experience with OpenDDS specifically, I would like to expand on your own answer, which does not seem entirely correct to me. I base this on mechanisms described in the DDS specification.

These empty DataSample symbolized notifications of changes of states internally in OpenDDS when the DataWriter went off.

According to the DDS specification, destruction of a DataWriter results in the unregistering of all its instances. That unregistering implies a state change of the instances from ALIVE to NOT_ALIVE. These state changes are not "internal" like you wrote, but intended to be visible for anybody who is interested. Subscribing applications can be made aware of this by inspecting the instance_state field in the SampleInfo structure.

In your case, you wrote 10 instances (key values) so the destruction of the DataWriter resulted in 10 updates, each indication a change to the state of the previously published instances.

They should not be read but just be considered as notifications.

Since these updates indicate changes to the state of the instances only, the valid_data flag is cleared and indeed, their data fields should not be read. However, it is still possible to determine which instance the update is about, by invoking get_key_value() on the DataReader in question, and passing it the InstanceHandle_t found in the field instance_handle of the SampleInfo struct. If you did that, then you would notice that there would be a notification for every ID from 0 to 9 in your case.

Reinier Torenbeek
  • 16,669
  • 7
  • 46
  • 69
  • Thanks for your answer, it indeed extends the information I got on the internet and documentations. – MSch8791 Jan 15 '17 at 19:13