Skip to content
Stand with Ukraine flag

Building from source

This guide covers downloading and building TBMQ from source. Instructions are tested on Ubuntu 22.04 LTS and 24.04 LTS.

The build produces installation packages for Linux and Windows and, optionally, local Docker images. The first build downloads all dependencies and can take 15 minutes or more; later builds reuse them.

Required tools

  • Java 25
  • Maven 3.6.3+
  • Git
  • Docker (images and tests)

Build outputs

  • .deb Debian and Ubuntu package thingsboard-mqtt-broker.deb
  • .rpm RPM package thingsboard-mqtt-broker.rpm
  • .zip Windows package thingsboard-mqtt-broker-windows.zip
  • Images Local Docker images Optional: build local Docker images

This section describes the build tools required to compile TBMQ from source.

TBMQ is built using Java 25. Install OpenJDK 25:

Terminal window
sudo apt update
sudo apt install openjdk-25-jdk-headless

Configure your operating system to use OpenJDK 25 by default. Set the default version with the following command:

Terminal window
sudo update-alternatives --config java

Verify the installation:

Terminal window
java -version
Expected output
openjdk version "25.0.xx"
OpenJDK Runtime Environment (...)
OpenJDK 64-Bit Server VM (build ...)

TBMQ requires Maven 3.6.3 or later:

Terminal window
sudo apt install maven

Installing Maven also installs your distribution’s default Java runtime. Check that Maven runs on Java 25:

Terminal window
mvn -version

The output must include Java version: 25. If it shows another version, follow the Java instructions above to restore Java 25 as the default.

Install Git to clone the source code:

Terminal window
sudo apt install git

Docker is needed only to build local Docker images and to run the tests. Install Docker, then make sure your user can run Docker without root — the build talks to Docker as the user who runs Maven.

Clone the repository from the official GitHub repo:

Terminal window
git clone -b release-2.4.2 https://github.com/thingsboard/tbmq.git
cd tbmq

From the tbmq directory, build the project:

Terminal window
mvn clean install -DskipTests

To also build the Docker images, run the build with the Docker plugin enabled:

Terminal window
mvn clean install -DskipTests -Ddockerfile.skip=false

The build creates the following images, each also tagged latest:

thingsboard/tbmq:2.4.2
thingsboard/tbmq-node:2.4.2
thingsboard/tbmq-integration-executor:2.4.2

Debian, RPM, and Windows packages are located in the target folder:

Terminal window
cd application/target
File Package
thingsboard-mqtt-broker.deb Debian and Ubuntu package
thingsboard-mqtt-broker.rpm RPM package
thingsboard-mqtt-broker-windows.zip Windows package

Integration tests start their dependencies in Docker containers through Testcontainers, so they need Docker with access for your user.

Run all unit and integration tests:

Terminal window
mvn clean install

Common fixes for build issues:

  • Clean Maven cache:

    Terminal window
    rm -rf ~/.m2/repository
  • Clean Gradle cache:

    Terminal window
    rm -rf ~/.gradle/caches/
  • Clean node modules:

    Terminal window
    rm -rf ui-ngx/node_modules
  • Build in parallel, format license headers, and build Docker images:

    Terminal window
    mvn -T 0.8C license:format clean install -DskipTests -Ddockerfile.skip=false

Run your build

The Docker install runs the thingsboard/tbmq images, so after a local image build it runs your build. See Docker (Linux, macOS).

Tune the configuration

Every broker parameter, its environment variable, and its default. See the configuration reference.

Connect your first client

Set up client credentials, then publish and subscribe with an MQTT client. See Getting started.

Learn the architecture

How the broker nodes, Kafka, Valkey, and PostgreSQL fit together. See Architecture.