• Stars
    star
    2,000
  • Rank 22,218 (Top 0.5 %)
  • Language
    Java
  • License
    Other
  • Created over 8 years ago
  • Updated 4 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Eclipse Paho Java MQTT client library. Paho is an Eclipse IoT project.

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();
        }
    }
}

More Repositories

1

mosquitto

Eclipse Mosquitto - An open source MQTT broker
C
7,649
star
2

che

Kubernetes based Cloud Development Environments for Enterprise Teams
TypeScript
6,868
star
3

jetty.project

Eclipse Jetty® - Web Container & Clients - supports HTTP/2, HTTP/1.1, HTTP/1.0, websocket, servlets, and more
Java
3,655
star
4

paho.mqtt.android

MQTT Android
Java
2,708
star
5

paho.mqtt.golang

Go
2,381
star
6

eclipse-collections

Eclipse Collections is a collections framework for Java with optimized data structures and a rich, functional and fluent API.
Java
2,283
star
7

paho.mqtt.python

paho.mqtt.python
Python
1,946
star
8

sumo

Eclipse SUMO is an open source, highly portable, microscopic and continuous traffic simulation package designed to handle large networks. It allows for intermodal simulation including pedestrians and comes with a large set of tools for scenario creation.
1,902
star
9

paho.mqtt.c

An Eclipse Paho C client library for MQTT for Windows, Linux and MacOS. API documentation: https://eclipse.github.io/paho.mqtt.c/
C
1,736
star
10

eclipse.jdt.ls

Java language server
Java
1,410
star
11

mraa

Linux Library for low speed IO Communication in C with bindings for C++, Python, Node.js & Java. Supports generic io platforms, as well as Intel Edison, Intel Joule, Raspberry Pi and many more.
C
1,349
star
12

paho.mqtt.embedded-c

Paho MQTT C client library for embedded systems. Paho is an Eclipse IoT project (https://iot.eclipse.org/)
C
1,271
star
13

paho.mqtt.javascript

paho.mqtt.javascript
JavaScript
1,115
star
14

openvsx

An open-source registry for VS Code extensions
Java
1,059
star
15

milo

Eclipse Miloâ„¢ - an open source implementation of OPC UA (IEC 62541).
Java
976
star
16

omr

Eclipse OMRâ„¢ Cross platform components for building reliable, high performance language runtimes
C++
917
star
17

paho.mqtt.cpp

C++
875
star
18

xtext

Eclipse Xtextâ„¢ is a language development framework
Java
715
star
19

upm

UPM is a high level repository that provides software drivers for a wide variety of commonly used sensors and actuators. These software drivers interact with the underlying hardware platform through calls to MRAA APIs.
C++
651
star
20

microprofile

Repository for important documentation - the index to the project / community
Java
635
star
21

californium

CoAP/DTLS Java Implementation
Java
620
star
22

leshan

Java Library for LWM2M
Java
614
star
23

paho.mqtt-spy

mqtt-spy is an open source desktop & command line utility intended to help you with monitoring activity on MQTT topics
Java
605
star
24

jkube

Build and Deploy java applications on Kubernetes
Java
593
star
25

steady

Analyses your Java applications for open-source dependencies with known vulnerabilities, using both static analysis and testing to determine code context and usage for greater accuracy. https://eclipse.github.io/steady/
Java
516
star
26

sprotty

A diagramming framework for the web
TypeScript
514
star
27

buildship

The Eclipse Plug-ins for Gradle project.
Java
507
star
28

paho.mqtt.m2mqtt

C#
495
star
29

lsp4j

A Java implementation of the language server protocol intended to be consumed by tools and language servers implemented in Java.
Java
473
star
30

kura

Eclipse Kuraâ„¢ project
Java
469
star
31

wakaama

Eclipse Wakaama is a C implementation of the Open Mobile Alliance's LightWeight M2M protocol (LWM2M).
C
465
star
32

streamsheets

An open-source tool for processing stream data using a spreadsheet-like interface.
JavaScript
441
star
33

paho.mqtt.rust

paho.mqtt.rust
Rust
422
star
34

jifa

🔬 Online Heap Dump, GC Log & Thread Dump Analyzer. Make troubleshooting easy.
Java
421
star
35

hawkbit

Eclipse hawkBitâ„¢
Java
416
star
36

eclipse-collections-kata

Eclipse Collections Katas
Java
411
star
37

hono

Eclipse Honoâ„¢ Project
Java
378
star
38

repairnator

Software development bots for Github. Join the bot revolution! 🌟🤖🌟💞
Java
370
star
39

ponte

Ponte Project
JavaScript
360
star
40

birt

Eclipse BIRTâ„¢ The open source reporting and data visualization project.
Java
355
star
41

rdf4j

Eclipse RDF4J: scalable RDF for Java
Java
323
star
42

paho.mqtt-sn.embedded-c

Paho C MQTT-SN gateway and libraries for embedded systems. Paho is an Eclipse IoT project.
C++
305
star
43

paho.golang

Go libraries
Go
269
star
44

lemminx

XML Language Server
Java
242
star
45

vorto

Vorto Project
Java
221
star
46

kapua

Java
218
star
47

elk

Eclipse Layout Kernel - Automatic layout for Java applications.
Java
211
star
48

jnosql

Eclipse JNoSQL is a framework which has the goal to help Java developers to create Jakarta EE applications with NoSQL.
Java
210
star
49

corrosion

Eclipse Corrosion - Rust edition in Eclipse IDE
Java
199
star
50

capella

Open Source Solution for Model-Based Systems Engineering
Java
197
star
51

dirigible

Eclipse Dirigibleâ„¢ Project
JavaScript
196
star
52

tahu

Eclipse Tahu addresses the existence of legacy SCADA/DCS/ICS protocols and infrastructures and provides a much-needed definition of how best to apply MQTT into these existing industrial operational environments.
Java
196
star
53

microprofile-config

MicroProfile Configuration Feature
Java
182
star
54

wildwebdeveloper

Simple and productive Web Development Tools in the Eclipse IDE
Java
181
star
55

pdt

PHP Development Tools project (PDT)
PHP
178
star
56

org.aspectj

Java
172
star
57

xacc

XACC - eXtreme-scale Accelerator programming framework
C++
137
star
58

thingweb.node-wot

thingweb.node-wot
TypeScript
130
star
59

microprofile-rest-client

MicroProfile Rest Client
Java
124
star
60

tycho

Tycho project repository (tycho)
Java
119
star
61

microprofile-conference

Microprofile.io Demo Code - Web Services Conference Application
Java
117
star
62

microprofile-fault-tolerance

microprofile fault tolerance
Java
115
star
63

microprofile-samples

Micro Profile Samples
Java
115
star
64

xtext-core

xtext-core
Java
114
star
65

microprofile-open-api

Microprofile open api
Java
112
star
66

gef

Eclipse GEFâ„¢
Java
111
star
67

jbom

Java
104
star
68

paho.mqtt.testing

An Eclipse Paho project - a Python broker for testing
Python
104
star
69

xtext-xtend

xtext-xtend
Java
100
star
70

transformer

Eclipse Transformer provides tools and runtime components that transform Java binaries, such as individual class files and complete JARs and WARs, mapping changes to Java packages, type names, and related resource names.
Java
97
star
71

microprofile-health

microprofile-health
Java
95
star
72

microprofile-metrics

microprofile-metrics
Java
94
star
73

microprofile-graphql

microprofile-graphql
Java
93
star
74

sw360

SW360 project
Java
92
star
75

microprofile-jwt-auth

Java
92
star
76

tinydtls

Eclipse tinydtls
C
92
star
77

microprofile-lra

microprofile-lra
Java
90
star
78

mosaic

Eclipse MOSAIC is a Multi-Domain and Multi-Scale Simulation Framework for Automated and Connected Mobility Scenarios.
Java
81
star
79

kuksa.val

kuksa.val
Rust
80
star
80

nebula

Nebula Project
Java
79
star
81

microprofile-reactive-streams-operators

Microprofile project
Java
75
star
82

mosquitto.rsmb

Mosquitto rsmb
C
75
star
83

microprofile-starter

MicroProfile project generator source code
Java
68
star
84

aCute

Eclipse aCute - C# edition in Eclipse IDE
Java
65
star
85

ditto-examples

Eclipse Dittoâ„¢: Digital Twin framework - Examples
Java
63
star
86

tm4e

TextMate support in Eclipse IDE
Java
60
star
87

californium.tools

Californium project
Java
59
star
88

microprofile-opentracing

microprofile-opentracing
Java
57
star
89

microprofile-reactive-messaging

Java
57
star
90

eclemma

🌘 Java Code Coverage for Eclipse IDE
Java
57
star
91

texlipse

Eclipse Texlipse
Java
56
star
92

dartboard

Dart Plugin for Eclipse
Java
55
star
93

jnosql-databases

This project contains Eclipse JNoSQL databases
Java
54
star
94

windowbuilder

Eclipse Windowbuilder
Java
54
star
95

lsp4e

Language Server Protocol support in Eclipse IDE
Java
53
star
96

mita

mita
Xtend
53
star
97

xtext-eclipse

xtext-eclipse
Java
49
star
98

che-che4z-lsp-for-cobol

COBOL Language Support provides autocomplete, highlighting and diagnostics for COBOL code and copybooks
COBOL
46
star
99

packages

IoT Packages project
Smarty
44
star
100

winery

Eclipse Winery project
Java
44
star