Chii2 MQTT

MQTT Message Server

Download .zip Download .tar.gz View on GitHub

About Chii2 MQTT.

MQTT is a machine-to-machine (M2M)/"Internet of Things" connectivity protocol. It was designed as an extremely lightweight publish/subscribe messaging transport.
Chii2 MQTT provides full MQTT V3.1 Protocol Specification server side implementation. Chii2 MQTT is written purely in Java, designed to be lightweight fast reliable and extensible, it can run as message broker in standalone mode or embedded mode. The project is under Apache License v2.

Roadmap

Beta Release: 1.0.0 Snapshot

MQTT V3.1 Protocol Specification
        Connect              Completed
        Publish QoS 0        Completed
        Publish QoS 1        Completed
        Publish QoS 2        Completed
        Subscribe            Completed
        UnSubscribe          Completed
        Ping                 Completed
        Disconnect           Completed
        Retain               Completed
        Will                 Not Implemented
        Resend               Partially
        Keep Alive           Not Implemented
        Authorization        Not Implemented
        SSL                  Not Implemented

Bulid

Chii2 MQTT project using Maven as management and comprehension tool. To build project from source, you need to install maven on your system. Then clone the source code from github, and run following command:

$ mvn clean install

Chii2 MQTT has following dependencies:commons-lang3,commons-dbutils,netty,disruptor,derby,slf4j

Running in OSGi

Chii2 MQTT is designed to be OSGi compatible, project has provided a sample OSGi server. To build and run the sample:

$ mvn clean install
$ cd assembly
$ java -jar bin/felix.jar

The derby storage package (bundle) already configured with Blueprint, an IoC container similar to Spring. The sample server also using Blueprint to inject derby storage. The init and destroy method are called from Blueprint life cycle management:

/**
 * Sample OSGi Server
 */
public class OSGiServer {

    // MQTT Server Configuration
    private MQTTServerConfiguration brokerConfiguration;
    // MQTT Server Storage
    private StorageService brokerStorage;
    // MQTT Broker
    private MQTTServer broker;
    // The Logger
    private final Logger logger = LoggerFactory.getLogger(OSGiServer.class);

    /**
     * Injected Storage Service
     */
    public void setBrokerStorage(StorageService brokerStorage) {
        this.brokerStorage = brokerStorage;
    }

    /**
     * OSGi life cycle init
     */
    public void init() {
        logger.info("Chii2 MQTT Server Init.");
        // Init MQTT Server Configuration
        brokerConfiguration = new MQTTServerConfiguration();
        brokerConfiguration.setServerName("Chii2 MQTT Server");
        // Init MQTT Server
        broker = new MQTTServer(brokerConfiguration, brokerStorage);
        broker.start();
    }

    /**
     * OSGi life cycle destroy
     */
    public void destroy() {
        logger.info("Chii2 MQTT Server Destroy.");
        broker.stop();
    }

If you don't want to use Blueprint, you can declare the derby storage manually with the same way as running Chii2 MQTT embedded.

Compatible Clients

Chii2 MQTT is tested with Eclipse Paho MQTT client library.

Author

Gu Dongxu (@longkerdandy) can be reached at longkerdandy@gmail.com.
PS: The author is available to hire at Shanghai, China.