1

I am currently using RTI DDS for a pub sub system I am implementing, and for some topics want to keep a history depth of only 1 to keep to be resent if ever needed and for other topics, want to keep all the history to be resent if ever needed. Below is the Qos policy file I am using.

   <?xml version="1.0"?>
    <dds>
        <qos_library name="Keep_History_Library">
            <qos_profile name="Keep_History_profile" is_default_qos="true">

                <datawriter_qos name="ReliableWriter">
                    <property>
                        <value>
                            <element>
                                <name>dds.data_writer.history.memory_manager.fast_pool.pool_buffer_max_size</name>
                                <!-- Typical size of your data type. -->
                                <value>32000</value>
                            </element>  
                        </value>  
                    </property>  
                    <durability>
                        <kind>TRANSIENT_LOCAL_DURABILITY_QOS</kind>
                    </durability>
                    <history><kind>KEEP_LAST_HISTORY_QOS</kind><depth>1</depth></history>
                    <reliability>
                        <kind>RELIABLE_RELIABILITY_QOS</kind>
                    </reliability>
                    <publication_name>
                        <name>HistoryDataWriter</name>
                    </publication_name>
                </datawriter_qos>

                <datareader_qos name="ReliableReader">
                    <history><kind>KEEP_LAST_HISTORY_QOS</kind><depth>1</depth></history>
                    <reliability>
                        <kind>RELIABLE_RELIABILITY_QOS</kind>
                    </reliability>
                    <durability>
                        <kind>TRANSIENT_LOCAL_DURABILITY_QOS</kind>
                    </durability>
                    <subscription_name>
                        <name>HistoryDataReader</name>
                    </subscription_name>
                </datareader_qos>
            </qos_profile>

            <qos_profile name="Keep_All_History_profile">
                <datawriter_qos name="ReliableWriter">
                    <property>
                        <value>
                            <element>
                                <name>dds.data_writer.history.memory_manager.fast_pool.pool_buffer_max_size</name>
                                <!-- Typical size of your data type. -->
                                <value>32000</value>
                            </element>  
                        </value>  
                    </property>  
                    <history><kind>KEEP_ALL_HISTORY_QOS</kind></history>
                    <reliability>
                        <kind>RELIABLE_RELIABILITY_QOS</kind>
                    </reliability>
                    <durability>
                        <kind>TRANSIENT_LOCAL_DURABILITY_QOS</kind>
                    </durability>
                    <publication_name>
                        <name>HistoryDataWriter</name>
                    </publication_name>
                </datawriter_qos>

                <datareader_qos name="ReliableReader">
                    <history><kind>KEEP_ALL_HISTORY_QOS</kind><depth>1000000</depth></history>
                    <reliability>
                        <kind>RELIABLE_RELIABILITY_QOS</kind>
                    </reliability>
                    <durability>
                        <kind>TRANSIENT_LOCAL_DURABILITY_QOS</kind>
                    </durability>
                    <subscription_name>
                        <name>HistoryDataReader</name>
                    </subscription_name>
                </datareader_qos>
            </qos_profile>
        </qos_library>
    </dds>

The following, is the code written in java to load the Keep_All_History_profile from the Qos policy file for the reader.

DataReaderQos datareader_qos = new DataReaderQos();          

DomainParticipantFactory.TheParticipantFactory.get_datareader_qos_from_profile(datareader_qos, "Keep_History_Library", "Keep_All_History_profile");

As well as the code to load the Qos file into the writer

DataWriterQos datawriter_qos = new DataWriterQos();

DomainParticipantFactory.TheParticipantFactory.get_datawriter_qos_from_profile(datawriter_qos, "Keep_History_Library", "Keep_All_History_profile");

However the problem I am having is when I try to load the Keep All History profile, a depth of one is only keep and not anymore. However if I change the keep last history part of the profile to a depth to say a depth of 10 it will keep and read the last 10 messages where the keep all history is supposed to be loaded. Why would this be happening where it appears as though the wrong profile is being loaded?

EDIT

Code used to make the datawriter which is used right after the loading of the Qos profile.

        writer = (DataDataWriter)
                publisher.create_datawriter(
                    topic, Publisher.DATAWRITER_QOS_DEFAULT,
                    null, StatusKind.STATUS_MASK_NONE);
        if (writer == null) {
            System.err.println("create_datawriter error\n");
            return;
        }  

as well as the datareader

       listener = new DataListener();
        reader = (DataDataReader)
        subscriber.create_datareader(
           topic, Subscriber.DATAREADER_QOS_DEFAULT, listener,
           StatusKind.STATUS_MASK_ALL);
        if (reader == null) {
            System.err.println("create_datareader error\n");
            return;
        }
    }

The data reader then sends a message with the following method,

public void writeData(String results) throws InterruptedException
{
        instance.results = results;
        writer.write(instance, handle);
}
jgr208
  • 2,896
  • 9
  • 36
  • 64
  • The KEEP_ALL_HISTORY_QOS does not use the ... element. Please remove that from the Keep_All_History_profile profile. (Also, the Writer's depth in the profile has an extraneous > at the end of the value) – rip... Feb 23 '15 at 21:19
  • and show your work -- how do you go on to use the datareader_qos and datawriter_qos objects in your code? – rip... Feb 23 '15 at 21:20
  • @rip... that is what i thought but then some example out on the web showed a depth to the keep all so i will put it back to what i originally had. i will show how i then create the data reader and writer as well as send the data. – jgr208 Feb 23 '15 at 21:26
  • @rip... a printout of the datawriter_qos in the writer displays the following. history_kind=KEEP_LAST_HISTORY_QOS, history_depth=1 as well as history=HistoryQosPolicy[kind=KEEP_ALL_HISTORY_QOS, depth=1 – jgr208 Feb 23 '15 at 21:36

1 Answers1

3

Why you see what you see:

You are using Subscriber.DATAREADER_QOS_DEFAULT and Publisher.DATAREADER_QOS_DEFAULT, and the 'is_default_qos' boolean is set on the Keep_Last depth 1 profile.

What it is doing under the hood:

When you have is_default_qos flag set on profile "Foo", THAT is the profile that will be used, when you use a *_QOS_DEFAULT flag. Even if you use a Participant profile from some OTHER profile.

The *_QOS_DEFAULT flags will ALWAYS revert to the "is_default_qos" profile.

How to get what you want:

If you want to use Subscriber.DATAREADER_QOS_DEFAULT and Publisher.DATAREADER_QOS_DEFAULT then you have to tell the Subscriber and Publisher objects that they are to use a different default value.

subscriber.set_default_datareader_qos_with_profile(
    "Keep_History_Library", "Keep_All_History_profile");    

publisher.set_default_datareader_qos_with_profile(
    "Keep_History_Library", "Keep_All_History_profile");

OR

use the _create_with_profile variants of the factory calls:

subscriber.create_datareader_with_profile(
    topic, "Keep_History_Library", "Keep_All_History_profile", 
    listener, StatusKind.STATUS_MASK_ALL);

publisher.create_datawriter_with_profile(
    topic, "Keep_History_Library", "Keep_All_History_profile", 
null, StatusKind.STATUS_MASK_NONE);
rip...
  • 996
  • 5
  • 20