GithubHelp home page GithubHelp logo

todorokikohei / mqttv5-client Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 5.41 MB

MQTT Version5.0のクライアント実装を拡張する

License: Other

HTML 0.55% Java 99.36% Shell 0.06% Batchfile 0.02% Dockerfile 0.01%

mqttv5-client's Introduction

元のリポジトリ

https://github.com/eclipse/paho.mqtt.java

Eclipse Paho Java Client

Build Status

The Paho Java Client is an MQTT client library written in Java for developing applications that run on the JVM or other Java compatible platforms such as Android

The Paho Java Client provides two APIs: MqttAsyncClient provides a fully asynchronous API where completion of activities is notified via registered callbacks. MqttClient is a synchronous wrapper around MqttAsyncClient where functions appear synchronous to the application.

Project description:

The Paho project has been created to provide reliable open-source implementations of open and standard messaging protocols aimed at new, existing, and emerging applications for Machine-to-Machine (M2M) and Internet of Things (IoT). Paho reflects the inherent physical and cost constraints of device connectivity. Its objectives include effective levels of decoupling between devices and applications, designed to keep markets open and encourage the rapid growth of scalable Web and Enterprise middleware and applications.

Links

Using the Paho Java Client

Downloading

Eclipse hosts a Nexus repository for those who want to use Maven to manage their dependencies. The released libraries are also available in the Maven Central repository.

Add the repository definition and the dependency definition shown below to your pom.xml.

Replace %REPOURL% with either https://repo.eclipse.org/content/repositories/paho-releases/ for the official releases, or https://repo.eclipse.org/content/repositories/paho-snapshots/ for the nightly snapshots. Replace %VERSION% with the level required .

The latest release version is 1.2.5 and the current snapshot version is 1.2.6-SNAPSHOT.

** Dependency definition for MQTTv3 client **

<project ...>
<repositories>
    <repository>
        <id>Eclipse Paho Repo</id>
        <url>%REPOURL%</url>
    </repository>
</repositories>
...
<dependencies>
    <dependency>
        <groupId>org.eclipse.paho</groupId>
        <artifactId>org.eclipse.paho.client.mqttv3</artifactId>
        <version>%VERSION%</version>
    </dependency>
</dependencies>
</project>

** Dependency definition for MQTTv5 client **

<project ...>
<repositories>
    <repository>
        <id>Eclipse Paho Repo</id>
        <url>%REPOURL%</url>
    </repository>
</repositories>
...
<dependencies>
    <dependency>
        <groupId>org.eclipse.paho</groupId>
        <artifactId>org.eclipse.paho.mqttv5.client</artifactId>
        <version>%VERSION%</version>
    </dependency>
</dependencies>
</project>

If you find that there is functionality missing or bugs in the release version, you may want to try using the snapshot version to see if this helps before raising a feature request or an issue.

Building from source

There are two active branches on the Paho Java git repository, master which is used to produce stable releases, and develop where active development is carried out. By default cloning the git repository will download the master branch, to build from develop make sure you switch to the remote branch: git checkout -b develop remotes/origin/develop

To then build the library run the following maven command: mvn package -DskipTests

This will build the client library without running the tests. The jars for the library, source and javadoc can be found in the following directories:

org.eclipse.paho.client.mqttv3/target
org.eclipse.paho.mqttv5.client/target

Documentation

MQTTv3 reference documentation is online at: http://www.eclipse.org/paho/files/javadoc/index.html

Log and Debug in the Java Client: https://wiki.eclipse.org/Paho/Log_and_Debug_in_the_Java_client

Getting Started

The included code below is a very basic sample that connects to a server and publishes a message using the MQTTv3 synchronous API. More extensive samples demonstrating the use of the MQTTv3 and MQTTv5 Asynchronous API can be found in the org.eclipse.paho.sample directory of the source.

import org.eclipse.paho.client.mqttv3.MqttClient;
import org.eclipse.paho.client.mqttv3.MqttConnectOptions;
import org.eclipse.paho.client.mqttv3.MqttException;
import org.eclipse.paho.client.mqttv3.MqttMessage;
import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence;

public class MqttPublishSample {

    public static void main(String[] args) {

        String topic        = "MQTT Examples";
        String content      = "Message from MqttPublishSample";
        int qos             = 2;
        String broker       = "tcp://iot.eclipse.org:1883";
        String clientId     = "JavaSample";
        MemoryPersistence persistence = new MemoryPersistence();

        try {
            MqttClient sampleClient = new MqttClient(broker, clientId, persistence);
            MqttConnectOptions connOpts = new MqttConnectOptions();
            connOpts.setCleanSession(true);
            System.out.println("Connecting to broker: "+broker);
            sampleClient.connect(connOpts);
            System.out.println("Connected");
            System.out.println("Publishing message: "+content);
            MqttMessage message = new MqttMessage(content.getBytes());
            message.setQos(qos);
            sampleClient.publish(topic, message);
            System.out.println("Message published");
            sampleClient.disconnect();
            System.out.println("Disconnected");
            System.exit(0);
        } catch(MqttException me) {
            System.out.println("reason "+me.getReasonCode());
            System.out.println("msg "+me.getMessage());
            System.out.println("loc "+me.getLocalizedMessage());
            System.out.println("cause "+me.getCause());
            System.out.println("excep "+me);
            me.printStackTrace();
        }
    }
}

mqttv5-client's People

Contributors

jpwsutton avatar rdasgupt avatar zyyangbj avatar icraggs avatar andypiper avatar orpiske avatar ogis-yamazaki avatar powturns avatar hmvp avatar miketran78727 avatar mcarrer avatar ctron avatar hylkevds avatar bisk1 avatar silh avatar maxpagani avatar henry-lp avatar vit21ik avatar todorokikohei avatar rehanshaukat avatar pavelanikeichyk avatar msqr avatar sp193 avatar jarthorn avatar dobermai avatar david-katz avatar aploese avatar oreillymj avatar desokroshan avatar satyadeepk avatar

Watchers

 avatar

mqttv5-client's Issues

パケットフォーマットの拡張

PINGREQに任意のデータを付加できるようにする。

  • ペイロードの追加
  • 可変ヘッダの追加
  • UserPropertyを可変ヘッダに追加可能に

拡張したPINGREQで分散配信を制御できるかを検証する

PINGREQのペイロードに送信可能かを識別するフラグを付加して送信する実装を行った。このフラグが正常に働くかを確認するために、以下の作業を実施する。

  • 複数のサブスクライバで共有サブスクリプションを実行する検証アプリを実装
  • PINGREQのペイロードをメインスレッドから動的に変更するためのインターフェースを実装
  • 途中で1台のサブスクライバを送信不可能にして検証

PINGREQの送信タイミングを拡張する

PINGREQを一定間隔で送信してBrokerとの情報交換を実現する。そのために、以下のタスクを実行する。

  • PINGREQの送信タイミングの確認
  • 一定間隔でPINGREQを送信を実装
  • パラメータでPINGREQの送信間隔を設定可能に

コンテナ環境での評価クライアントの実装

大量のデータ処理を実行するクライアントでの実行結果記録処理を実装

  • パブリッシャとサブスクライバの実装分離

    • 引数でパブリッシャ,サブスクライバを指定
  • サブスクライバの実装

    • 処理したデータの記録処理
    • 実行結果を非同期にファイル出力する処理
    • PINGREQ送信時の処理状況の記録処理
  • パブリッシャの実装

    • Executerを利用した指定帯域での送信処理

送信データ取得の実装

  • キュー内のメッセージ数とメッセージ処理時間を取得する手段を実装
  • PINGREQのペイロードに上記2つのデータをJSON形式で設定して送信する処理を実装

PINGREQで送信できるデータを拡張する

PINGREQにSubscriberの情報を付加することでBrokerの分散配信を高度化する。そのために、以下のタスクを実行する。

  • PINGREQのペイロードに任意のデータを送信できるようにする

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.