This solution demonstrates how to integrate the KasperskyOS-adapted version of RabbitMQ® C AMQP client library into a KasperskyOS-based solution.
To illustrate this integration, the solution provides a practical example: an AMQP (Advanced Message Queuing Protocol) publisher that demonstrates asynchronous messaging capabilities using RabbitMQ as the message broker. The publisher application sends messages from KasperskyOS to a consumer running on the host system.
For additional details on KasperskyOS, including its limitations and known issues, please refer to the KasperskyOS Community Edition Online Help.
Publisher—Program that is an implementation of the AMQP publisher.DCM—System program that lets you dynamically create IPC channels.Ntpd—System program that implements an NTP client that receives time parameters from external NTP servers in the background and forwards them to the KasperskyOS kernel.BlobContainer—System program required for working with dynamic libraries in shared memory.EntropyEntity—System program that implements random number generation.DNetSrv—Network card driver.VfsSdCardFs—System program that supports the file system of SD cards.VfsNet—System program that supports network protocols.Dhcpcd—System program that implements a DHCP client, which gets network interface parameters from an external DHCP server in the background and passes them to a virtual file system.SDCard—SD Card driver.
When you build the example for the target hardware platform, platform-specific drivers are automatically included in the solution:
BSP—Hardware platform support package (Board Support Package). Provides cross-platform configuration of peripherals for the Radxa ROCK 3A and Raspberry Pi 4 B.GPIO—GPIO support driver for the Radxa ROCK 3A.PinCtrl—Low-level pin multiplexing (pinmux) configuration driver for the Radxa ROCK 3A.Bcm2711MboxArmToVc—Driver for working with the VideoCore (VC6) coprocessor via mailbox technology for Raspberry Pi 4 B.
This architecture features an AMQP publisher running in KasperskyOS that sends messages to a
RabbitMQ broker. The broker's deployment varies: it runs in a Docker container for QEMU environments
and directly on the host system for hardware configurations. Messages are consumed on the host
system using the amqp-tools utilities.
graph LR
subgraph Host ["Host system"]
direction TB
node1(RabbitMQ)
node3("AMQP consumer<br>(amqp-tools)")
end
subgraph KOS ["KasperskyOS"]
node2("AMQP publisher for KasperskyOS")
end
node2-->|"AMQP"|node1
node1-->|"AMQP"|node3
The solution initialization description file named init.yaml is generated during the solution
build process based on the ./einit/src/init.yaml.in template. Macros in
the @INIT_*@ format contained in the template are automatically expanded in the resulting
init.yaml file. For more details, refer to
init.yaml.in template.
The ./einit/src/security.psl file describes the security policy of the
solution. The declarations in the PSL file are provided with comments that explain the purpose of
these declarations. For more information about the security.psl file, see
Describing a security policy for a KasperskyOS-based solution.
- Confirm that your host system meets all the System requirements listed in the KasperskyOS Community Edition Developer's Guide.
- Install the KasperskyOS Community Edition SDK version 1.4. You can download it for free from os.kaspersky.com.
- Copy the source files of this example to your local project directory.
- Source the SDK setup script to configure the build environment. This exports the
KOSCEDIRenvironment variable, which points to the SDK installation directory:source /opt/KasperskyOS-Community-Edition-<platform>-<version>/common/set_env.sh
- Build the necessary drivers from source only if you intend to run this example on Radxa ROCK 3A hardware. This step is not required for QEMU or Raspberry Pi 4 B.
- Make sure that the Docker software is installed and running.
$ systemctl status docker - To run the RabbitMQ message broker, run the
RabbitMQ Docker official image using the following command:
$ docker run -d -p 5672:5672 --hostname my-rabbit --name some-rabbit rabbitmq:3 - Create an alias for your network interface with the address
10.0.2.2/24:$ sudo ip a a 10.0.2.2/24 dev docker0A static IP address
10.0.2.2and port5672are set for RabbitMQ message broker using theAMQP_BROKER_ADDRESSandAMQP_BROKER_PORTenvironment variables. You can change the broker address and port in the file./einit/src/init.yaml.inaccording to your network configuration. - Install the package
amqp-tools(command-line utilities for interacting with AMQP servers):$ sudo apt-get update -y $ sudo apt install amqp-tools - To check your environment, run the following command:
The screen should display information about the
$ docker statssome-rabbitrunning container. - To start the AMQP consumer on the host system when running the example on QEMU, run the
following command:
$ amqp-consume --server=10.0.2.2 --port=5672 --exchange=amq.direct --routing-key=test cat
- To install required packages on your host system, run the following command:
$ sudo apt install rabbitmq-server amqp-tools - Set your computer network interface to have a static IPv4 address
10.0.2.2/24. - To make sure the RabbitMQ message broker is operating, run the following command:
$ systemctl status rabbitmq-server.service - To start the AMQP consumer on the host system when running the example on Raspberry Pi 4 B or Radxa ROCK 3A, run the following command:
$ amqp-consume --server=localhost --port=5672 --exchange=amq.direct --routing-key=test cat
By default in the RabbitMQ message broker the guest user is prohibited
from connecting from remote hosts; it can only connect over a loopback interface (i.e. localhost).
This applies to connections regardless of the protocol. To get around this limitation, follow the
steps below:
- Use
rabbitmqctlto create a new user with the desired credentials:$ sudo rabbitmqctl add_user <user_name> <password> - Use the following command to set the virtual host access permissions for the new user:
(The full permissions are for illustrative purposes only. In a real solution, grant permissions carefully.)
$ sudo rabbitmqctl set_permissions --vhost '/' <user_name> '.*' '.*' '.*' - Replace the
guest/guestcredentials with <user_name>/<password> in thepublisher.cppfile.
The AMQP publisher for KasperskyOS is built using the CMake build system, which is provided in the KasperskyOS Community Edition SDK. When you develop a KasperskyOS-based solution, use the recommended structure of project directories to simplify the use of CMake scripts.
To build the example to run on QEMU, go to the directory with the example and run the following commands:
$ cmake -B build \
-D CMAKE_TOOLCHAIN_FILE="$KOSCEDIR/toolchain/share/toolchain-aarch64-kos.cmake"
$ cmake --build build --target {kos-qemu-image|sim}where:
kos-qemu-imagecreates a KasperskyOS-based solution image for QEMU that includes the example;simcreates a KasperskyOS-based solution image for QEMU that includes the example and runs it
After a successful build, the kos-qemu-image solution image will be located at the ./build/einit
directory.
To build the example to run on the target hardware platform, go to the directory with the example and run the following commands:
$ cmake -B build \
-D CMAKE_TOOLCHAIN_FILE="$KOSCEDIR/toolchain/share/toolchain-aarch64-kos.cmake"
$ cmake --build build --target {kos-image|sd-image}where:
kos-imagecreates a KasperskyOS-based solution image that includes the example;sd-imagecreates a file system image for a bootable SD card.
After a successful build, the kos-image solution image will be located at the ./build/einit
directory. The hdd.img bootable SD card image will be located at the ./build directory.
To run the example on the target hardware platform:
-
Connect the SD card to the computer.
-
Copy the bootable SD card image to the SD card using the command:
$ sudo dd bs=64k if=build/hdd.img of=/dev/sd[X] conv=fsync
where
[X]is the final character in the name of the SD card block device. -
Connect the bootable SD card to the board.
-
Supply power to the board and wait for the example to run.
You can also use an alternative option to prepare and run the example:
- Prepare the required hardware platform and bootable SD card by following the instructions in the KasperskyOS Community Edition Online Help:
- Run the example by following the instructions in the KasperskyOS Community Edition Online Help
./publisher/CMakeLists.txt—CMake commands for building the Publisher
program.
./einit/CMakeLists.txt—CMake commands for building the Einit program and
the solution image.
./CMakeLists.txt—CMake commands for building the solution.
After building and running the example, follow these steps:
- Wait until a message similar to the following appears in the QEMU standard output:
[Publisher] {"sequence"=1} ... [Publisher] {"sequence"=100} - A message similar to the following should appear in the host operating system standard output:
Server provided queue name: amq.gen-66CuP6WkyGbSerDewSCSow {"sequence"=1}...{"sequence"=100}
© 2026 AO Kaspersky Lab