Site icon Embarcadero RAD Studio, Delphi, & C++Builder Blogs

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

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

Adding “frmMain” code

[crayon-6741c22dd3d97157750258/]

Lets create Method “InitSTOMPClient”

[crayon-6741c22dd3d9d491431918/]

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”

[crayon-6741c22dd3d9f523625552/]

The application display will be as follows

Check out the full source code here (GitHub link)

Exit mobile version