KB: How to use Services without sending TypeCode/TypeObject

In order to reduce discovery traffic, you can avoid sending the TypeCode and TypeObject from your applications and Services.

You avoid propagating the Type by setting the max_serialized_length in the QoS file as follows:

  • To not propagate TypeCode:
    <participant_qos>
        <resource_limits>
            <type_code_max_serialized_length>0</type_code_max_serialized_length>
        </resource_limits>
    </participant_qos>
  • To not propagate TypeObject:
    <participant_qos>
        <resource_limits>
            <type_object_max_serialized_length>0</type_object_max_serialized_length>
        </resource_limits>
    </participant_qos>

See this article to learn more about TypeCodes and TypeObjects.

If you are going to use a Service, you need to specify the type, so there is no need to propagate it. In order to do this with, for example, Routing Service, follow these steps:

  • Obtain the equivalent XML file from the IDL definition. We will use this XML type definition in the configuration file for Routing Service to specify the type. If you only have the IDL type definition, you can use rtiddsgen to generate an equivalent XML file:

    %NDDSHOME%/bin/rtiddsgen -convertToXML <idl_definition>
  • Define the type in the Routing Service configuration. In order to do this, you will need to specify the type inside the <types> label. There are two ways of doing this, by defining the XML file or by defining the type itself:

    <types>
        <include file="types.xml"/>
    </types>

    Or

    <types>
        <struct name="ShapeType">
            <member name="color" stringMaxLenght="128" type="string" key="true"/>
            <member name="x" type="int32"/>
            <member name="y" type="int32"/> 
            <member name="shapesize" type="int32"/> 
        </struct>
    </types>
  • Register the type for your participants:

    <participant_1>
        <domain_id>34</domain_id>
        <registered_type name="ShapeType" type_name="ShapeType"/> 
    </participant_1>

Now the application and the Service will communicate properly without sending the TypeCode/TypeObject on the wire.

The Routing Service example is attached.

 
Attachments: