Creating a DomainParticipant

Typically, you will only need to create one DomainParticipant per DDS domain per application. (Although unusual, you can create multiple DomainParticipants for the same DDS domain in an application.)

To create a DomainParticipant, use the DomainParticipantFactory’s create_participant() or create_participant_with_profile() operation:

A QoS profile is way to use QoS settings from an XML file or string. With this approach, you can change QoS settings without recompiling the application. For details, see Configuring QoS with XML.

Note: In the Modern C++ API, you will use the DomainParticipant constructors.

DDSDomainParticipant * create_participant( 
DDS_DomainId_t domainId,
const DDS_DomainParticipantQos &qos,
DDSDomainParticipantListener *listener,
DDS_StatusMask mask) DDSDomainParticipant * create_participant_with_profile ( DDS_DomainId_t domainId, const char * library_name, const char *profile_name, DDSDomainParticipantListener *listener, DDS_StatusMask mask)



The domain ID uniquely identifies the DDS domain that the DomainParticipant is in. It controls with which other DomainParticipants it will communicate. See Choosing a Domain ID and Creating Multiple DDS Domains for more information on domain IDs.


If you want the default QoS settings (described in the API Reference HTML documentation), use DDS_PARTICIPANT_QOS_DEFAULT for this parameter (see Figure: Creating a DomainParticipant with Default QosPolicies ). If you want to customize any of the QosPolicies, supply a DomainParticipantQos structure that is described in Setting DomainParticipant QosPolicies.

Note: If you use DDS_PARTICIPANT_QOS_DEFAULT, it is not safe to create the DomainParticipant while another thread may simultaneously be calling the DomainParticipantFactory’s set_default_participant_qos() operation.


Listeners are callback routines. Connext DDS uses them to notify your application of specific events (status changes) that may occur. The listener parameter may be set to NULL if you do not want to install a Listener. The DomainParticipant’s Listener is a catchall for all of the events of all of its Entities. If an event is not handled by an Entity’s Listener, then the DomainParticipantListener may be called in response to the event. For more information, see Setting Up DomainParticipantListeners.


This bit mask indicates which status changes will cause the Listener to be invoked. The bits set in the mask must have corresponding callbacks implemented in the Listener. If you use NULL for the Listener, use DDS_STATUS_MASK_NONE for this parameter. If the Listener implements all callbacks, use DDS_STATUS_MASK_ALL. For information on statuses, see Listeners.


A QoS Library is a named set of QoS profiles. See URL Groups.


A QoS profile groups a set of related QoS, usually one per entity. See URL Groups.

After you create a DomainParticipant, the next step is to register the data types that will be used by the application, see Using RTI Code Generator (rtiddsgen). Then you will need to create the Topics that the application will publish and/or subscribe, see Creating Topics. Finally, you will use the DomainParticipant to create Publishers and/or Subscribers, see Creating Publishers and Creating Subscribers.

Note: It is not safe to create one DomainParticipant while another thread may simultaneously be looking up (Looking Up DomainParticipants) or deleting (Deleting DomainParticipants) the same DomainParticipant.

For more examples, see Configuring QoS Settings when DomainParticipant is Created.


Figure: Creating a DomainParticipant with Default QosPolicies

DDS_DomainId_t domain_id = 10;
// MyDomainParticipantListener is user defined and
// extends DDSDomainParticipantListener
MyDomainParticipantListener* participant_listener = 
	new MyDomainParticipantListener(); // or = NULL
// Create the participant
DDSDomainParticipant* participant = factory->create_participant(
	participant_listener, DDS_STATUS_MASK_ALL);
if (participant == NULL) {
	// ... error

© 2018 RTI