# Local Communication v2
# Module-to-Module Communication
With this API, you can get modules to communicate with each other. There are two ways for them to communicate:
- point to point - one module sends a message to another module
- broadcast - one module sends a message to many other modules
The endpoints below describe how this works:
# PUB Send messages to other modules
# to/module/{module_id}/local/{name}
In this case, module_id is a target module identifier. Your module can publish local messages to any other module.
# SUB Receive targeted messages from other modules
# to/module/{module_id}/local/{name}
Here, the module_id points to the module sending targeted messages.
# PUB Broadcast messages from your module
# from/module/{module_id}/local/{name}
The module_id is used here as the target module identifier.
# SUB Subscribe to broadcasted messages from other modules
# from/module/{module_id}/local/{name}
In this case, module_id is the identifier of the publisher.
Parameters:
Name | Type | Description | Accepted values |
---|---|---|---|
module_id | string | Module identifier | Name of module |
name | string | Input name | Any |
Message format
Properties:
Key | Value | Notes | Mandatory |
---|---|---|---|
correlationId | <string> | Unique String (e.g. uuid) | No |
target | <string> | No | |
context | <string> | No | |
source | <string> | No |
These properties can be included in the request by adding them to the topic to which you are sending the messages. See the Message Properties section to find out more.
Here is an example of the properties used:
to/module/{module_id}/local/{name}&correlationId={correlationId}
to/module/{module_id}/local/{name}&correlationId={correlationId}
from/module/{module_id}/local/{name}&correlationId={correlationId}
from/module/{module_id}/local/{name}&correlationId={correlationId}
Payload information:
The payload should contain any well-formed JSON, String, XML, or similar.
Payload example:
{
"publisherId": "blmodule1",
"file": "to1.txt"
}