0

I'm using fastrtps (https://github.com/eProsima/Fast-RTPS) C++ DDS implementation to publish and subscribe data, using it's publish/subscribe layer (not lower level reader/writer layer). Fastrtps supports history, meaning subscriber joining after publisher has published some messages should be able to receive those old messages. Documentation quite clearly explains how to configure the history on both publisher and subscriber side, but there is no documentation on how to read actual history messages. I wasn't able to find any clues from header files either.

How can I receive history messages using fastrtps publish/subscribe layer?

Normal fastrtps::SubscriberListener::onNewDataMessage() callback does not seem to work for history, only for new messages (as it's signature suggests). I would have expected something like this:

fastrtps::Subsciber *mySubscriber;
(...)
mySubscriber->getHistory(...);

or perhaps

MySubscriberListerner : public fastrtps::SubscriberListener
{
  (...)
  void onHistoryMessage();  // SubscriberListener callback
}

But can't find anything like this.

jviita
  • 114
  • 2
  • 11

1 Answers1

0

When you set a history on the DataWriter, it holds that many samples that it has sent. When you set a history on the DataReader, it requests that many previously sent samples. Note: The reader requests, the writer offers. If the reader is requesting more, it still only gets what the writer offers. If the reader requests less, it only makes that many available to your application. (said that way because different behaviors may result -- where does the filtering happen? maybe on the writer side, maybe on the reader side. Depends on the implementation).

Now, your writer has HISTORY qos and a certain number of samples that have been held onto. Your reader also has HISTORY qos, and requests a certain number of previously sent samples. There is no difference between a 'historical' sample and a 'now' sample. The samples arrive ... and your application is notified.

Because your reader hadn't seen them before, they are (to your reader) new samples and are reported to you via onNewDataMessage().

There is nothing like "give me the historical samples", because you already got them, when you were notified that samples were available (or polled them, or had a listener, or however).

If you are not seeing historical samples on creation of the DataReader, then you have other QOS disconnects or memory usage issues or ...

DDS is nothing if not configurable, but you really need to understand the nuances.

rip...
  • 996
  • 5
  • 20