Skip to content

KxSystems/mqtt

Repository files navigation

MQTT mqtt - MQTT for kdb+

GitHub release (latest by date) Travis (.org) branch

This interface lets you communicate with an MQTT broker from a kdb+ session. The interface follows closely the PAHO MQTT C API. Exposed functionality includes

  • connect to a MQTT broker
  • subscribe to topics
  • publish to a broker

This is part of the Fusion for kdb+ interface collection.

New to kdb+ ?

Kdb+ is the world’s fastest timeseries database, optimized for ingesting, analyzing and storing massive amounts of structured data. To get started with kdb+, please visit https://code.kx.com/q/learn/ for downloads and developer information. For general information, visit https://kx.com/

New to MQTT ?

Message Queueing Telemetry Transport (MQTT) is a machine-to-machine/IOT connectivity protocol. It is designed to provide a lightweight publish/subscribe messaging protocol.

MQTT is used commonly for constrained devices with low-bandwidth, high-latency or unreliable networks.

Use cases

This messaging protocol is used extensively where a small software footprint is required, e.g.

  • communication with edge devices/sensors
  • home automation
  • mobile applications

🌐 MQTT: Real-world applications

API Documentation

👉 API reference

Installation Documentation

👉 Install guide

Debugging/Tracing

👉 The underlying Paho MQTT library provides the ability to log diagnostic information to standard out or log files via an environment variable as detailed here

Building From Source

👉 Building guide

Quick start

Requirements

To run the examples you will need a MQTT broker e.g.

Start Mosquitto

Start Mosquitto on default port localhost:1883.

sudo systemctl start mosquitto

Launch consumer

We assume you are in the source directory of the MQTT-kdb+ interface.

mqtt]$ cd q
q]$ q ../examples/consumer.q 

Launch producer

In the same directory as the one launching a consumer, run:

q]$ q ../examples/producer.q

Then pubish a message by a timer, say every second:

q)\t 1000

Going back to the console of consumer, now you can see received messages in .mqtt.tab:

q).mqtt.tab
topic  msg_sent                      msg_recv                      received_m..
-----------------------------------------------------------------------------..
topic1 2021.01.06D13:24:46.267356000 2021.01.06D13:24:46.267718000 topic1_3  ..
topic2 2021.01.06D13:24:46.267450000 2021.01.06D13:24:46.368412000 topic2_3  ..
topic1 2021.01.06D13:24:47.267366000 2021.01.06D13:24:47.268676000 topic1_4  ..
topic2 2021.01.06D13:24:47.267624000 2021.01.06D13:24:47.372268000 topic2_4  ..
topic1 2021.01.06D13:24:48.276623000 2021.01.06D13:24:48.277677000 topic1_5  ..
topic2 2021.01.06D13:24:48.276801000 2021.01.06D13:24:48.377926000 topic2_5  ..
topic1 2021.01.06D13:24:49.267324000 2021.01.06D13:24:49.268228000 topic1_6  ..
topic2 2021.01.06D13:24:49.267482000 2021.01.06D13:24:49.368805000 topic2_6  ..
topic1 2021.01.06D13:24:50.267684000 2021.01.06D13:24:50.268125000 topic1_7  ..
topic2 2021.01.06D13:24:50.267804000 2021.01.06D13:24:50.368889000 topic2_7  ..

Status

The interface is currently available under an Apache 2.0 license and is supported on a best-efforts basis by the KX Fusion team. The interface is currently in active development, with additional functionality released on an ongoing basis.

👉 Issues and feature requests

👉 Guide to contributing