Habari Client for Artemis  6.8
Object Pascal STOMP client library for ActiveMQ Artemis
TBTConnection Class Reference

A Connection object is a client's active connection to its message provider. More...

Inheritance diagram for TBTConnection:
IConnection IConnectionInfo

Public Member Functions

TBTConnection MakeConnection ()
 A static helper method to create a new connection.
 
TBTConnection MakeConnection (const string UserName, const string Password, const string URL)
 A static helper method to create a new connection.
 
Boolean TransportConnected ()
 Is the transport layer connected? More...
 
string StompSessionID ()
 Stomp session ID. More...
 
string StompServerName ()
 Stomp server name. More...
 
TStompProtocolVersion StompProtocolVersion ()
 Stomp protocol version of the current connection. More...
 
 Start ()
 Starts (or restarts) a connection's delivery of incoming messages. More...
 
 Stop ()
 Temporarily stops a connection's delivery of incoming messages. More...
 
 Close ()
 Closes the connection. More...
 
ISession CreateSession (const Boolean Transacted, const TAcknowledgementMode AcknowledgementMode)
 Creates a new session to work on this connection, specifying transacted and acknowledgeMode. More...
 
ISession CreateSession (const TAcknowledgementMode ASessionMode)
 Creates a new session to work on this connection, specifying sessionMode. More...
 
 SetDefaultClientID (const string Value)
 Sets the default client id that the connection will use if explicitly not set with the SetClientID call.
 
 SetTransformer (const IMessageTransformer Transformer)
 Set the message transformer.
 
IMessageTransformer GetTransformer ()
 Get the message transformer.
 
 SetMapMessageTransformationId (const string ATransformationId)
 Set the transformation id for map messages.
 
 SetObjectMessageTransformationId (const string ATransformationId)
 Set the transformation id for object messages.
 

Public Attributes

string ClientID
 The client identifier for this connection. More...
 
Boolean Closed
 Returns true if the connection is closed. More...
 
Boolean Closing
 Returns true if the connection is in the process of being closed. More...
 
Integer ConnectTimeOut
 Connect time out. More...
 
Integer SendTimeOut
 Send time out. More...
 
Boolean Started
 Returns true if this connection has been started. More...
 
TBTAbstractTransport Transport
 The transport. More...
 

Protected Member Functions

 CheckClosedOrFailed ()
 simply throws an exception if the Connection is already closed or the Transport has failed More...
 
 CheckClientIDWasManuallySpecified ()
 Ensures that the ClientID was manually specified and not auto-generated. More...
 
 EnsureConnectionInfoSent ()
 Send the ConnectionInfo to the Broker.
 
 SendHeartbeat ()
 Send a heartbeat signal (requires Stomp 1.1)
 
 CheckHeartbeat ()
 Check for server heartbeat signal (requires Stomp 1.1) More...
 
Boolean ReceiveHeartbeat (const Integer ATimeout)
 Try to receive server heartbeat. More...
 

Detailed Description

A Connection object is a client's active connection to its message provider.

A connection serves several purposes:

  • It encapsulates an open connection with a message provider. It typically represents an open TCP/IP socket between a client and the service provider software.
  • Its creation is where client authentication takes place.
  • It can specify a unique client identifier.

Member Function Documentation

◆ CheckClientIDWasManuallySpecified()

TBTConnection::CheckClientIDWasManuallySpecified ( )
protected

Ensures that the ClientID was manually specified and not auto-generated.

If the ClientID was not specified this method will throw an exception. This method is used to ensure that the ClientID + durableSubscriber name are used correctly.

◆ CheckClosedOrFailed()

TBTConnection::CheckClosedOrFailed ( )
protected

simply throws an exception if the Connection is already closed or the Transport has failed

Exceptions
EJMSException

◆ CheckHeartbeat()

TBTConnection::CheckHeartbeat ( )
protected

Check for server heartbeat signal (requires Stomp 1.1)

Exceptions
ENoHeartbeatif an expected server heartbeat was missing

◆ Close()

TBTConnection::Close ( )

Closes the connection.

Since a provider typically allocates significant resources on behalf of a connection, clients should close these resources when they are not needed.

◆ CreateSession() [1/2]

ISession TBTConnection::CreateSession ( const Boolean  Transacted,
const TAcknowledgementMode  AcknowledgementMode 
)

Creates a new session to work on this connection, specifying transacted and acknowledgeMode.

Parameters
Transacted- indicates whether the session is transacted
AcknowledgementModeamTransactional, amClientAcknowledge, amAutoAcknowledge. Some brokers also support amClientIndividual (see documentation).
Returns
new session

◆ CreateSession() [2/2]

ISession TBTConnection::CreateSession ( const TAcknowledgementMode  ASessionMode)

Creates a new session to work on this connection, specifying sessionMode.

Parameters
ASessionModeamTransactional, amClientAcknowledge, amAutoAcknowledge. Some brokers also support amClientIndividual (see documentation).
Returns
new session
Since
2.1

◆ ReceiveHeartbeat()

Boolean TBTConnection::ReceiveHeartbeat ( const Integer  ATimeout)
protected

Try to receive server heartbeat.

Requires Stomp 1.1

Parameters
ATimeouttimeout
Returns
True if a heartbeat signal was received

◆ Start()

TBTConnection::Start ( )

Starts (or restarts) a connection's delivery of incoming messages.

A call to start on a connection that has already been started is ignored.

◆ StompProtocolVersion()

TStompProtocolVersion TBTConnection::StompProtocolVersion ( )

Stomp protocol version of the current connection.

See also
IConnectionInfo

◆ StompServerName()

string TBTConnection::StompServerName ( )

Stomp server name.

See also
IConnectionInfo

◆ StompSessionID()

string TBTConnection::StompSessionID ( )

Stomp session ID.

See also
IConnectionInfo

◆ Stop()

TBTConnection::Stop ( )

Temporarily stops a connection's delivery of incoming messages.

Delivery can be restarted using the connection's Start method.

When the connection is stopped, delivery to all the connection's message consumers is inhibited: synchronous receives block, and messages are not delivered to message listeners.

This call blocks until receives and/or message listeners in progress have completed.

Stopping a connection has no effect on its ability to send messages. A call to stop on a connection that has already been stopped is ignored.

◆ TransportConnected()

Boolean TBTConnection::TransportConnected ( )

Is the transport layer connected?

See also
IConnectionInfo

Member Data Documentation

◆ ClientID

string TBTConnection::ClientID

The client identifier for this connection.

The preferred way to assign a client's client identifier is for it to be configured in a client-specific ConnectionFactory object and transparently assigned to the Connection object it creates.

Alternatively, a client can set a connection's client identifier using a provider-specific value. The facility to set a connection's client identifier explicitly is not a mechanism for overriding the identifier that has been administratively configured. It is provided for the case where no administratively specified identifier exists. If one does exist, an attempt to change it by setting it must throw an IllegalStateException. If a client sets the client identifier explicitly, it must do so immediately after it creates the connection and before any other action on the connection is taken. After this point, setting the client identifier is a programming error that should throw an IllegalStateException.

The purpose of the client identifier is to associate a connection and its objects with a state maintained on behalf of the client by a provider. The only such state identified by the API is that required to support durable subscriptions.

If another connection with the same clientID is already running when this method is called, the message provider should detect the duplicate ID and throw an InvalidClientIDException.

See also
GetClientID For reading
SetClientID For writing

◆ Closed

Boolean TBTConnection::Closed

Returns true if the connection is closed.

See also
FClosed For reading

◆ Closing

Boolean TBTConnection::Closing

Returns true if the connection is in the process of being closed.

See also
FClosing For reading

◆ ConnectTimeOut

Integer TBTConnection::ConnectTimeOut

Connect time out.

Note
Experimental feature.
See also
FConnectTimeOut For reading
SetConnectTimeOut For writing

◆ SendTimeOut

Integer TBTConnection::SendTimeOut

Send time out.

Note
Experimental feature.
See also
FSendTimeOut For reading
SetSendTimeOut For writing

◆ Started

Boolean TBTConnection::Started

Returns true if this connection has been started.

See also
FStarted For reading
SetStarted For writing

◆ Transport

TBTAbstractTransport TBTConnection::Transport

The transport.

See also
FTransport For reading