RTI DDS Qos 配置文件历史未按预期工作
RTI DDS Qos profile history not working as expected
我目前正在将 RTI DDS 用于我正在实施的发布子系统,并且对于某些主题,我希望将历史深度保持为 1,以便随时重新发送需要和其他主题,希望保留所有历史记录,以便在需要时重新发送。下面是我正在使用的 Qos policy
文件。
<?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>
以下是在java中编写的代码,用于从Qos policy
文件中为reader加载Keep_All_History_profile
。
DataReaderQos datareader_qos = new DataReaderQos();
DomainParticipantFactory.TheParticipantFactory.get_datareader_qos_from_profile(datareader_qos, "Keep_History_Library", "Keep_All_History_profile");
以及将 Qos
文件加载到编写器中的代码
DataWriterQos datawriter_qos = new DataWriterQos();
DomainParticipantFactory.TheParticipantFactory.get_datawriter_qos_from_profile(datawriter_qos, "Keep_History_Library", "Keep_All_History_profile");
但是我遇到的问题是当我尝试加载 Keep All History profile
时,深度 1 只保留,不再保留。但是,如果我将配置文件的 keep last history
部分更改为深度,即深度为 10,它将保留并读取最后 10 条消息,其中保留所有历史记录应该被加载。为什么会出现这种情况,看起来好像加载了错误的配置文件?
编辑
用于制作数据写入器的代码,在加载 Qos
配置文件后立即使用。
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;
}
以及数据reader
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;
}
}
数据reader然后用下面的方法发送消息,
public void writeData(String results) throws InterruptedException
{
instance.results = results;
writer.write(instance, handle);
}
为什么会看到你所看到的:
您正在使用 Subscriber.DATAREADER_QOS_DEFAULT 和 Publisher.DATAREADER_QOS_DEFAULT,'is_default_qos' 布尔值设置在 Keep_Last 深度 1 配置文件上。
它在幕后做了什么:
当您在个人资料 "Foo" 上设置 is_default_qos 标志时, 是将使用的个人资料,当您使用 *_QOS_DEFAULT 标志。即使您使用来自某些 OTHER 个人资料的参与者个人资料。
*_QOS_DEFAULT 标志将始终 恢复到 "is_default_qos" 配置文件。
如何得到你想要的:
如果您想使用 Subscriber.DATAREADER_QOS_DEFAULT 和 Publisher.DATAREADER_QOS_DEFAULT,那么您必须告诉订阅者和发布者对象它们将使用不同的默认值。
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);
我目前正在将 RTI DDS 用于我正在实施的发布子系统,并且对于某些主题,我希望将历史深度保持为 1,以便随时重新发送需要和其他主题,希望保留所有历史记录,以便在需要时重新发送。下面是我正在使用的 Qos policy
文件。
<?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>
以下是在java中编写的代码,用于从Qos policy
文件中为reader加载Keep_All_History_profile
。
DataReaderQos datareader_qos = new DataReaderQos();
DomainParticipantFactory.TheParticipantFactory.get_datareader_qos_from_profile(datareader_qos, "Keep_History_Library", "Keep_All_History_profile");
以及将 Qos
文件加载到编写器中的代码
DataWriterQos datawriter_qos = new DataWriterQos();
DomainParticipantFactory.TheParticipantFactory.get_datawriter_qos_from_profile(datawriter_qos, "Keep_History_Library", "Keep_All_History_profile");
但是我遇到的问题是当我尝试加载 Keep All History profile
时,深度 1 只保留,不再保留。但是,如果我将配置文件的 keep last history
部分更改为深度,即深度为 10,它将保留并读取最后 10 条消息,其中保留所有历史记录应该被加载。为什么会出现这种情况,看起来好像加载了错误的配置文件?
编辑
用于制作数据写入器的代码,在加载 Qos
配置文件后立即使用。
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;
}
以及数据reader
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;
}
}
数据reader然后用下面的方法发送消息,
public void writeData(String results) throws InterruptedException
{
instance.results = results;
writer.write(instance, handle);
}
为什么会看到你所看到的:
您正在使用 Subscriber.DATAREADER_QOS_DEFAULT 和 Publisher.DATAREADER_QOS_DEFAULT,'is_default_qos' 布尔值设置在 Keep_Last 深度 1 配置文件上。
它在幕后做了什么:
当您在个人资料 "Foo" 上设置 is_default_qos 标志时, 是将使用的个人资料,当您使用 *_QOS_DEFAULT 标志。即使您使用来自某些 OTHER 个人资料的参与者个人资料。
*_QOS_DEFAULT 标志将始终 恢复到 "is_default_qos" 配置文件。
如何得到你想要的:
如果您想使用 Subscriber.DATAREADER_QOS_DEFAULT 和 Publisher.DATAREADER_QOS_DEFAULT,那么您必须告诉订阅者和发布者对象它们将使用不同的默认值。
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);