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);
}
4

1 回答 1

3

为什么你看到你所看到的:

您正在使用 Subscriber.DATAREADER_QOS_DEFAULT 和 Publisher.DATAREADER_QOS_DEFAULT,并且在 Keep_Last 深度 1 配置文件中设置了“is_default_qos”布尔值。

它在幕后做了什么:

当您在配置文件“Foo”上设置了 is_default_qos 标志时,当您使用 * _QOS_DEFAULT标志时,这就是将使用的配置文件。即使您使用来自其他个人资料的参与者个人资料。

*_QOS_DEFAULT 标志将始终恢复为“is_default_qos”配置文件。

如何得到你想要的:

如果您想使用 Subscriber.DATAREADER_QOS_DEFAULT 和 Publisher.DATAREADER_QOS_DEFAULT,那么您必须告诉 Subscriber 和 Publisher 对象它们将使用不同的默认值。

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");

或者

使用工厂调用的 _create_with_profile 变体:

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);
于 2015-02-23T22:52:34.037 回答