How to check if a Persistence Service is running

5 posts / 0 new
Last post
raz
Offline
Last seen: 4 years 5 months ago
Joined: 04/30/2019
Posts: 7
How to check if a Persistence Service is running

Hello everybody,

I'd like to know if it is possible to check if an instance of Persistence Service is running in order to be sure that my samples are stored correctly in non-volatile memory.

I'd prefere not to use Remote Administration of the service.

 

Thank you in advance and best regards

Offline
Last seen: 4 years 3 weeks ago
Joined: 08/20/2012
Posts: 25

Hello Raz,

I suspect you may benefit from configuring your DataWriter to regard the Persistence Service as a required subscription. Does this look like it might match your use case?

Regards,

Tom

raz
Offline
Last seen: 4 years 5 months ago
Joined: 04/30/2019
Posts: 7

Hi Tom,

thanks for your quick reply.

I don't understand how required subscriptions may solve my problem. What I'm looking for is a way to determine, if a Persistence Service listens to my DataWriter or if no Persistence Service is running at all.

How can I achieve this with required subscriptions?

My first attempt was to use application acknowledgments, but using this code:

void DataWriterListener::on_application_acknowledgment(DDSDataWriter* writer, const DDS_AcknowledgmentInfo & info)
{
    if (info.valid_response_data) {
        ReturnCode_t retcode;        
        ParticipantBuiltinTopicData partData;
        retcode = writer->get_matched_subscription_participant_data(partData, info.subscription_handle);
        printf("### partData: retcode %d, name: %s, roleName: %s ###", 
            retcode, 
            partData.participant_name.name,
            partData.participant_name.role_name);
    }
    else { }
}

 leads to the following error / output:

[D0500|Writer(80000002)|T=ExampleTopic|GET_MATCHED Participant DATA] DDS_DataWriter_get_matched_subscription_participant_data:ERROR: Failed to get discovered_participant_data

### partData: retcode 4, name: , roleName:  ###

 

Does anybody know why get_matched_subscription_participant_data fails with error code 4 (DDS_RETCODE_PRECONDITION_NOT_MET) for acknowledgments sent by a Persistence Service?

The call to get_matched_subscription_participant_data is successful for acknowledgments sent by any other DataReader but fails for a connected Persistence Service.

 

Best regards

fercs77's picture
Offline
Last seen: 1 month 4 weeks ago
Joined: 01/15/2011
Posts: 30

Hi Raz,

You can monitor the DataWriter's PublicationMatchedStatus. When a Persistence Service DataReader is discovered you can get its info by invoking DataWriter::get_matched_subscription_data. Within the SubscriptionBuiltinTopicData there is an enumeration field called service. When the value is DDS_PERSISTENCE_SERVICE_QOS you are macthing with a Persistence Service DataReader.

Regards,

Fernando

raz
Offline
Last seen: 4 years 5 months ago
Joined: 04/30/2019
Posts: 7

Hi Fernando,

thank you very much for your help!

I just implemented your solution and it works like a charm:

void DataWriterListener::on_publication_matched(DDSDataWriter *writer, const PublicationMatchedStatus &status)
{
    SubscriptionBuiltinTopicData subscriptionData;
    ReturnCode_t retcode;

    if (status.current_count_change > 0) {
        retcode = writer->get_matched_subscription_data(subscriptionData, status.last_subscription_handle);

        if (retcode == RETCODE_OK) {
            if (subscriptionData.service.kind == DDS_PERSISTENCE_SERVICE_QOS) {
                // Persistence Service is running
            }
            else { }
        }
        else { }
    }
    else { }
}

 

Best regards,

raz