Skip to content

Commit 07755c4

Browse files
author
Ian Craggs
committed
Merge branch 'develop'
2 parents 6d7aafd + 87e570b commit 07755c4

512 files changed

Lines changed: 44389 additions & 27352 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.

.gitattributes

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Set the default behavior, in case people don't have core.autocrlf set.
2+
#* text=auto
3+
4+
# Explicitly declare text files you want to always be normalized and converted
5+
# to native line endings on checkout.
6+
*.java text
7+
*.xml text
8+
*.md text
9+
*.html text
10+
*.yml text
11+
*.sh text
12+
13+
*.class binary
14+
*.jar binary
15+
*.png binary

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,6 @@ Icon
5959
# Maven
6060
log/
6161
target/
62+
63+
64+
*.log.*

.travis.yml

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,31 @@
11
sudo: true
22
language: java
3-
3+
install: true
44
matrix:
55
include:
66
- os: linux
77
dist: trusty
88
sudo: required
9+
jdk: oraclejdk8
910
# - os: osx
11+
# jdk: oraclejdk8
12+
13+
14+
1015

1116
sudo: required
1217

1318
before_install:
14-
- ./travis-install.sh
19+
- ./start-broker.sh
1520

16-
script: mvn --projects org.eclipse.paho.client.mqttv3,org.eclipse.paho.client.mqttv3.test test -Dtest.server_ssl_port=18885 -Dtest.server_uri=tcp://localhost:1883 -Dtest.server_websocket_uri=ws://localhost:8080 -B
21+
script:
22+
- mvn -B clean -q
23+
- 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
1725

18-
addons:
19-
apt:
20-
sources:
21-
- sourceline: 'ppa:mosquitto-dev/mosquitto-ppa'
22-
packages:
23-
- mosquitto
26+
#addons:
27+
# apt:
28+
# sources:
29+
# - sourceline: 'ppa:mosquitto-dev/mosquitto-ppa'
30+
# packages:
31+
# - mosquitto

CONTRIBUTING.md

Lines changed: 134 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,134 @@
1-
# Contributing to Paho
2-
3-
Thanks for your interest in this project!
4-
5-
You can contribute bugfixes and new features by sending pull requests through GitHub.
6-
7-
## Legal
8-
9-
In order for your contribution to be accepted, it must comply with the Eclipse Foundation IP policy.
10-
11-
Please read the [Eclipse Foundation policy on accepting contributions via Git](http://wiki.eclipse.org/Development_Resources/Contributing_via_Git).
12-
13-
1. Sign the [Eclipse ECA](http://www.eclipse.org/legal/ECA.php)
14-
1. Register for an Eclipse Foundation User ID. You can register [here](https://dev.eclipse.org/site_login/createaccount.php).
15-
2. Log into the [Eclipse projects forge](https://www.eclipse.org/contribute/cla), and click on 'Eclipse Contributor Agreement'.
16-
2. Go to your [account settings](https://dev.eclipse.org/site_login/myaccount.php#open_tab_accountsettings) and add your GitHub username to your account.
17-
3. Make sure that you _sign-off_ your Git commits in the following format:
18-
``` Signed-off-by: Alex Smith <alexsmith@nowhere.com> ``` This is usually at the bottom of the commit message. You can automate this by adding the '-s' flag when you make the commits. e.g. ```git commit -s -m "Adding a cool feature"```
19-
4. Ensure that the email address that you make your commits with is the same one you used to sign up to the Eclipse Foundation website with.
20-
21-
## Contributing a change
22-
23-
1. [Fork the repository on GitHub](https://github.com/eclipse/paho.mqtt.java/fork)
24-
2. Clone the forked repository onto your computer: ``` git clone https://github.com/<your username>/paho.mqtt.java.git ```
25-
3. Create a new branch from the latest ```develop``` branch with ```git checkout -b YOUR_BRANCH_NAME origin/develop```
26-
4. Make your changes
27-
5. If developing a new feature, make sure to include JUnit tests.
28-
6. Ensure that all new and existing tests pass.
29-
7. Commit the changes into the branch: ``` git commit -s ``` Make sure that your commit message is meaningful and describes your changes correctly.
30-
8. If you have a lot of commits for the change, squash them into a single / few commits.
31-
9. Push the changes in your branch to your forked repository.
32-
10. Finally, go to [https://github.com/eclipse/paho.mqtt.java](https://github.com/eclipse/paho.mqtt.java) and create a pull request from your "YOUR_BRANCH_NAME" branch to the ```develop``` one to request review and merge of the commits in your pushed branch.
33-
34-
35-
What happens next depends on the content of the patch. If it is 100% authored
36-
by the contributor and is less than 1000 lines (and meets the needs of the
37-
project), then it can be pulled into the main repository. If not, more steps
38-
are required. These are detailed in the
39-
[legal process poster](http://www.eclipse.org/legal/EclipseLegalProcessPoster.pdf).
40-
41-
42-
43-
## Developer resources:
44-
45-
46-
Information regarding source code management, builds, coding standards, and more.
47-
48-
- [https://projects.eclipse.org/projects/iot.paho/developer](https://projects.eclipse.org/projects/iot.paho/developer)
49-
50-
Contact:
51-
--------
52-
53-
Contact the project developers via the project's development
54-
[mailing list](https://dev.eclipse.org/mailman/listinfo/paho-dev).
55-
56-
Search for bugs:
57-
----------------
58-
59-
This project uses GitHub Issues here: [github.com/eclipse/paho.mqtt.java/issues](https://github.com/eclipse/paho.mqtt.java/issues) to track ongoing development and issues.
60-
61-
Create a new bug:
62-
-----------------
63-
64-
Be sure to search for existing bugs before you create another one. Remember that contributions are always welcome!
65-
66-
- [Create new Paho bug](https://github.com/eclipse/paho.mqtt.java/issues/new)
1+
# Contributing to Paho
2+
3+
Thanks for your interest in this project!
4+
5+
You can contribute bugfixes and new features by sending pull requests through GitHub.
6+
7+
## Legal
8+
9+
In order for your contribution to be accepted, it must comply with the Eclipse Foundation IP policy.
10+
11+
Please read the [Eclipse Foundation policy on accepting contributions via Git](http://wiki.eclipse.org/Development_Resources/Contributing_via_Git).
12+
13+
1. Sign the [Eclipse ECA](http://www.eclipse.org/legal/ECA.php)
14+
1. Register for an Eclipse Foundation User ID. You can register [here](https://dev.eclipse.org/site_login/createaccount.php).
15+
2. Log into the [Eclipse projects forge](https://www.eclipse.org/contribute/cla), and click on 'Eclipse Contributor Agreement'.
16+
2. Go to your [account settings](https://dev.eclipse.org/site_login/myaccount.php#open_tab_accountsettings) and add your GitHub username to your account.
17+
3. Make sure that you _sign-off_ your Git commits in the following format:
18+
``` Signed-off-by: Alex Smith <alexsmith@nowhere.com> ``` This is usually at the bottom of the commit message. You can automate this by adding the '-s' flag when you make the commits. e.g. ```git commit -s -m "Adding a cool feature"```
19+
4. Ensure that the email address that you make your commits with is the same one you used to sign up to the Eclipse Foundation website with.
20+
21+
## Contributing a change
22+
23+
1. [Fork the repository on GitHub](https://github.com/eclipse/paho.mqtt.java/fork)
24+
2. Clone the forked repository onto your computer: ``` git clone https://github.com/<your username>/paho.mqtt.java.git ```
25+
3. Create a new branch from the latest ```develop``` branch with ```git checkout -b YOUR_BRANCH_NAME origin/develop```
26+
4. Make your changes
27+
5. If developing a new feature, make sure to include JUnit tests.
28+
6. Ensure that all new and existing tests pass.
29+
7. Commit the changes into the branch: ``` git commit -s ``` Make sure that your commit message is meaningful and describes your changes correctly.
30+
8. If you have a lot of commits for the change, squash them into a single / few commits.
31+
9. Push the changes in your branch to your forked repository.
32+
10. Finally, go to [https://github.com/eclipse/paho.mqtt.java](https://github.com/eclipse/paho.mqtt.java) and create a pull request from your "YOUR_BRANCH_NAME" branch to the ```develop``` one to request review and merge of the commits in your pushed branch.
33+
34+
35+
What happens next depends on the content of the patch. If it is 100% authored
36+
by the contributor and is less than 1000 lines (and meets the needs of the
37+
project), then it can be pulled into the main repository. If not, more steps
38+
are required. These are detailed in the
39+
[legal process poster](http://www.eclipse.org/legal/EclipseLegalProcessPoster.pdf).
40+
41+
42+
43+
## Developer resources:
44+
45+
46+
Information regarding source code management, builds, coding standards, and more.
47+
48+
- [https://projects.eclipse.org/projects/iot.paho/developer](https://projects.eclipse.org/projects/iot.paho/developer)
49+
50+
Contact:
51+
--------
52+
53+
Contact the project developers via the project's development
54+
[mailing list](https://dev.eclipse.org/mailman/listinfo/paho-dev).
55+
56+
Search for bugs:
57+
----------------
58+
59+
This project uses GitHub Issues here: [github.com/eclipse/paho.mqtt.java/issues](https://github.com/eclipse/paho.mqtt.java/issues) to track ongoing development and issues.
60+
61+
Create a new bug:
62+
-----------------
63+
64+
Be sure to search for existing bugs before you create another one. Remember that contributions are always welcome!
65+
66+
- [Create new Paho bug](https://github.com/eclipse/paho.mqtt.java/issues/new)
67+
=======
68+
# Contributing to Paho
69+
70+
Thanks for your interest in this project!
71+
72+
You can contribute bugfixes and new features by sending pull requests through GitHub.
73+
74+
## Legal
75+
76+
In order for your contribution to be accepted, it must comply with the Eclipse Foundation IP policy.
77+
78+
Please read the [Eclipse Foundation policy on accepting contributions via Git](http://wiki.eclipse.org/Development_Resources/Contributing_via_Git).
79+
80+
1. Sign the [Eclipse ECA](http://www.eclipse.org/legal/ECA.php)
81+
1. Register for an Eclipse Foundation User ID. You can register [here](https://dev.eclipse.org/site_login/createaccount.php).
82+
2. Log into the [Eclipse projects forge](https://www.eclipse.org/contribute/cla), and click on 'Eclipse Contributor Agreement'.
83+
2. Go to your [account settings](https://dev.eclipse.org/site_login/myaccount.php#open_tab_accountsettings) and add your GitHub username to your account.
84+
3. Make sure that you _sign-off_ your Git commits in the following format:
85+
``` Signed-off-by: Alex Smith <alexsmith@nowhere.com> ``` This is usually at the bottom of the commit message. You can automate this by adding the '-s' flag when you make the commits. e.g. ```git commit -s -m "Adding a cool feature"```
86+
4. Ensure that the email address that you make your commits with is the same one you used to sign up to the Eclipse Foundation website with.
87+
88+
## Contributing a change
89+
90+
1. [Fork the repository on GitHub](https://github.com/eclipse/paho.mqtt.java/fork)
91+
2. Clone the forked repository onto your computer: ``` git clone https://github.com/<your username>/paho.mqtt.java.git ```
92+
3. Create a new branch from the latest ```develop``` branch with ```git checkout -b YOUR_BRANCH_NAME origin/develop```
93+
4. Make your changes
94+
5. If developing a new feature, make sure to include JUnit tests.
95+
6. Ensure that all new and existing tests pass.
96+
7. Commit the changes into the branch: ``` git commit -s ``` Make sure that your commit message is meaningful and describes your changes correctly.
97+
8. If you have a lot of commits for the change, squash them into a single / few commits.
98+
9. Push the changes in your branch to your forked repository.
99+
10. Finally, go to [https://github.com/eclipse/paho.mqtt.java](https://github.com/eclipse/paho.mqtt.java) and create a pull request from your "YOUR_BRANCH_NAME" branch to the ```develop``` one to request review and merge of the commits in your pushed branch.
100+
101+
102+
What happens next depends on the content of the patch. If it is 100% authored
103+
by the contributor and is less than 1000 lines (and meets the needs of the
104+
project), then it can be pulled into the main repository. If not, more steps
105+
are required. These are detailed in the
106+
[legal process poster](http://www.eclipse.org/legal/EclipseLegalProcessPoster.pdf).
107+
108+
109+
110+
## Developer resources:
111+
112+
113+
Information regarding source code management, builds, coding standards, and more.
114+
115+
- [https://projects.eclipse.org/projects/iot.paho/developer](https://projects.eclipse.org/projects/iot.paho/developer)
116+
117+
Contact:
118+
--------
119+
120+
Contact the project developers via the project's development
121+
[mailing list](https://dev.eclipse.org/mailman/listinfo/paho-dev).
122+
123+
Search for bugs:
124+
----------------
125+
126+
This project uses GitHub Issues here: [github.com/eclipse/paho.mqtt.java/issues](https://github.com/eclipse/paho.mqtt.java/issues) to track ongoing development and issues.
127+
128+
Create a new bug:
129+
-----------------
130+
131+
Be sure to search for existing bugs before you create another one. Remember that contributions are always welcome!
132+
133+
- [Create new Paho bug](https://github.com/eclipse/paho.mqtt.java/issues/new)
134+

MQTTv3.md

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
# Eclipse Paho Java MQTTv3 Client
2+
3+
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.
4+
5+
## Using the Paho Java MQTTv3 Client
6+
7+
### Downloading
8+
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.
10+
11+
Add the repository definition and the dependency definition shown below to your pom.xml.
12+
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 .
14+
The latest release version is ```1.2.0``` and the current snapshot version is ```1.2.1-SNAPSHOT```.
15+
16+
```
17+
<project ...>
18+
<repositories>
19+
<repository>
20+
<id>Eclipse Paho Repo</id>
21+
<url>%REPOURL%</url>
22+
</repository>
23+
</repositories>
24+
...
25+
<dependencies>
26+
<dependency>
27+
<groupId>org.eclipse.paho</groupId>
28+
<artifactId>org.eclipse.paho.client.mqttv3</artifactId>
29+
<version>%VERSION%</version>
30+
</dependency>
31+
</dependencies>
32+
</project>
33+
34+
```
35+
36+
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.
37+
38+
### Building from source
39+
40+
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 ```
41+
42+
To then build the library run the following maven command: ```mvn package -DskipTests```
43+
44+
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.
45+
46+
## Documentation
47+
Reference documentation is online at: [http://www.eclipse.org/paho/files/javadoc/index.html](http://www.eclipse.org/paho/files/javadoc/index.html)
48+
49+
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)
50+
51+
## Getting Started
52+
53+
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.
54+
55+
56+
```
57+
import org.eclipse.paho.client.mqttv3.MqttClient;
58+
import org.eclipse.paho.client.mqttv3.MqttConnectOptions;
59+
import org.eclipse.paho.client.mqttv3.MqttException;
60+
import org.eclipse.paho.client.mqttv3.MqttMessage;
61+
import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence;
62+
63+
public class MqttPublishSample {
64+
65+
public static void main(String[] args) {
66+
67+
String topic = "MQTT Examples";
68+
String content = "Message from MqttPublishSample";
69+
int qos = 2;
70+
String broker = "tcp://iot.eclipse.org:1883";
71+
String clientId = "JavaSample";
72+
MemoryPersistence persistence = new MemoryPersistence();
73+
74+
try {
75+
MqttClient sampleClient = new MqttClient(broker, clientId, persistence);
76+
MqttConnectOptions connOpts = new MqttConnectOptions();
77+
connOpts.setCleanSession(true);
78+
System.out.println("Connecting to broker: "+broker);
79+
sampleClient.connect(connOpts);
80+
System.out.println("Connected");
81+
System.out.println("Publishing message: "+content);
82+
MqttMessage message = new MqttMessage(content.getBytes());
83+
message.setQos(qos);
84+
sampleClient.publish(topic, message);
85+
System.out.println("Message published");
86+
sampleClient.disconnect();
87+
System.out.println("Disconnected");
88+
System.exit(0);
89+
} catch(MqttException me) {
90+
System.out.println("reason "+me.getReasonCode());
91+
System.out.println("msg "+me.getMessage());
92+
System.out.println("loc "+me.getLocalizedMessage());
93+
System.out.println("cause "+me.getCause());
94+
System.out.println("excep "+me);
95+
me.printStackTrace();
96+
}
97+
}
98+
}
99+
```
100+
101+
## Adding custom headers for Websocket connection
102+
103+
The included code below is a extended basic sample that connects to a server with custom headers.
104+
105+
```
106+
MqttClient client = new MqttClient("wss://<BROKER_URI>", "MyClient");
107+
108+
MqttConnectOptions connectOptions = new MqttConnectOptions();
109+
Properties properties = new Properties();
110+
properties.setProperty("X-Amz-CustomAuthorizer-Name", <SOME_VALUE>);
111+
properties.setProperty("X-Amz-CustomAuthorizer-Signature", <SOME_VALUE>);
112+
properties.setProperty(<SOME_VALUE>, <SOME_VALUE>);
113+
connectOptions.setCustomWebSocketHeaders(properties);
114+
115+
client.connect(connectOptions);
116+
117+
```

0 commit comments

Comments
 (0)