RTI Connext Modern C++ API  Version 6.0.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Request-Reply Examples

Examples on how to use the request-reply API. More...

Examples on how to use the request-reply API.

Request-Reply code examples.

Request-Reply Examples

DDS Types

RTI Connext uses DDS data types for sending and receiving requests and replies. Valid types are those generated by the rtiddsgen code generator, the DDS built-in types, and DynamicData. Refer to the User's Manual and the following links for more information:

Set up

Requester: sending requests and receiving replies

Replier: receiving requests and sending replies

Requester Creation

Creating a Requester with optional parameters

Basic Requester example

Correlating requests and replies

Creating a Replier

Basic Replier example

SimpleReplier example

using namespace rti::request;
participant,
"TestService",
[](const Foo& request)
{
return Bar(std::string("Simple reply for ") + request.message());
}
);
// After creation the SimpleReplier is already active and the functor will
// be called upon receiving a request.
See Also
Basic Requester example

Configuring Request-Reply QoS profiles

If you do not specify your own QoS parameters (in RequesterParams and ReplierParams), a rti::request::Requester and rti::request::Replier are created using a default configuration. That configuration is equivalent to the one in the following QoS profile called "default":

<?xml version="1.0"?>
<!--
Description
XML QoS Profile for ExampleRequest
The QoS configuration of the DDS entities in the generated example is loaded
from this file.
This file is used only when it is in the current working directory or when the
environment variable NDDS_QOS_PROFILES is defined and points to this file.
The profile in this file inherits from the builtin QoS profile
BuiltinQosLib::Generic.StrictReliable. That profile, along with all of the
other built-in QoS profiles can be found in the
BuiltinProfiles.documentationONLY.xml file located in the
$NDDSHOME/resource/xml/ directory.
You may use any of these QoS configurations in your application simply by
referring to them by the name shown in the
BuiltinProfiles.documentationONLY.xml file and listed below:
* In library "BuiltinQosLib":
** Baseline
** Baseline.5.0.0
** Baseline.5.1.0
** Baseline.5.2.0
** Generic.Common
** Generic.510TransportCompatibility
** Generic.Monitoring.Common
** Generic.ConnextMicroCompatibility
** Generic.OtherDDSVendorCompatibility
* In library "BuiltinQosLibExp":
** Generic.StrictReliable
** Generic.KeepLastReliable
** Generic.BestEffort
** Generic.StrictReliable.HighThroughput
** Generic.StrictReliable.LowLatency
** Generic.Participant.LargeData
** Generic.Participant.LargeData.Monitoring
** Generic.StrictReliable.LargeData
** Generic.KeepLastReliable.LargeData
** Generic.StrictReliable.LargeData.FastFlow
** Generic.StrictReliable.LargeData.MediumFlow
** Generic.StrictReliable.LargeData.SlowFlow
** Generic.KeepLastReliable.LargeData.FastFlow
** Generic.KeepLastReliable.LargeData.MediumFlow
** Generic.KeepLastReliable.LargeData.SlowFlow
** Generic.KeepLastReliable.TransientLocal
** Generic.KeepLastReliable.Transient
** Generic.KeepLastReliable.Persistent
** Generic.AutoTuning
** Pattern.PeriodicData
** Pattern.Streaming
** Pattern.ReliableStreaming
** Pattern.Event
** Pattern.AlarmEvent
** Pattern.Status
** Pattern.AlarmStatus
** Pattern.LastValueCache
You should not edit the file BuiltinProfiles.documentationONLY.xml directly.
However, if you wish to modify any of the values in a built-in profile, the
recommendation is to create a profile of your own and inherit from the built-in
profile you wish to modify. The NDDS_QOS_PROFILES.example.xml file (contained in
the same directory as the BuiltinProfiles.documentationONLY.xml file) shows how
to inherit from the built-in profiles.
For more information about XML QoS Profiles see Chapter 17 in the
RTI Connext user manual.
-->
<dds xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="/home/build3/rti/waveworks/ndds600/connextdds/ndds.4.1/resource/schema/rti_dds_qos_profiles.xsd"
version="6.0.0">
<!-- QoS Library containing the QoS profile used in the generated example.
A QoS library is a named set of QoS profiles.
-->
<qos_library name="ExampleRequest_Library">
<!-- QoS profile used to configure reliable communication between the DataWriter
and DataReader created in the example code.
A QoS profile groups a set of related QoS.
-->
<qos_profile name="ExampleRequest_Profile" base_name="BuiltinQosLibExp::Generic.StrictReliable" is_default_qos="true">
<!-- QoS used to configure the data writer created in the example code -->
<datawriter_qos>
<name>ExampleRequestDataWriter</name>
<!-- This property is needed when using -unboundedSupport command-line option
in order to configure the memory allocation policy for the buffers that are
used to serialize the samples -->
<property>
<value>
<element>
<name>
dds.data_writer.history.memory_manager.fast_pool.pool_buffer_max_size
</name>
<value>4096</value>
</element>
</value>
</property>
</datawriter_qos>
<!-- QoS used to configure the data reader created in the example code -->
<datareader_qos>
<name>ExampleRequestDataReader</name>
<!-- This property is needed when using -unboundedSupport command-line option
in order to configure the memory allocation policy for the buffers that are
used to keep the serialized keys for the instances -->
<property>
<value>
<element>
<name>
dds.data_reader.history.memory_manager.fast_pool.pool_buffer_max_size
</name>
<value>4096</value>
</element>
</value>
</property>
</datareader_qos>
<participant_qos>
<!--
The participant name, if it is set, will be displayed in the
RTI tools, making it easier for you to tell one
application from another when you're debugging.
-->
<participant_name>
<name>ExampleRequestParticipant</name>
<role_name>ExampleRequestParticipantRole</role_name>
</participant_name>
</participant_qos>
</qos_profile>
</qos_library>
</dds>

You can use the profile called "RequesterExampleProfile", which modifies some parameters from the default. The example Creating a Requester with optional parameters shows how to create a rti::request::Requester using this profile.

See Also
Creating a Requester with optional parameters
Configuring QoS Profiles with XML

RTI Connext Modern C++ API Version 6.0.0 Copyright © Sun Mar 3 2019 Real-Time Innovations, Inc