Transcript

© 2016 IBM Corporation

IBM Analytics

Informix MQTT Listener – new in 12.10.xC7

Shawn Moe – Architect, IBM AnalyticsJune 2016

© 2016 IBM Corporation2

Detailed Solution Architecture

• NoSQL ↔ SQL Translation

• Wire Listeners for MongoDB,

REST & MQTT protocols

• SQLI & DRDA Protocol Support

• Relational tables, JSON

Collections, Time Series, and

Spatial Data Support

REST Client

MongoDB

Client

SQLI Client

DRDA Client

MQTT Client

Informix

DBMS

Informix Wire

Listener

Spatial

Time Series

JSON Collection

Relational Table

© 2016 IBM Corporation3

MQTT Listener

MQTT (from http://mqtt.org/faq)

MQ Telemetry Transport

PUBlish-SUBscribe, extremely simple and lightweight messaging protocol, designed for

constrained devices and low-bandwidth, high-latency or unreliable networks

ideal for “machine-to-machine” (M2M) or “Internet of Things” (IoT) connected devices, and for

mobile applications where bandwidth and battery power are at a premium

Feature overview

In addition to the Mongo and REST listeners, there is now a new MQTT listener type in the

Informix Wire Listener that allows MQTT clients to publish data to Informix

Motivation

This feature is geared towards IOT environments where devices on the “edge” need an easy,

lightweight way to publish (insert) data into the Informix database server.

xC7

© 2016 IBM Corporation4

MQTT Listener

Wire Listenerlistener.type=mqtt

IOT

DeviceMQTT protocol:

PUBLISHJDBC:

INSERTIOT

Device

IOT

Device

IOT

Device

IOT

DevicexC7

© 2016 IBM Corporation5

MQTT Listener

Set listener.type=mqtt in the configuration file

The MQTT Listener only supports PUBLISHING data to a topic, which maps

to inserting data in the Informix database server

The MQTT Listener does NOT currently support SUBSCRIBE

xC7

© 2016 IBM Corporation6

MQTT PUBLISH

In MQTT, you PUBLISH to a topic name

The topic name should be in the format “dbname/tablename” which maps to the database and

table name where the data will be inserted

The MQTT Listener supports PUBLISH to collections, relational tables, and

timeseries tables where the data stored within the timeseries is BSON

The data in the payload of the MQTT PUBLISH message should be a JSON

string representation of the data to be inserted into the Informix database

xC7

© 2016 IBM Corporation7

MQTT PUBLISH

Publishing to a timeseries table

We only support publishing to a BSON timeseries – i.e. the timeseries row type must contain a

timestamp field and a single BSON field that contains the rest of the data.

The MQTT listener uses the Timeseries High Speed Loader routines to insert data into the

timeseries table on the database server

To configure the number of JDBC connections used for each timeseries table while loading data

through the Timeseries Loader routines, you can set timeseries.loader.connections in the

listener properties file

The default value is timeseries.loader.connections=10

The data sent in the MQTT payload must be in JSON format

It must contain the timeseries primary key column(s), the timestamp, and any fields to be included in the

BSON part of the timeseries

xC7

© 2016 IBM Corporation8

MQTT PUBLISH

Publishing to a collection

The data sent in the MQTT payload must in JSON format

The listener will convert this to a BSON document and use an INSERT prepared statement to

insert it into the collection table

Publishing to a relational table

The data sent in the MQTT payload must in JSON format, where the keys of the JSON

document must map to columns in the relational table

The listener will use an INSERT prepared statement to insert the data into the relational table

xC7

© 2016 IBM Corporation9

Authentication with MQTT

If authentication is enabled in the listener (authentication.enable=true), the

MQTT CONNECT packet must include the user name and password.

Because the listener requires that a user authenticates to a particular database, the username

must be in the format “dbname.username”

•CONNECT

•username “mydb.joe”

•password “pass4joe”

When connecting and authenticating users with the MQTT listener, you can

use MongoDB-CR authentication or Informix PAM authentication. You

cannot use the SCRAM-SHA1 authentication that is supported in the Mongo

listener typexC7

© 2016 IBM Corporation10

Sample Java Code

Some sample Java code for publishing to the MQTT listener, based on the Paho Java MQTT client

(https://eclipse.org/paho/clients/java/)

xC7

© 2016 IBM Corporation11

MQTT client libraries

MQTT libraries are available for most any programming language

See https://github.com/mqtt/mqtt.github.io/wiki/libraries for a list of MQTT

libraries by language

xC7