7. Forwarding Routes

The following YAML configuration file configures a DDS Router to create two Simple Participants in domains 0 and 1. It then establishes a generic forwarding route between them, and a topic forwarding route for the topic Circle.

Note

This configuration enables participants in different domains to publish and subscribe to topics, as in Change Domain Example. The difference is that in this example we will use forwarding routes to define the participants we want to send messages to.

#######################
# CONFIGURATION VERSION
version: v4.0                                                     # 0

##############
# PARTICIPANTS
participants:                                                     # 1

####################
# SIMPLE PARTICIPANT
# This participant will subscribe to topics in domain 0.

  - name: SimpleParticipant_0                                     # 2
    kind: local                                                   # 3
    domain: 0                                                     # 4

####################
# SIMPLE PARTICIPANT
# This participant will subscribe to topics in domain 1.

  - name: SimpleParticipant_1
    kind: local
    domain: 1


################
# GENERIC ROUTES
routes:                                                           # 5

#######
# ROUTE
# This participant will forward the data it receives to
# SimpleParticipant_1
  - src: SimpleParticipant_0                                      # 6
    dst:                                                          # 7
      - SimpleParticipant_1                                       # 8

#######
# ROUTE
# This participant will not forward the data it receives.
  - src: SimpleParticipant_1                                      # 10


##############
# TOPIC ROUTES
topic-routes:                                                     # 11

  - name: Circle                                                  # 12
    type: HelloWorld                                              # 13

    routes:                                                       # 14

#############
# TOPIC ROUTE
# This participant will forward the data it receives on
# topic Circle to SimpleParticipant_0.
      - src: SimpleParticipant_1                                  # 15
        dst:                                                      # 16
          - SimpleParticipant_0                                   # 17

#############
# TOPIC ROUTE
# This participant will not forward the data it receives
# on topic Circle.
      - src: SimpleParticipant_0

7.1. Configuration

7.1.1. Simple Participants

These participants are configured with a name, a kind (local), and a domain id (0 and 1).

##############
# PARTICIPANTS
participants:                                                     # 1

####################
# SIMPLE PARTICIPANT
# This participant will subscribe to topics in domain 0.

  - name: SimpleParticipant_0                                     # 2
    kind: local                                                   # 3
    domain: 0                                                     # 4

####################
# SIMPLE PARTICIPANT
# This participant will subscribe to topics in domain 1.

  - name: SimpleParticipant_1
    kind: local
    domain: 1

7.1.2. Generic Forwarding Routes

We define the generic forwarding routes under the tag routes. This route is configured so that SimpleParticipant_1 subscribes to the data published by SimpleParticipant_0.

#######
# ROUTE
# This participant will forward the data it receives to
# SimpleParticipant_1
  - src: SimpleParticipant_0                                      # 6
    dst:                                                          # 7
      - SimpleParticipant_1                                       # 8

This route is configured so that SimpleParticipant_1 does not publish the data it receives. Thus, a subscriber in domain 0 would not receive the data published in domain 1.

#######
# ROUTE
# This participant will not forward the data it receives.
  - src: SimpleParticipant_1                                      # 10

7.1.3. Topic Forwarding Routes

We define the topic forwarding routes under the tag topic-routes by declaring the topic’s name, type, and routes.

##############
# TOPIC ROUTES
topic-routes:                                                     # 11

  - name: Circle                                                  # 12
    type: HelloWorld                                              # 13

    routes:                                                       # 14

Note

The type tag is required. The topic forwarding route will not be set for a topic with the same name but a different type.

Then, we declare the route for each participant.

Warning

When there is not a topic forwarding route for a specific topic, the generic forwarding route will be completely ignored and the topic forwarding route will be used instead.

This route is configured so that SimpleParticipant_0 will subscribe to the data published by SimpleParticipant_1.

#############
# TOPIC ROUTE
# This participant will forward the data it receives on
# topic Circle to SimpleParticipant_0.
      - src: SimpleParticipant_1                                  # 15
        dst:                                                      # 16
          - SimpleParticipant_0                                   # 17

This route is configured so that SimpleParticipant_0 does not forward the data it receives.

#############
# TOPIC ROUTE
# This participant will not forward the data it receives
# on topic Circle.
      - src: SimpleParticipant_0

7.2. Execute example

Please refer to the User Interface section for a detailed explanation on how to execute the DDS Router.

7.2.1. Execute with Fast DDS Basic Configuration Example

To check that the generic forwarding routes are working we are going to execute two examples. In the first one, we will set up a publisher in domain 0, a subscriber in domain 1, and check that the subscriber receives the publications. In the second one, we will set up a publisher in domain 1, a subscriber in domain 0, and check that the subscriber does not receive the publications, since there are no generic forwarding routes from domain 1 to domain 0.

7.2.1.1. Publish in domain 0 and subscribe in domain 1

Execute a Fast DDS BasicConfigurationExample publisher in domain 0:

./BasicConfigurationExample publisher --domain 0

Execute a Fast DDS BasicConfigurationExample subscriber in domain 1:

./BasicConfigurationExample subscriber --domain 1

Execute the DDS Router with the configuration file available at <path/to/ddsrouter_tool>/share/resources/configurations/examples/forwarding_routes.yaml. Once the DDS Router is running, messages from the publisher in domain 0 will be forwarded by the DDS Router to the subscriber in domain 1, that will print them in stdout.

7.2.1.2. Publish in domain 1 and subscribe in domain 0

Execute a Fast DDS BasicConfigurationExample publisher in domain 1:

./BasicConfigurationExample publisher --domain 1

Execute a Fast DDS BasicConfigurationExample subscriber in domain 0:

./BasicConfigurationExample subscriber --domain 0

Execute the DDS Router with this configuration file (available in <path/to/ddsrouter_tool>/share/resources/configurations/examples/forwarding_routes.yaml). Once the DDS Router is running, nothing should happen, since there are no generic forwarding routes from domain 1 to domain 0.

7.2.2. Execute with Fast DDS Basic Configuration Example on topic Circle

To check that the topic forwarding routes are working we are going to execute two examples. In the first one, we will set up a publisher in domain 1, a subscriber in domain 0, and check that the subscriber receives the publications on topic Circle. In the second one, we will set up a publisher in domain 0, a subscriber in domain 1, and check that the subscriber does not receive the publications, since there are no topic forwarding routes from domain 0 to domain 1 on topic Circle.

7.2.2.1. Publish in domain 1 and subscribe in domain 0

Execute a Fast DDS BasicConfigurationExample publisher in domain 1 on topic Circle:

./BasicConfigurationExample publisher --domain 1 --topic Circle

Execute a Fast DDS BasicConfigurationExample subscriber in domain 0 on topic Circle:

./BasicConfigurationExample subscriber --domain 0 --topic Circle

Execute the DDS Router with the configuration file available at <path/to/ddsrouter_tool>/share/resources/configurations/examples/forwarding_routes.yaml. Once the DDS Router is running, messages from the publisher in domain 1 on topic Circle will be forwarded by the DDS Router to the subscriber in domain 0, that will print them in stdout.

7.2.2.2. Publish in domain 0 and subscribe in domain 1

Execute a Fast DDS BasicConfigurationExample publisher in domain 0 on topic Circle:

./BasicConfigurationExample publisher --domain 0 --topic Circle

Execute a Fast DDS BasicConfigurationExample subscriber in domain 1 on topic Circle:

./BasicConfigurationExample subscriber --domain 1 --topic Circle

Execute the DDS Router with this configuration file (available in <path/to/ddsrouter_tool>/share/resources/configurations/examples/forwarding_routes.yaml). Once the DDS Router is running, nothing should happen, since there are no topic forwarding routes on topic Circle from domain 0 to domain 1.