# Local Communication
In the cases where multiple modules are running on Ability Edge gateway, there might be a need for communication between the modules. One of the ways of how it could be achieved is by the usage of the MQTT topics that are dedicated for that purpose:
{topics_local_out}/{targetModuleId}/{input}
- send messages to other modules via this topic{topics_local_in}/#
- subscribe to it, ot receive messages from other modules. Last level of the topic represents an input identifier.
The mesage may contain payload. Target module must be able to accept messages on
that input and you must be aware of the expected payload structure. Note that
since the targetModuleId
is the service name, which is only assigned after a
module's identity has been created in the information model, you can only
configure your module with the target module identifier after the edge
registration flow has been completed (either via your own custom configuration
properties or docker.env
section of the abb.ability.configuration model of
your module).
# Example
Let's assume that we have 2 modules running on our Ability Edge gateway:
- Module1
- Module2
Module1 may send a message to the Module2 in the following way:
Topic: modules/local/module2/example
Payload:
{
"requestType": "whatTimeIsIt"
}
The Module2 would receive the following message:
Topic: modules/local/module2/example
Payload:
{
"message": "whatTimeIsIt"
}
which is exactly the same as Module1 has sent. Now, Module2 may respond to Module1 by sending another message.
For a much more practical (and realistic) example have a look at this article.
← Remote Methods Files →