SAP Home Learn Build Integrate Model Operate Extend with AI ConnectTutorial navigator Knowledge Graph API Devtoberfest Developer Advocates App Space

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

🎓 intermediate 20 min. ABAP DevelopmentIntermediateInternet Of Things

You will learn

  • โœ”How to publish an MQTT message in ABAP
  • โœ”How to receive MQTT messages in ABAP
Unknown U Unknown April 18, 2023
Created by March 9, 2023
Contributors

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)

Learn more →