Skip to main content

Overview

The Coreflux MQTT broker provides a rich set of commands that you can use to manage users, rules, models, actions, routes, and more. These commands are published to the $SYS/Coreflux/Command topic to control and configure the broker.

Why Use Broker Commands?

Instead of editing configuration files and restarting the broker, you can manage everything at runtime through MQTT messages. Add users, deploy LoT Actions, configure Routes—all without downtime.
Think of broker commands as a remote control for your broker. You send a message to a special topic, and the broker immediately responds—no SSH, no restarts, no manual file editing.

In This Page

SectionDescription
Command FormatHow to structure commands
User ManagementAdd, remove, and configure users
LoT CommandsManage Rules, Models, Actions, and Routes
Python IntegrationAdd and manage Python scripts
System CommandsTrace logging and diagnostics

Command Format

Commands are sent to the broker via MQTT messages published to the $SYS/Coreflux/Command topic. The general format is:
-commandName <argument>
For example:
-addAction DEFINE ACTION MyAction ON EVERY 10 SECONDS DO PUBLISH TOPIC "test" WITH "hello"
Command responses are published to $SYS/Coreflux/Command/Output. Subscribe to this topic to receive feedback from your commands.

User Management Commands

Manage broker users and their credentials.

Adding a User

Create a new user with a username and password:
-addUser <username> <password>
Example:
-addUser operator SecurePass123!
Response: User operator added successfully!

Removing a User

Remove an existing user from the broker:
-removeUser <username>
Example:
-removeUser operator
Response: User operator removed successfully!

Changing User Password

Update a user’s password:
-changeUserPassword <username> <newPassword>
Example:
-changeUserPassword operator NewSecurePass456!
Response: Password for user operator changed successfully!

Changing User Settings

Modify specific settings for a user:
-changeUserSettings <username> <settingName> <newValue>
Response: Settings for user updated successfully!

LoT Commands

Commands for managing LoT (Language of Things) entities.

Rules

Rules define access control and permissions for the broker. See the Rules documentation for complete syntax reference.
Rules are LoT code and can also be deployed directly from a LoT Notebook by running the cell containing your rule definition.

Adding a Rule

-addRule DEFINE RULE <RuleName> WITH PRIORITY <number> FOR <Scope> [TO TOPIC "<pattern>"]
    IF <condition> THEN
        ALLOW
    ELSE
        DENY
Example — Restrict Action creation to admins:
-addRule DEFINE RULE AllowActionCreation WITH PRIORITY 1 FOR ActionManagementCreation
    IF USER IS "root" OR USER IS "admin" THEN
        ALLOW
    ELSE
        DENY
Response: Rule 'AllowActionCreation' added successfully
Example — Control topic access:
-addRule DEFINE RULE RestrictSensorPublish WITH PRIORITY 1 FOR Publish TO TOPIC "sensors/#"
    IF USER HAS SensorPermission THEN
        ALLOW
    ELSE
        DENY
Response: Rule 'RestrictSensorPublish' added successfully

Removing a Rule

-removeRule <ruleName>
Example:
-removeRule AllowActionCreation
Response: Rule 'AllowActionCreation' removed successfully

Models

Models define data structures for topic payloads.

Adding a Model

-addModel DEFINE MODEL <modelName>
    <model definition>
Example:
-addModel DEFINE MODEL TemperatureSensor
    WITH TOPIC "sensors/+/temperature"
    ADD FIELD temperature WITH TYPE Float
    ADD FIELD unit WITH TYPE String
    ADD FIELD timestamp WITH TYPE DateTime
Response: Model 'TemperatureSensor' added successfully

Removing a Model

-removeModel <modelName>
Example:
-removeModel TemperatureSensor
Response: Model 'TemperatureSensor' removed successfully

Removing All Models

-removeAllModels
Response: All models removed successfully
This command removes ALL models from the broker. Use with caution.

Actions

Actions define automated behaviors triggered by events or schedules.

Adding an Action

-addAction DEFINE ACTION <actionName>
    <action definition>
Example - Time-based Action:
-addAction DEFINE ACTION Heartbeat
    ON EVERY 10 SECONDS DO
        PUBLISH TOPIC "system/heartbeat" WITH TIMESTAMP "UTC"
Example - Topic-based Action:
-addAction DEFINE ACTION EchoMessage
    ON TOPIC "input/data" DO
        PUBLISH TOPIC "output/echo" WITH PAYLOAD
Response: Action 'Heartbeat' added successfully

Removing an Action

-removeAction <actionName>
Example:
-removeAction Heartbeat
Response: Action 'Heartbeat' removed successfully

Running an Action Manually

Trigger an action to run immediately:
-runAction <actionName>
Example:
-runAction Heartbeat
Response: Action 'Heartbeat' executed successfully

Removing All Actions

-removeAllActions
Response: All actions removed successfully

Routes

Routes configure connections to external systems and data pipelines.

Adding a Route

-addRoute DEFINE ROUTE <routeName> WITH TYPE <routeType>
    <route configuration>
Example - MQTT Bridge:
-addRoute DEFINE ROUTE CloudBridge WITH TYPE MQTT_BRIDGE
    ADD SOURCE_CONFIG
        WITH BROKER SELF
    ADD DESTINATION_CONFIG
        WITH BROKER_ADDRESS "iot.cloudprovider.com"
        WITH BROKER_PORT '8883'
        WITH USE_TLS true
    ADD MAPPING sensorData
        WITH SOURCE_TOPIC "sensors/#"
        WITH DESTINATION_TOPIC "factory1/sensors/#"
        WITH DIRECTION "out"
Response: Route 'CloudBridge' added successfully

Removing a Route

-removeRoute <routeName>
Example:
-removeRoute CloudBridge
Response: Route 'CloudBridge' removed successfully

Listing All Routes

Get a list of all registered routes:
-listRoutes
Response: List of all registered routes with their status

Getting Route Template Code

Retrieve a template for a specific route type:
-routeCode <routeType>
Example:
-routeCode POSTGRESQL
Response: Template code with all available parameters for the route type

Removing All Routes

-removeAllRoutes
Response: All routes removed successfully

Diagnostics

Commands for troubleshooting and debugging LoT entities.

Running LoT Diagnostic

Run diagnostics on a specific entity:
-lotDiagnostic <entityType> <entityName>
Example:
-lotDiagnostic action MyAction
Response: Diagnostic information for the specified entity

Getting Pending Status

Check the status of pending models and actions:
-getPendingStatus
Response: Status of all pending models and actions

Python Integration Commands

Manage Python scripts within the broker for custom data processing.

Adding a Python Script

-addPython <scriptName> <code>
Example:
-addPython Calculator
# Script Name: Calculator

def add(a, b):
    return a + b

def multiply(a, b):
    return a * b
Response: Python script 'Calculator' added successfully
Python scripts must start with # Script Name: YourScriptName to be recognized by the system. The script name is used when calling Python functions from LoT actions using the CALL PYTHON syntax.

Removing a Python Script

-removePython <scriptName>
Example:
-removePython Calculator
Response: Python script 'Calculator' removed successfully

Installing Python Packages

Install additional Python packages via pip:
-installPythonPackage <packageName>
Example:
-installPythonPackage numpy
Response: Package 'numpy' installed successfully

Listing Installed Packages

View all installed Python packages:
-listPythonPackages
Response: List of all installed Python packages

Removing All Python Scripts

-removeAllPythonScripts
Response: All Python scripts removed successfully

System Commands

Trace Logging Commands

Trace logging allows you to capture and monitor specific log events in the Coreflux system.

Adding a Trace Log Point

-addTraceLog level=<Level>,lifetime=<Seconds>,messageContains=<Substring>,topic=<mqttTopic>
Parameters:
ParameterDescription
levelLog level: Debug, Information, Warning, Error, Fatal
lifetimeDuration in seconds before the trace point expires
messageContainsFilter logs containing this substring
topicMQTT topic where matching logs will be published
Example:
-addTraceLog level=Information,lifetime=3600,messageContains=sensor,topic=logs/sensors
This creates a trace point that:
  • Captures logs at Information level or higher
  • Automatically expires after 3600 seconds (1 hour)
  • Only captures logs containing “sensor”
  • Publishes matching logs to logs/sensors
Response: Trace log point added successfully

Listing Trace Log Points

View all active trace points:
-listTraceLogs
Response: List of all active trace log points

Removing a Trace Log Point

Remove a specific trace point by topic:
-removeTraceLog <topic>
Example:
-removeTraceLog logs/sensors
Response: Trace log point removed successfully

Removing All Trace Log Points

-removeAllTraceLogs
Response: All trace log points removed successfully

Connection Status

View the status of all database connections and their recovery patterns:
-connectionStatus
Response: Status of all database connections

Update Data

Trigger a refresh of broker data:
-updateData
Response: Data refresh triggered successfully

Command Authorization

Commands are subject to authorization rules defined in the broker. Not all users may have permission to execute all commands. See the Rules documentation for information on setting up access control.
Always ensure proper access control is configured before exposing the command topic to untrusted clients.

Next Steps