![]() |
Habari Client for RabbitMQ
6.11
Object Pascal STOMP client library for RabbitMQ
|
A Session object is a single-threaded context for producing and consuming messages. More...
Public Member Functions | |
Commit () | |
If this is a transactional session then commit all message send and acknowledgements for producers and consumers in this session. More... | |
IBytesMessage | CreateBytesMessage () |
Creates a IBytesMessage object. More... | |
IMessage | CreateMessage () |
Creates a IMessage object. More... | |
ITextMessage | CreateTextMessage () |
Creates a ITextMessage object. More... | |
ITextMessage | CreateTextMessage (const string Text) |
Creates an initialized ITextMessage object. More... | |
IMapMessage | CreateMapMessage () |
Creates a MapMessage object. More... | |
IMessageConsumer | CreateConsumer (const IDestination Destination) |
Creates a IMessageConsumer for the specified destination. More... | |
IMessageConsumer | CreateConsumer (const IDestination Destination, const string MessageSelector) |
Creates a IMessageConsumer for the specified destination, using a message selector. More... | |
IMessageConsumer | CreateConsumer (const IDestination Destination, const string MessageSelector, const Boolean NoLocal) |
Creates IMessageConsumer for the specified destination, using a message selector. More... | |
IObjectMessage | CreateObjectMessage () |
Creates an IObjectMessage object. More... | |
IObjectMessage | CreateObjectMessage (const TObject AObject) |
Creates an initialized IObjectMessage object. More... | |
ITopicSubscriber | CreateDurableSubscriber (const ITopic Topic, const string Name) |
Creates a durable subscriber to the specified topic. More... | |
ITopicSubscriber | CreateDurableSubscriber (const ITopic Topic, const string Name, const string MessageSelector, const Boolean NoLocal) |
Creates a durable subscriber to the specified topic, using a message selector and specifying whether messages published by its own connection should be delivered to it. More... | |
IMessageProducer | CreateProducer (const IDestination Destination) |
Creates a producer of messages on a given destination. | |
IQueue | CreateQueue (const string QueueName) |
Creates a queue identity given a IQueue name. More... | |
ITopic | CreateTopic (const string TopicName) |
Creates a topic identity given a ITopic name. More... | |
ITemporaryQueue | CreateTemporaryQueue () |
Creates a TemporaryQueue object. More... | |
ITemporaryTopic | CreateTemporaryTopic () |
Creates a TemporaryTopic object. More... | |
Rollback () | |
If this is a transactional session then rollback all message send and acknowledgements for producers and consumers in this session. More... | |
Send (const IDestination Destination, const IMessage Message, const TJMSDeliveryMode DeliveryMode, const Byte Priority, const Cardinal TimeToLive, const Integer SendTimeOut) | |
Sends the message for dispatch by the broker. More... | |
Unsubscribe (const string Destination, const string Name) | |
Unsubscribes a durable subscription that has been created by a client. More... | |
Public Attributes | |
TAcknowledgementMode | AcknowledgeMode |
The acknowledgement mode of the session. More... | |
TBTConnection | Connection |
The connection of the session. More... | |
Boolean | Running |
Returns True if the session has started. More... | |
Boolean | Transacted |
Whether the session uses transactions. More... | |
TBTTransactionContext | TransactionContext |
The transaction context of the session. More... | |
Protected Member Functions | |
CheckClosed () | |
Check if the session is closed. More... | |
CheckClientAck () | |
Check the acknowlegment mode. | |
A Session object is a single-threaded context for producing and consuming messages.
A session serves several purposes:
IQueue
or ITopic
objects for those clients that need to dynamically manipulate provider-specific destination names. A session can create and service multiple message producers and consumers.
One typical use is to have a thread block on a synchronous IMessageConsumer
until a message arrives. The thread may then use one or more of the ISession
'sIMessageProducer
s.
If a client desires to have one thread produce messages while others consume them, the client should use a separate session for its producing thread.
Once a connection has been started, any session with one or more registered message listeners is dedicated to the thread of control that delivers messages to it. It is erroneous for client code to use this session or any of its constituent objects from another thread of control. The only exception to this rule is the use of the session or connection close
method.
It should be easy for most clients to partition their work naturally into sessions. This model allows clients to start simply and incrementally add message processing complexity as their need for concurrency grows.
The close
method is the only session method that can be called while some other session method is being executed in another thread.
A session may be specified as transacted. Each transacted session supports a single series of transactions. Each transaction groups a set of message sends into an atomic unit of work.
A transaction is completed using either its session's commit
method or its session's rollback
method. The completion of a session's current transaction automatically begins the next. The result is that a transacted session always has a current transaction within which its work is done.
|
protected |
Check if the session is closed.
It is used for ensuring that the session is open before performing various operations.
EIllegalStateException | if the Session is closed |
TBTSession::Commit | ( | ) |
If this is a transactional session then commit all message send and acknowledgements for producers and consumers in this session.
EJMSException |
IBytesMessage TBTSession::CreateBytesMessage | ( | ) |
Creates a IBytesMessage
object.
A IBytesMessage
object is used to send a message containing a stream of uninterpreted bytes.
IMessageConsumer TBTSession::CreateConsumer | ( | const IDestination | Destination | ) |
Creates a IMessageConsumer
for the specified destination.
Since IQueue
and ITopic
both inherit from IDestination
, they can be used in the destination parameter to create a IMessageConsumer
.
Destination | the IDestination to access. |
IMessageConsumer TBTSession::CreateConsumer | ( | const IDestination | Destination, |
const string | MessageSelector | ||
) |
Creates a IMessageConsumer
for the specified destination, using a message selector.
Since IQueue
and ITopic
both inherit from IDestination
, they can be used in the destination parameter to create a IMessageConsumer
.
A client uses a IMessageConsumer
object to receive messages that have been sent to a destination.
Destination | the IDestination to access |
MessageSelector | only messages with properties matching the message selector expression are delivered. An empty string indicates that there is no message selector for the message consumer. |
IMessageConsumer TBTSession::CreateConsumer | ( | const IDestination | Destination, |
const string | MessageSelector, | ||
const Boolean | NoLocal | ||
) |
Creates IMessageConsumer
for the specified destination, using a message selector.
This method can specify whether messages published by its own connection should be delivered to it, if the destination is a topic.
Since IQueue
and ITopic
both inherit from IDestination
, they can be used in the destination parameter to create a IMessageConsumer
.
A client uses a IMessageConsumer
object to receive messages that have been published to a destination.
In some cases, a connection may both publish and subscribe to a topic. The consumer noLocal
attribute allows a consumer to inhibit the delivery of messages published by its own connection. The default value for this attribute is False. The noLocal
value must be supported by destinations that are topics.
Destination | the IDestination to access |
MessageSelector | only messages with properties matching the message selector expression are delivered. An empty string indicates that there is no message selector for the message consumer. |
NoLocal | - if true, and the destination is a topic, inhibits the delivery of messages published by its own connection. The behavior for NoLocal is not specified if the destination is a queue. |
MessageSelector is not supported by RabbitMQ
NoLocal is not supported by RabbitMQ
ITopicSubscriber TBTSession::CreateDurableSubscriber | ( | const ITopic | Topic, |
const string | Name | ||
) |
Creates a durable subscriber to the specified topic.
Topic | - the non-temporary ITopic to subscribe to |
Name | - the name used to identify this subscription |
EJMSException | - if the session fails to create a subscriber due to some internal error. |
ITopicSubscriber TBTSession::CreateDurableSubscriber | ( | const ITopic | Topic, |
const string | Name, | ||
const string | MessageSelector, | ||
const Boolean | NoLocal | ||
) |
Creates a durable subscriber to the specified topic, using a message selector and specifying whether messages published by its own connection should be delivered to it.
IMapMessage TBTSession::CreateMapMessage | ( | ) |
Creates a MapMessage
object.
A MapMessage object is used to send a self-defining set of name-value pairs, where names are String objects and values are primitive values in the Java programming language.
IMessage TBTSession::CreateMessage | ( | ) |
IObjectMessage TBTSession::CreateObjectMessage | ( | ) |
Creates an IObjectMessage
object.
An IObjectMessage object is used to send a message that contains a serializable Java object.
IObjectMessage TBTSession::CreateObjectMessage | ( | const TObject | AObject | ) |
Creates an initialized IObjectMessage
object.
An IObjectMessage object is used to send a message that contains a serializable Java object.
AObject | the object to use to initialize this message |
IQueue TBTSession::CreateQueue | ( | const string | QueueName | ) |
Creates a queue identity given a IQueue
name.
This facility is provided for the rare cases where clients need to dynamically manipulate queue identity. It allows the creation of a queue identity with a provider-specific name. Clients that depend on this ability are not portable.
Note that this method is not for creating the physical queue. The physical creation of queues is an administrative task and is not to be initiated by the JMS API.
QueueName | the name of this IQueue |
IQueue
with the given name ITemporaryQueue TBTSession::CreateTemporaryQueue | ( | ) |
Creates a TemporaryQueue object.
Its lifetime will be that of the Connection unless it is deleted earlier.
ITemporaryTopic TBTSession::CreateTemporaryTopic | ( | ) |
Creates a TemporaryTopic object.
Its lifetime will be that of the Connection unless it is deleted earlier.
ITextMessage TBTSession::CreateTextMessage | ( | ) |
Creates a ITextMessage
object.
A ITextMessage
object is used to send a message containing a String
object.
ITextMessage TBTSession::CreateTextMessage | ( | const string | Text | ) |
Creates an initialized ITextMessage
object.
A ITextMessage
object is used to send a message containing a String
.
Text | the string used to initialize this message |
ITopic TBTSession::CreateTopic | ( | const string | TopicName | ) |
Creates a topic identity given a ITopic
name.
This facility is provided for the rare cases where clients need to dynamically manipulate topic identity. This allows the creation of a topic identity with a provider-specific name. Clients that depend on this ability are not portable.
Note that this method is not for creating the physical topic. The physical creation of topics is an administrative task and is not to be initiated by the JMS API.
TopicName | the name of this ITopic |
ITopic
with the given name TBTSession::Rollback | ( | ) |
If this is a transactional session then rollback all message send and acknowledgements for producers and consumers in this session.
EJMSException |
TBTSession::Send | ( | const IDestination | Destination, |
const IMessage | Message, | ||
const TJMSDeliveryMode | DeliveryMode, | ||
const Byte | Priority, | ||
const Cardinal | TimeToLive, | ||
const Integer | SendTimeOut | ||
) |
Sends the message for dispatch by the broker.
Destination | - message destination. |
Message | - message to be sent. |
DeliveryMode | - JMS message delivery mode. |
Priority | - message priority. |
TimeToLive | - message expiration. |
SendTimeOut | - send time out. |
TBTSession::Unsubscribe | ( | const string | Destination, |
const string | Name | ||
) |
Unsubscribes a durable subscription that has been created by a client.
Destination | - the destination name |
Name | - the name used to identify this subscription |
EJMSException | - if the session fails to unsubscribe to the durable subscription due to some internal error. |
TAcknowledgementMode TBTSession::AcknowledgeMode |
The acknowledgement mode of the session.
TBTConnection TBTSession::Connection |
The connection of the session.
Boolean TBTSession::Running |
Returns True if the session has started.
Boolean TBTSession::Transacted |
Whether the session uses transactions.
TBTTransactionContext TBTSession::TransactionContext |
The transaction context of the session.