SAP

Manage my Account SAP Devs YouTube ↗ Learnings ↗ Community ↗ Provide Feedback ↗
Logout
⤢ Open full site

Publish and Receive MQTT Messages

Publish and receive MQTT messages in ABAP using the ABAP MQTT Client.

Overview

You will learn

  • How to publish an MQTT message in ABAP
  • How to receive MQTT messages in ABAP
Julie Plummer J Julie Plummer April 18, 2023
Created on March 9, 2023
Contributors

More from Julie Plummer

See all 51 tutorials by Julie Plummer →

Prerequisites

Prerequisites

Steps

Intro

In this tutorial, you will create a simple ABAP class that can publish and receive messages using the MQTT protocol.


Step 1 Create a new ABAP class

Create a new ABAP class called ZCL_TUTORIAL_MQTT and implement the interface IF_MQTT_EVENT_HANDLER by adding the snippet to the PUBLIC SECTION of your class:

ABAP
INTERFACES if_mqtt_event_handler.

Next, add the 6 unimplemented abstract methods by clicking the light bulb to the right of the line you just inserted and select Add 6 unimplemented methods.

Add 6 unimplemented methods
Add 6 unimplemented methods

Step 2 Create the MQTT Client and connect to the broker
+
Step 3 Implement the PUBLISH method
+
Step 4 Publish an MQTT message
+
Step 5 Implement the ON_MESSAGE method
+
Step 6 Subscribe to an MQTT topic
+
Step 7 Test your program
+
Step 8 Unsubscribe and disconnect (optional)
+

Resources

Discussion

Share feedback on this tutorial or join the conversation in SAP Community.

Submit detailed feedback Discuss in Community
Steps
Step 1 of 8
1. Create a new ABAP class 2. Create the MQTT Client and connect to the broker 3. Implement the PUBLISH method 4. Publish an MQTT message 5. Implement the ON_MESSAGE method 6. Subscribe to an MQTT topic 7. Test your program 8. Unsubscribe and disconnect (optional)
Next