ADLINK-IST/opensplice

Spurious messages on application close.

Closed this issue · 3 comments

Irgy0 commented

We have a simple setup with two executables running on the same machine and communicating via DDS, both using opensplice. What we are finding is that about 5 seconds after closing the publishing executable, spurious messages appear at the subscriber. These messages appear for each key value that was sent on that topic, and have all other non-key values set to zero. I cannot find any suggestion that this is desirable or intended behaviour. We are running in C++ using the iso cpp 2 interface on Redhat 8. I'm not sure what other information might be relevant.

I assume that those are so-called 'single-process' applications (as federated applications that communicate over shared-memory isn't part of the community release), in which case I suspect that what you're seeing is that the the instance-states (of all instances with related writers of the publishing executable) are being set to NOT_ALIVE_NO_WRITERS after a lease on the liveliness has been lost.
In that case, it's not really 'spurious messages' but rather a spec-compliant behavior w.r.t. an instance-state being set to not-alive after DDS detected there are no (more) alive datawriter-objects writing that instance.
You can also find the related documentation in the ISOCPP2 user-manual (just search for 'not_alive_no_writers')

Dear Irgy0,

As Hans explain, what you observed is required behavior. when data writer(s) are deleted, the DDS administration changes the metadata of all instances with related writers (if there is no sample available in reader queue then dds administration put a dummy sample into the reader queue to intimate the data reader for this instance state changes). In your case, When you close the publisher application, data writers are deleted, dds administration put dummy sample to change the instance state at reader side to NOT_ALIVE_NO_WRITER/NOT_ALIVE_DISPOSED state (depending on your setting for auto_dispose).

To avoid these dummy/ invalid samples you need to check validity of your sample before processing it and use instance_state to ALIVE. The code snipped (from helloworld example) are given below:

        dds::sub::LoanedSamples<HelloWorldData::Msg> samples = dr.take();
        for (dds::sub::LoanedSamples<HelloWorldData::Msg>::const_iterator sample = samples.begin();
             sample < samples.end();
             ++sample)
        {
            **if (sample->info().valid())**
            {
                std::cout << "=== [Subscriber] message received :" << std::endl;
                std::cout << "    userID  : " << sample->data().userID() << std::endl;
                std::cout << "    Message : \"" << sample->data().message() << "\"" << std::endl;
                sampleReceived = true;
            }
        }

With best regards,
Vivek Kumar Pandey
Solutions Architect
Adlink Technology

Irgy0 commented

Hi, thanks so much for the fast and helpful replies. You were entirely right, we weren't checking the "valid" field at all and we clearly should be. I even looked for some sort of validity field but didn't think to check inside "info" (feel silly about that in hindsight).

I'll close this since it's not an actual problem with the opensplice code.