Getting started with MQTT clients

You can get started developing a mobile or machine-to-machine (M2M) app by building and running a sample MQTT client app that uses an MQTT client library. The sample apps, and associated client libraries, are available in the Mobile Messaging and M2M Client Pack from IBM®. There are versions of the apps and client libraries written in Java, in JavaScript, and in C. You can run these apps on most platforms and devices, including Android devices and products from Apple.

Before you begin

To build and run your app, you need some experience of building apps for the target device or platform and the programming language being used. A little experience is usually enough to get a sample app up and running on your chosen device or platform.

If you use an enterprise-strength MQTT server such as IBM WebSphere® MQ or IBM MessageSight, you can exchange information from your sample app with your existing enterprise apps.

About this task

Your objectives are as follows:
  1. Choose an MQTT server to which you can connect the client app.
  2. Download the Mobile Messaging and M2M Client Pack.
  3. Build, for your target device or platform, the sample apps from the client pack.
  4. Verify that the samples behave as expected by connecting them to the MQTT server.
As a result of building and testing the sample apps for your device or platform, you create a working development environment that you can then use to build your own client apps.
The Mobile Messaging and M2M Client Pack contains the MQTT SDK. This SDK provides you with the following resources:
  • Sample MQTT client apps written in Java, in JavaScript, and in C.
  • MQTT client libraries that support these client apps, and enable them to run on most platforms and devices.
The SDK also includes the source code for the MQTT client for C. You can adapt this source code to build MQTT client libraries for C for other platforms. For help to do this, see Building the MQTT client for C libraries. The source code for the MQTT client for C is also available with an open source license from Eclipse Paho.

Procedure

The following articles guide you through the platform-specific steps for building and running a sample MQTT app on a desktop computer, or on a mobile device for Android or from Apple:

What to do next

To develop a new MQTT application, you must have or acquire the following skills:
  • Programming in the language that is required for the device or platform.
  • Programming for the target device or platform.
  • Designing publish/subscribe applications.
  • Designing programs for the MQTT programming model.
  • Designing programs to run on your chosen mobile device.
  • Using SSL and JAAS to secure programs.

You do not need any network programming skills to connect an MQTT client with another device or application, because MQTT is a messaging and queuing system. The MQTT client libraries manage the network connections for your application.

To integrate your MQTT client with existing enterprise applications, you have two choices. You can share the MQTT publish/subscribe topics with (for example) an IBM WebSphere MQ or JMS application, or you can write your own integration adapter as another MQTT client.

Sources of information to consult today are: