Skip to content

Commit 9a315e3

Browse files
author
Ranjan Dasgupta
authored
Merge branch 'develop' into feature/skip_port
2 parents fbf9544 + f12b693 commit 9a315e3

210 files changed

Lines changed: 2330 additions & 3718 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/ISSUE_TEMPLATE.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
Please fill out the form below before submitting, thank you!
22

3-
- [ ] Bug exists Release Version 1.2.3 ( Master Branch)
4-
- [ ] Bug exists in MQTTv3 Client on Snapshot Version 1.2.4-SNAPSHOT (Develop Branch)
5-
- [ ] Bug exists in MQTTv5 Client on Snapshot Version 1.2.3-SNAPSHOT (Develop Branch)
3+
- [ ] Bug exists Release Version 1.2.5 ( Master Branch)
4+
- [ ] Bug exists in MQTTv3 Client on Snapshot Version 1.2.6-SNAPSHOT (Develop Branch)
5+
- [ ] Bug exists in MQTTv5 Client on Snapshot Version 1.2.6-SNAPSHOT (Develop Branch)
66

77

88
If this is a bug regarding the Android Service, please raise the bug here instead: https://github.com/eclipse/paho.mqtt.android/issues/new

.github/workflows/main.yaml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Workflow to build mqtt.paho.java library
2+
3+
name: Java CI
4+
5+
on:
6+
push:
7+
branches: [ master ]
8+
pull_request:
9+
branches: [ master ]
10+
11+
workflow_dispatch:
12+
13+
jobs:
14+
build:
15+
runs-on: ${{ matrix.os }}
16+
strategy:
17+
matrix:
18+
# os: [ubuntu-latest, macOS-latest, windows-latest]
19+
# java: [ 8.0.192, 8, 11.0.3, 17, 18-ea ]
20+
os: [ubuntu-latest]
21+
java: [ 8.0.192 ]
22+
fail-fast: false
23+
max-parallel: 4
24+
name: Build MQTT Paho Java on JDK ${{ matrix.java }}, ${{ matrix.os }}
25+
steps:
26+
- uses: actions/checkout@v2
27+
- name: Set up JDK ${{ matrix.java }} ${{ matrix.os }}
28+
uses: actions/setup-java@v1
29+
with:
30+
java-version: ${{ matrix.java }}
31+
java-package: jdk
32+
- name: Package with Maven skip tests
33+
run: mvn -B package --file pom.xml -DskipTests
34+

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,10 @@ target/
6262

6363

6464
*.log.*
65+
66+
# Test files
67+
Bug443142Test-*-tcplocalhost*
68+
client-1-tcpioteclipseorg1882
69+
testConnectTimeout
70+
71+

.travis.yml

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,18 @@
1-
sudo: true
1+
sudo: required
22
language: java
33
install: true
4-
matrix:
4+
5+
jobs:
56
include:
67
- os: linux
78
dist: trusty
8-
sudo: required
99
jdk: oraclejdk8
10-
# - os: osx
11-
# jdk: oraclejdk8
12-
13-
14-
15-
16-
sudo: required
1710

1811
before_install:
1912
- ./start-broker.sh
2013

2114
script:
2215
- mvn -B clean -q
2316
- mvn -B --projects org.eclipse.paho.client.mqttv3,org.eclipse.paho.client.mqttv3.test test -q
24-
# - mvn -B --projects org.eclipse.paho.mqttv5.common,org.eclipse.paho.mqttv5.client,org.eclipse.paho.mqttv5.client.test test -q
17+
- mvn -B --projects org.eclipse.paho.mqttv5.client,org.eclipse.paho.mqttv5.client.test test -q
2518

26-
#addons:
27-
# apt:
28-
# sources:
29-
# - sourceline: 'ppa:mosquitto-dev/mosquitto-ppa'
30-
# packages:
31-
# - mosquitto

MQTTv3.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ Add the repository definition and the dependency definition shown below to your
1212

1313
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 .
1414

15-
The latest release version is ```1.2.4``` and the current snapshot version is ```1.2.5-SNAPSHOT```.
16-
15+
The latest release version is ```1.2.5``` and the current snapshot version is ```1.2.6-SNAPSHOT```.
1716

1817
```
1918
<project ...>
@@ -108,10 +107,10 @@ The included code below is a extended basic sample that connects to a server wit
108107
MqttClient client = new MqttClient("wss://<BROKER_URI>", "MyClient");
109108
110109
MqttConnectOptions connectOptions = new MqttConnectOptions();
111-
Properties properties = new Properties();
112-
properties.setProperty("X-Amz-CustomAuthorizer-Name", <SOME_VALUE>);
113-
properties.setProperty("X-Amz-CustomAuthorizer-Signature", <SOME_VALUE>);
114-
properties.setProperty(<SOME_VALUE>, <SOME_VALUE>);
110+
Map<String, String> properties = new HashMap<>();
111+
properties.put("X-Amz-CustomAuthorizer-Name", <SOME_VALUE>);
112+
properties.put("X-Amz-CustomAuthorizer-Signature", <SOME_VALUE>);
113+
properties.put(<SOME_KEY>, <SOME_VALUE>);
115114
connectOptions.setCustomWebSocketHeaders(properties);
116115
117116
client.connect(connectOptions);

MQTTv5.md

Lines changed: 94 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,105 @@
11
# Eclipse Paho Java Client for MQTTv5
22

3-
_Warning: The Paho MQTTv5 client is under active development and so can expect breaking changes whilst in the develop branch._
3+
The v5 client is build on the same foundations as the v3 client is, however it is being heavily refactored using lessons learnt from the v3 client and feedback from the community. Like v3 client, the Paho Java Client provides two APIs: MqttAsyncClient provides a fully asychronous API where completion of activities is notified via registered callbacks. MqttClient is a synchronous wrapper around MqttAsyncClient where functions appear synchronous to the application.
44

5-
This branch of the Paho Java client is the home of the new MQTTv5 client implementation. This is very much a work in progress, so any feedback / and contributions will be appreciated.
5+
## Using the Paho Java MQTTv5 Client
66

7-
The Committee Specification for MQTT Version 5.0 is available to read here: http://docs.oasis-open.org/mqtt/mqtt/v5.0/cs01/mqtt-v5.0-cs01.html.
7+
### Downloading
88

9-
The v5 client is build on the same foundations as the v3 client is, however it is targeting Java 8 and above, allowing us to take advantages of more modern Java APIs to aid development and use. Any important fixes for the core engine can be ported between the two clients to take advantage of any performance or stability improvements. It is also being heavily refactored using lessons learnt from the v3 client and feedback from the community.
9+
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.
1010

11-
## Plan
11+
Add the repository definition and the dependency definition shown below to your pom.xml.
1212

13-
#### Project Modules:
14-
* `org.eclipse.paho.mqttv5.client` - A full client similar to the existing mqttv3 client
15-
* `org.eclipse.paho.mqttv5.common` - A common library that could be used by both a client and server, contains a packet implementation that encodes and decodes all MQTTv5 packet types.
16-
* `org.eclipse.paho.mqttv5.testClient` - A number of examples written that show off features of the v5 client.
17-
* `org.eclipse.paho.mqttv5.server` - Not yet implemented. There has been some interest in the community for a Java MQTTv5 server using the vert.x framework. Contributions are very welcome.
13+
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 .
1814

19-
## Help, something doesn't work! / This looks terrible! / What about x!
15+
The latest release version is ```1.2.5``` and the current snapshot version is ```1.2.6-SNAPSHOT```.
2016

21-
This client is under active development and as such may be incomplete / broken a lot of the time right now. However, the more feedback and help we get on it, the better it will get! If you have any issues, please raise a bug against the client [here](https://github.com/eclipse/paho.mqtt.java/issues), but **please** prefix it with 'MQTTv5' so we know that it's not an issue with the current v3.1.1 client.
17+
```
18+
<project ...>
19+
<repositories>
20+
<repository>
21+
<id>Eclipse Paho Repo</id>
22+
<url>%REPOURL%</url>
23+
</repository>
24+
</repositories>
25+
...
26+
<dependencies>
27+
<dependency>
28+
<groupId>org.eclipse.paho</groupId>
29+
<artifactId>org.eclipse.paho.mqttv5.client</artifactId>
30+
<version>%VERSION%</version>
31+
</dependency>
32+
</dependencies>
33+
</project>
2234
23-
If you have any ideas about how the API should be designed going forward, then please chip in on [this](https://github.com/eclipse/paho.mqtt.java/issues/389) issue.
35+
```
36+
37+
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.
38+
39+
### Building from source
40+
41+
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 ```
42+
43+
To then build the library run the following maven command: ```mvn package -DskipTests```
44+
45+
This will build the client library without running the tests. The jars for the library, source and javadoc can be found in the ```org.eclipse.paho.mqttv5.client/target``` directory.
46+
47+
## Documentation
48+
Reference documentation is online at: [http://www.eclipse.org/paho/files/javadoc/index.html](http://www.eclipse.org/paho/files/javadoc/index.html)
49+
50+
Log and Debug in the Java Client: [https://wiki.eclipse.org/Paho/Log_and_Debug_in_the_Java_client](https://wiki.eclipse.org/Paho/Log_and_Debug_in_the_Java_client)
51+
52+
## Getting Started
53+
54+
The included code below is a very basic sample that connects to a server and publishes a message using the MqttClient asynchronous API. More extensive samples demonstrating the use of the Asynchronous API will be added in the ```org.eclipse.paho.sample.mqttv5app``` directory of the source soon.
55+
56+
57+
```
58+
import org.eclipse.paho.mqttv5.client.MqttAsyncClient;
59+
import org.eclipse.paho.mqttv5.client.MqttConnectionOptions;
60+
import org.eclipse.paho.mqttv5.client.IMqttToken;
61+
import org.eclipse.paho.mqttv5.client.persist.MemoryPersistence;
62+
import org.eclipse.paho.mqttv5.common.MqttException;
63+
import org.eclipse.paho.mqttv5.common.MqttMessage;
64+
import org.eclipse.paho.mqttv5.common.packet.MqttProperties;
65+
66+
public class MqttPublishSample {
67+
68+
public static void main(String[] args) {
69+
70+
String topic = "MQTT Examples";
71+
String content = "Message from MqttPublishSample";
72+
int qos = 2;
73+
String broker = "tcp://iot.eclipse.org:1883";
74+
String clientId = "JavaSample";
75+
MemoryPersistence persistence = new MemoryPersistence();
76+
77+
try {
78+
MqttConnectionOptions connOpts = new MqttConnectionOptions();
79+
connOpts.setCleanStart(false);
80+
MqttAsyncClient sampleClient = new MqttAsyncClient(broker, clientId, persistence);
81+
System.out.println("Connecting to broker: " + broker);
82+
IMqttToken token = sampleClient.connect(connOpts);
83+
token.waitForCompletion();
84+
System.out.println("Connected");
85+
System.out.println("Publishing message: "+content);
86+
MqttMessage message = new MqttMessage(content.getBytes());
87+
message.setQos(qos);
88+
token = sampleClient.publish(topic, message);
89+
token.waitForCompletion();
90+
System.out.println("Disconnected");
91+
System.out.println("Close client.");
92+
sampleClient.close();
93+
System.exit(0);
94+
} catch(MqttException me) {
95+
System.out.println("reason "+me.getReasonCode());
96+
System.out.println("msg "+me.getMessage());
97+
System.out.println("loc "+me.getLocalizedMessage());
98+
System.out.println("cause "+me.getCause());
99+
System.out.println("excep "+me);
100+
me.printStackTrace();
101+
}
102+
}
103+
}
104+
```
24105

25-
And of course, if you think of an amazing new feature for the v5 client, have a go at implementing it and submit a Pull Request against the develop branch!

README.md

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ Add the repository definition and the dependency definition shown below to your
3232

3333
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 .
3434

35-
The latest release version is ```1.2.4``` and the current snapshot version is ```1.2.5-SNAPSHOT```.
36-
35+
The latest release version is ```1.2.5``` and the current snapshot version is ```1.2.6-SNAPSHOT```.
3736

37+
** Dependency definition for MQTTv3 client **
3838
```
3939
<project ...>
4040
<repositories>
@@ -52,7 +52,26 @@ The latest release version is ```1.2.4``` and the current snapshot version is ``
5252
</dependency>
5353
</dependencies>
5454
</project>
55+
```
5556

57+
** Dependency definition for MQTTv5 client **
58+
```
59+
<project ...>
60+
<repositories>
61+
<repository>
62+
<id>Eclipse Paho Repo</id>
63+
<url>%REPOURL%</url>
64+
</repository>
65+
</repositories>
66+
...
67+
<dependencies>
68+
<dependency>
69+
<groupId>org.eclipse.paho</groupId>
70+
<artifactId>org.eclipse.paho.mqttv5.client</artifactId>
71+
<version>%VERSION%</version>
72+
</dependency>
73+
</dependencies>
74+
</project>
5675
```
5776

5877
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.
@@ -63,16 +82,20 @@ There are two active branches on the Paho Java git repository, ```master``` whic
6382

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

66-
This will build the client library without running the tests. The jars for the library, source and javadoc can be found in the ```org.eclipse.paho.client.mqttv3/target``` directory.
85+
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:
86+
```
87+
org.eclipse.paho.client.mqttv3/target
88+
org.eclipse.paho.mqttv5.client/target
89+
```
6790

6891
## Documentation
69-
Reference documentation is online at: [http://www.eclipse.org/paho/files/javadoc/index.html](http://www.eclipse.org/paho/files/javadoc/index.html)
92+
MQTTv3 reference documentation is online at: [http://www.eclipse.org/paho/files/javadoc/index.html](http://www.eclipse.org/paho/files/javadoc/index.html)
7093

7194
Log and Debug in the Java Client: [https://wiki.eclipse.org/Paho/Log_and_Debug_in_the_Java_client](https://wiki.eclipse.org/Paho/Log_and_Debug_in_the_Java_client)
7295

7396
## Getting Started
7497

75-
The included code below is a very basic sample that connects to a server and publishes a message using the MqttClient synchronous API. More extensive samples demonstrating the use of the Asynchronous API can be found in the ```org.eclipse.paho.sample.mqttv3app``` directory of the source.
98+
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.
7699

77100

78101
```

build.gradle

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/*
2+
* This file was generated by the Gradle 'init' task.
3+
*
4+
* This generated file contains a sample Java project to get you started.
5+
* For more details take a look at the Java Quickstart chapter in the Gradle
6+
* User Manual available at https://docs.gradle.org/6.0.1/userguide/tutorial_java_projects.html
7+
*/
8+
9+
plugins {
10+
id 'java'
11+
12+
id 'application'
13+
}
14+
15+
compileJava {
16+
options.compilerArgs << '-Xlint:deprecation'
17+
options.compilerArgs << '-Xlint:unchecked'
18+
}
19+
20+
version = '1.0.0'
21+
22+
repositories {
23+
mavenCentral()
24+
}
25+
26+
def tempDir = file("tmp")
27+
28+
task createTmpdir() {
29+
delete tempDir
30+
tempDir.mkdirs()
31+
}
32+
33+
test.dependsOn createTmpdir
34+
35+
configurations {
36+
libs
37+
}
38+
39+
dependencies {
40+
libs 'org.json:json:20211205'
41+
libs 'org.apache.commons:commons-jcs3-core:3.0'
42+
libs 'org.apache.commons:commons-csv:1.9.0'
43+
libs 'commons-net:commons-net:3.0.1'
44+
libs 'com.fasterxml.jackson.core:jackson-databind:2.13.0'
45+
libs 'com.ibm.db2:jcc:11.5.0.0'
46+
libs 'org.eclipse.paho:org.eclipse.paho.mqttv5.client:1.2.5'
47+
48+
testImplementation 'junit:junit:4.13.1'
49+
50+
configurations.implementation.extendsFrom(configurations.libs)
51+
}
52+
53+
task getDeps(type: Copy) {
54+
from sourceSets.main.runtimeClasspath
55+
into 'libs/'
56+
}
57+
58+
application {
59+
mainClassName = 'com.ibm.mas.scada.historian.connector.Connector'
60+
}
61+
62+
test {
63+
useJUnit()
64+
}
65+

0 commit comments

Comments
 (0)