Skip to content

Commit 7c2d007

Browse files
Update RPC example to use new features (#698)
* REQREPLY-196: Update RPC example to use new features. - Service discovery - Built-in RPC QoS profile
1 parent 6de7ed3 commit 7c2d007

File tree

5 files changed

+39
-139
lines changed

5 files changed

+39
-139
lines changed

examples/connext_dds/remote_procedure_call/README.md

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
11
# Example Code: Remote Procedure Call
22

3-
:warning: **Note**: The RPC communication pattern is experimental and available
4-
in the Python and Modern C++ **Connext** APIs.
5-
63
## Concept
74

85
Remote Procedure Call (RPC) is a specialization of the Request-Reply
96
communication pattern. It simplifies "client" and "service" applications by
107
using a service interface with operations that are implemented in the service
118
and called from the clients.
129

13-
See the [User's Manual](https://community.rti.com/static/documentation/connext-dds/7.2.0/doc/manuals/connext_dds_professional/users_manual/users_manual/RPC.htm)
10+
See the [User's Manual](https://community.rti.com/static/documentation/connext-dds/7.4.0/doc/manuals/connext_dds_professional/users_manual/users_manual/RPC.htm)
1411
for more information.
1512

1613
## Example Description

examples/connext_dds/remote_procedure_call/c++11/Inventory_client.cxx

+4-2
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,10 @@ void run_client(
3232
// Create a client with the ClientParams
3333
::InventoryServiceClient client(client_params);
3434

35-
// Wait until the service is started
36-
client.wait_for_service();
35+
// Wait until the service is discovered
36+
if (!client.wait_for_service(dds::core::Duration(20))) {
37+
throw std::runtime_error("Service not available");
38+
}
3739

3840
std::cout << "Initial inventory: " << client.get_inventory() << std::endl;
3941

examples/connext_dds/remote_procedure_call/c++11/README.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
# Example Code: Remote Procedure Calls
22

3+
:warning: **Connext 7.4.0** This example requires *Connext 7.4.0 or higher*.
4+
For the same example with support for older versions, check out the
5+
corresponding release branch, such as `release/7.3.0`.
6+
37
:warning: **Note**: For an overview of this feature, see the
4-
[RPC Tutorial](https://community.rti.com/static/documentation/connext-dds/7.2.0/doc/api/connext_dds/api_cpp2/group__RpcTutorialModule.html)
8+
[RPC Tutorial](https://community.rti.com/static/documentation/connext-dds/7.4.0/doc/api/connext_dds/api_cpp2/group__RpcTutorialModule.html)
59
section of the *Connext* Modern C++ API Reference.
610

711
## Building the Example :wrench:

examples/connext_dds/remote_procedure_call/c++11/USER_QOS_PROFILES.xml

+28-131
Original file line numberDiff line numberDiff line change
@@ -1,150 +1,47 @@
11
<?xml version="1.0"?>
22

33
<dds xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4-
xsi:noNamespaceSchemaLocation="http://community.rti.com/schema/7.0.0/rti_dds_qos_profiles.xsd">
4+
xsi:noNamespaceSchemaLocation="http://community.rti.com/schema/current/rti_dds_profiles.xsd">
55

66
<qos_library name="RequestReplyExampleProfiles">
7-
8-
<!-- Default QoS:
9-
10-
This profile contains the QoS that Requesters and Repliers
11-
would use by default. We can use it as a base profile to inherit
12-
from and override some parameters
13-
-->
14-
<qos_profile name="default">
15-
<datawriter_qos>
16-
17-
<!-- Strict reliable -->
18-
<reliability>
19-
<kind>RELIABLE_RELIABILITY_QOS</kind>
20-
<max_blocking_time>
21-
<sec>10</sec>
22-
<nanosec>0</nanosec>
23-
</max_blocking_time>
24-
</reliability>
25-
26-
<history>
27-
<kind>KEEP_ALL_HISTORY_QOS</kind>
28-
</history>
29-
30-
<!-- These are typical protocol parameters for a reliable
31-
DataWriter -->
32-
<protocol>
33-
<rtps_reliable_writer>
34-
<max_heartbeat_retries>
35-
LENGTH_UNLIMITED
36-
</max_heartbeat_retries>
37-
<heartbeats_per_max_samples>
38-
2
39-
</heartbeats_per_max_samples>
40-
<heartbeat_period>
41-
<sec>0</sec>
42-
<nanosec>100000000</nanosec> <!--100ms -->
43-
</heartbeat_period>
44-
<fast_heartbeat_period>
45-
<sec>0</sec>
46-
<nanosec>10000000</nanosec> <!--10ms -->
47-
</fast_heartbeat_period>
48-
<late_joiner_heartbeat_period>
49-
<sec>0</sec>
50-
<nanosec>10000000</nanosec> <!--10ms -->
51-
</late_joiner_heartbeat_period>
52-
<max_nack_response_delay>
53-
<sec>0</sec>
54-
<nanosec>0</nanosec>
55-
</max_nack_response_delay>
56-
<min_nack_response_delay>
57-
<sec>0</sec>
58-
<nanosec>0</nanosec>
59-
</min_nack_response_delay>
60-
<max_send_window_size>32</max_send_window_size>
61-
<min_send_window_size>32</min_send_window_size>
62-
</rtps_reliable_writer>
63-
</protocol>
64-
65-
<writer_resource_limits>
66-
<!-- This setting enables efficient communication
67-
between a replier and an arbitrary number of requesters
68-
-->
69-
<max_remote_reader_filters>
70-
LENGTH_UNLIMITED
71-
</max_remote_reader_filters>
72-
</writer_resource_limits>
73-
</datawriter_qos>
74-
7+
8+
<!-- Use these profiles to customize the Requester or Replier QoS -->
9+
10+
<!-- These profiles inherit from the built-in profile
11+
BuiltinQosLib::Pattern.RPC, which defines the default values for
12+
the DataWriters and DataReaders created by a Requester or Replier
13+
-->
14+
<qos_profile name="RequesterExampleProfile" base_name="BuiltinQosLib::Pattern.RPC">
15+
<!-- Set the QoS for the DataReader created by the Requester -->
16+
<!--
7517
<datareader_qos>
76-
<!-- Strict reliable -->
77-
<reliability>
78-
<kind>RELIABLE_RELIABILITY_QOS</kind>
79-
<max_blocking_time>
80-
<sec>10</sec>
81-
<nanosec>0</nanosec>
82-
</max_blocking_time>
83-
</reliability>
84-
85-
<history>
86-
<kind>KEEP_ALL_HISTORY_QOS</kind>
87-
</history>
88-
89-
<!-- These are typical protocol parameters for a reliable
90-
DataReader -->
91-
<protocol>
92-
<rtps_reliable_reader>
93-
<max_heartbeat_response_delay>
94-
<sec>0</sec>
95-
<nanosec>0</nanosec>
96-
</max_heartbeat_response_delay>
97-
<min_heartbeat_response_delay>
98-
<sec>0</sec>
99-
<nanosec>0</nanosec>
100-
</min_heartbeat_response_delay>
101-
</rtps_reliable_reader>
102-
</protocol>
103-
18+
...
10419
</datareader_qos>
105-
106-
</qos_profile>
107-
108-
<!-- This is the profile used by the Requester.
109-
It inherits from "default", defined above,
110-
and overrides some QoS -->
111-
<qos_profile name="RequesterExampleProfile"
112-
base_name="default">
20+
-->
11321

114-
<!-- QoS for the data writer that sends requests -->
22+
<!-- Set the QoS for the DataWriter created by the Requester -->
23+
<!--
11524
<datawriter_qos>
116-
<durability>
117-
<kind>TRANSIENT_LOCAL_DURABILITY_QOS</kind>
118-
</durability>
25+
...
11926
</datawriter_qos>
27+
-->
28+
</qos_profile>
12029

121-
<!-- QoS for the data reader that receives replies -->
30+
<qos_profile name="ReplierExampleProfile" base_name="BuiltinQosLib::Pattern.RPC">
31+
32+
<!-- Set the QoS for the DataReader created by the Replier -->
33+
<!--
12234
<datareader_qos>
123-
<durability>
124-
<kind>VOLATILE_DURABILITY_QOS</kind>
125-
</durability>
35+
...
12636
</datareader_qos>
127-
</qos_profile>
37+
-->
12838

129-
<!-- This is the profile used by the Replier.
130-
It inherits from "default", defined above,
131-
and overrides some QoS -->
132-
<qos_profile name="ReplierExampleProfile"
133-
base_name="default">
134-
135-
<!-- QoS for the data writer that sends replies -->
39+
<!-- Set the QoS for the DataWriter created by the Replier -->
40+
<!--
13641
<datawriter_qos>
137-
<durability>
138-
<kind>VOLATILE_DURABILITY_QOS</kind>
139-
</durability>
42+
...
14043
</datawriter_qos>
141-
142-
<!-- QoS for the data reader that receives requests -->
143-
<datareader_qos>
144-
<durability>
145-
<kind>TRANSIENT_LOCAL_DURABILITY_QOS</kind>
146-
</durability>
147-
</datareader_qos>
44+
-->
14845
</qos_profile>
14946

15047
</qos_library>

examples/connext_dds/remote_procedure_call/py/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Example Code: Remote Procedure Calls
22

33
:warning: **Note**: For an overview of this feature, see the
4-
[Remote Procedure Calls](https://community.rti.com/static/documentation/connext-dds/7.2.0/doc/api/connext_dds/api_python/rpc.html#remote-procedure-calls)
4+
[Remote Procedure Calls](https://community.rti.com/static/documentation/connext-dds/7.4.0/doc/api/connext_dds/api_python/rpc.html#remote-procedure-calls)
55
section of the *Connext* Python API Reference.
66

77
## Running the Example

0 commit comments

Comments
 (0)