Have an amazing solution built in RAD Studio? Let us know. Looking for discounts? Visit our Special Offers page!
CodeDelphiIDERAD Studio

Working Example Code of Using STOMP In Your Application

smartmockups kp1ck3ys

STOMP is the Simple (or Streaming) Text Oriented Messaging Protocol. STOMP provides an interoperable wire format so that STOMP clients can communicate with any STOMP message broker to provide easy and widespread messaging interoperability among many languages, platforms, and brokers. You may use IDE Software such as Delphi for STOMP. You can check the latest version of the STOMP specification here. You can read the explanation about STOMP from the article by Embarcadero MVP Ian Barker which can be found here https://blogs.embarcadero.com/add-stomp-to-your-apps-for-lightweight-real-time-streaming/

I wrote this article to complement what Ian Barker wrote, with code samples and components from Embarcadero Technology Partner, ESEGECE, https://www.esegece.com/delphi/stomp

screen shot 2021 05 23 at 21 34 51

Keep in mind that STOMP is just a protocol, a protocol that forms the basic specification in text, so STOMP data transmission can use anything, including using WebSockets.

How to use the sgcWebSocket component as the STOMP carrier data?

Let’s download the WebSocket component, trial version here https://www.esegece.com/websockets/download

The sgcWebSocket components support most Delphi versions from Delphi 7 to Delphi 10.4 as well as Lazarus/ Freepascal.

Delphi 10_4  
Delphi 10_3Delphi 10_2Delphi 10_1
Delphi 10Delphi XE8Delphi XE7
Delphi XE6Delphi XE5Delphi XE4
Delphi XE3Delphi XE2Delphi XE
Delphi 2010Delphi 2009Delphi 2007
Delphi 7Lazarus 2.0.12 Win32
  • Run your Delphi
  • Open Package’s folder of your dowloaded component
  • Open sgcWebSocketsD10_x.groupproj and install it
screen shot 2021 05 23 at 22 03 47
  • Now, create a new Firemonkey cross-platform project and add code like below:

Adding “frmMain” code

Lets create Method “InitSTOMPClient”

FClient is WebSocket client for STOMP to get passed to STOMP server, ESEGECE have a server as a test, let’s just use that

Create two event handlers – “DoOnSTOMPConnected” and “DoOnSTOMPMessage”

The application display will be as follows

screen shot 2021 05 23 at 22 28 03

Check out the full source code here (GitHub link)

Reduce development time and get to market faster with RAD Studio, Delphi, or C++Builder.
Design. Code. Compile. Deploy.
Start Free Trial   Upgrade Today

   Free Delphi Community Edition   Free C++Builder Community Edition

About author

Senior Software Engineer | Delphi/FreePascal Enthusiast | Linux/ Unix Enthusiast

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.