eclipse-cyclonedds / cyclonedds

Eclipse Cyclone DDS project
https://projects.eclipse.org/projects/iot.cyclonedds
Other
878 stars 360 forks source link

ExternalDomainId #1790

Open Titikshaaaa opened 1 year ago

Titikshaaaa commented 1 year ago

//CycloneDDS/Domain/Discovery/ExternalDomainId An override for the domain id is used to discovery and determine the port number mapping. This allows the creating of multiple domains in a single process while making them appear as a single domain on the network. The value "default" disables the override.

In this i am externally setting domain id. I am expecting that for example a publisher will publish message in both domain id i.e first in the domain id we provide while making participant and second in xml file as i was thinking that multiple domains are their in single process. But here the domain id which i am specfying in the xml file is overriding the domain id. So what is meant by this ExternalDomainId

eboasson commented 1 year ago

The only thing ExternalDomainId does is affect the mapping to UDP port numbers and the domain id that is advertised in the participant discovery messages. The documentation is correct, if perhaps a bit cryptic.

You can create N domains with different domain ids in the process. They will be kept separately, just as they would be if they were separate processes. Ordinarily they will not see each other's discovery messages because the port numbers are different, but even if you override the port numbers (the mapping is configurable) they will not communicate because the domain id is also part of the discovery data.

The one thing this option does that you cannot do in any other way is that it changes the domain id in the discovery. After you change that, it will be treated as that domain by anyone listening on the network.

That is, if you create two domains, 0 and 1 and you set the ExternalDomainId of both to 2, then everyone in the network considers them to be domain 2. If those domains 0 and 1 are in the same process, that means they will discover each other via the network protocol and communicate via the loopback interface.

And that is the only purpose this option serves: easily running network-based tests in a single process.