Skip to content

Client

Represents a client for communicating with a STOMP (Simple Text Oriented Messaging Protocol) v1.2 broker.

Remarks:

STOMP is a simple, text-based protocol offering an interoperable wire format that enables clients to communicate with a wide range of message brokers and queueing systems, ensuring broad compatibility across different STOMP message brokers. This class manages the connection lifecycle, message subscription and publishing, transaction handling, and heartbeating as per the STOMP 1.2 specification.

Key features include:

  • Connecting and disconnecting from a STOMP broker.
  • Subscribing to message destinations and receiving messages.
  • Sending messages to destinations in the broker.
  • Handling message acknowledgments and transactions.
  • Maintaining the client state and managing heartbeats to ensure a live connection.

The client supports both callback and async-await based operation patterns, making it suitable for various application scenarios.

Fields:

ConnectParameters Parameters

Gets the parameters used for establishing a connection with the STOMP server.

ServerParameters ServerParameters

Gets the parameters negotiated with the STOMP broker after a successful connection.

States State

Current state of the STOMP client. State changed events are emitted through the OnStateChanged event.

Action<Client, ServerParameters, IncomingFrame> OnConnected

Called when the client successfully connected to the broker.

Action<Client, Error> OnDisconnected

Called after the client disconnects from the broker.

Action<Client, States, States> OnStateChanged

Called for every internal state change of the client.

Func<Client, IncomingFrame, Boolean> OnFrame

Called for every frame received from the broker.

Methods:

Void BeginConnect(ConnectParameters, CancellationToken)

Initiates a connection to the STOMP broker using the provided ConnectParameters.

Task<ServerParameters> ConnectAsync(ConnectParameters, CancellationToken)

Using the ConnectParameters passed as its parameter begins the connection procedure to the broker.

Void BeginDisconnect()

Initiates the disconnection process from the STOMP broker.

Task<Error> DisconnectAsync()

Asynchronously disconnects from the STOMP broker.

Transaction CreateTransaction()

Creates a new transaction for sending and receiving messages in a transactional context.

SubscriptionBuilder CreateSubscriptionBuilder(String)

Begins the construction of a new subscription to the specified destination.

Subscription FindSubscription(String)

Searches for a subscription by its destination.

MessageBuilder CreateMessageBuilder(String)

Begins the construction of a new message to a specified destination.

Comments