Skip to content

paolo-rossi/nats.delphi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Delphi client for NATS, the cloud native messaging system.

Delphi For NATS

Delphi native implementation of a NATS Client Library. This library supports Core NATS, JetStream is currently under implementation.

Repo Created At License Apache 2 Commit Activity GitHub Contributors

Installation

...todo

Basic Usage

Connecting

uses
    Nats.Consts,
    Nats.Entities,
    Nats.Connection;


// Create a connection object
LConnection := TNatsConnection.Create;


// Connect to a NATS Server
LConnection.SetChannel('localhost', 4222, 1000).
    Open(
        procedure (AInfo: TNatsServerInfo; var AConnectOptions: TNatsConnectOptions)
        begin
            TThread.Queue(TThread.Current,
            procedure
            begin
                Log('Connected to server ' + AInfo.server_name);
            end
            );
        end,
        procedure
        begin
            TThread.Queue(TThread.Current,
            procedure
            begin
                Log('Disconnected from the server');
            end
            );

        end
        )
;

Publishing messages

LConnection.Publish('mysubject', 'My Message');

Subscribing to subjects

LConnection.Subscribe('mysubject', 
    procedure (const AMsg: TNatsArgsMSG)
    begin
        // Code to handle received Msg with subject "mysubject"
        // ** Remember! your code here must be thread safe!
        Log('Message received from NATS server: ' + AMsg);
    end
);

Unubscribing to subjects

  LConnection.Unsubscribe('mysubject');

JetStream

JetStream is the built-in NATS persistence system. nats.delphi provides a built-in API enabling both managing JetStream assets as well as publishing/consuming persistent messages.

JetStream support is under active development.

About

Delphi client for NATS, the cloud native messaging system.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages