aimrt.channel
Configuration Overview
The aimrt.channel configuration item is used to configure the Channel feature. Detailed configuration items are described below:
Node |
Type |
Optional |
Default |
Purpose |
|---|---|---|---|---|
backends |
array |
Optional |
[] |
List of Channel backends |
backends[i].type |
string |
Required |
“” |
Type of the Channel backend |
backends[i].options |
map |
Optional |
- |
Configuration for the specific Channel backend |
pub_topics_options |
array |
Optional |
“” |
Configuration for Channel Pub Topics |
pub_topics_options[i].topic_name |
string |
Required |
“” |
Name of the Channel Pub Topic, supports regular expressions |
pub_topics_options[i].enable_backends |
string array |
Required |
[] |
List of allowed Channel backends for the Channel Pub Topic |
pub_topics_options[i].enable_filters |
string array |
Optional |
[] |
List of framework-side filters to be loaded for the Channel Pub Topic |
sub_topics_options |
array |
Optional |
“” |
Configuration for Channel Sub Topics |
sub_topics_options[i].topic_name |
string |
Required |
“” |
Name of the Channel Sub Topic, supports regular expressions |
sub_topics_options[i].enable_backends |
string array |
Required |
[] |
List of allowed Channel backends for the Channel Sub Topic |
sub_topics_options[i].enable_filters |
string array |
Optional |
[] |
List of framework-side filters to be loaded for the Channel Sub Topic |
Detailed configuration instructions for aimrt.channel:
backendsis an array used to configure various Channel backends.backends[i].typeis the type of the Channel backend. AimRT officially provides thelocalbackend, and some plugins also provide certain Channel backend types.backends[i].optionsare the initialization parameters passed by AimRT to each Channel backend. The format of this configuration is defined by each Channel backend type; please refer to the documentation of the corresponding Channel backend type.
pub_topics_optionsandsub_topics_optionsare rule lists used to control the Channel backend rules used by eachTopicwhen publishing or subscribing to messages, where:topic_nameindicates theTopicname for this rule, configured as a regular expression. If theTopicname matches this regular expression, this rule will be applied.enable_backendsis a string array indicating that if theTopicname matches this rule, all messages published under thisTopicwill be delivered to all Channel backends in this list for processing. Note:All names appearing in this array must have been configured in
backends.The order of Channel backends configured in this array determines the order in which messages are delivered to each Channel backend for processing.
enable_filtersis a string array indicating the list of framework-side filters to be registered on the pub/sub side, with the order in the array being the order of filter registration. Some plugins provide framework-side filters for performing pre/post operations during channel invocation.Rules are checked from top to bottom; once a
Topicmatches a rule, no further rules will be checked for thatTopic.
In AimRT, the front-end interface and back-end implementation of the Channel are decoupled. After a message is Published through the interface, the actual publishing action is carried out by the Channel backend. Typically, after the Publish call, the message is sequentially delivered to various Channel backends for processing within the current thread. Most Channel backends handle messages asynchronously, but some special backends—such as the local backend—can be configured to invoke subscriber callbacks in a blocking manner. Therefore, how long the Publish method will block is undefined and depends on the specific backend configuration.
Here is a simple example:
aimrt:
channel:
backends:
- type: local
- type: mqtt
pub_topics_options:
- topic_name: "(.*)"
enable_backends: [local]
enable_filters: []
sub_topics_options:
- topic_name: "(.*)"
enable_backends: [local]
enable_filters: []
local Type Channel Backend
The local type Channel backend is an officially provided Channel backend by AimRT, used to publish messages to other modules within the same process. It automatically determines whether the publisher and subscriber are within the same Pkg and optimizes performance accordingly. All its configuration items are as follows:
Node |
Type |
Optional |
Default |
Purpose |
|---|---|---|---|---|
subscriber_use_inline_executor |
bool |
Optional |
true |
Whether the subscriber callback uses the inline executor |
subscriber_executor |
string |
Required when subscriber_use_inline_executor is false |
“” |
Name of the executor used for subscriber callbacks |
Usage notes:
If
subscriber_use_inline_executoris set totrue, the subscriber callback will be executed directly using the publisher’s executor, blocking the publisher’s Publish method until all subscriber callbacks have completed execution.subscriber_executoronly takes effect whensubscriber_use_inline_executorisfalse. The backend will deliver all subscriber callbacks to this executor for asynchronous execution, and the publisher’s Publish method will return immediately.
Here is a simple example:
aimrt:
executor:
executors:
- name: work_thread_pool
type: asio_thread
options:
thread_num: 4
channel:
backends:
- type: local
options:
subscriber_use_inline_executor: false
subscriber_executor: work_thread_pool
pub_topics_options:
- topic_name: "(.*)"
enable_backends: [local]
sub_topics_options:
- topic_name: "(.*)"
enable_backends: [local]