TBTJMSSession Class Reference

Session. More...

Inheritance diagram for TBTJMSSession:

ISession

List of all members.

Public Member Functions

 SetTransformer (const IMessageTransformer Transformer)
 Set the message transformer.
 Acknowledge ()
 Acknowledges all consumed messages of the session of this consumed message.
 Commit ()
 If this is a transactional session then commit all message send and acknowledgements for producers and consumers in this session.
IBytesMessage CreateBytesMessage ()
 Creates a BytesMessage object.
IMessage CreateMessage ()
 Creates a Message object.
ITextMessage CreateTextMessage ()
 Creates a TextMessage object.
ITextMessage CreateTextMessage (const WideString Text)
 Creates an initialized TextMessage object.
IMessageConsumer CreateConsumer (const IDestination Destination)
 Creates a MessageConsumer for the specified destination.
IMessageConsumer CreateConsumer (const IDestination Destination, const string MessageSelector)
 Creates a MessageConsumer for the specified destination, using a message selector.
IMessageConsumer CreateConsumer (const IDestination Destination, const string MessageSelector, const Boolean NoLocal)
 Creates MessageConsumer for the specified destination, using a message selector.
IMessageConsumer CreateConsumer (const IDestination Destination, const string MessageSelector, const Boolean NoLocal, IMessageListener MessageListener)
 Creates MessageConsumer for the specified destination, using a message selector.
IObjectMessage CreateObjectMessage ()
 Creates an ObjectMessage object.
IObjectMessage CreateObjectMessage (const TObject AObject)
 Creates an initialized ObjectMessage object.
IMessageProducer CreateProducer (IDestination Destination)
 Creates a producer of messages on a given destination.
IQueue CreateQueue (const string QueueName)
 Creates a queue identity given a Queue name.
ITopic CreateTopic (const string TopicName)
 Creates a topic identity given a Topic name.
 Rollback ()
 If this is a transactional session then rollback all message send and acknowledgements for producers and consumers in this session.
 Send (IMessageProducer Producer, IDestination Destination, IMessage Message, TJMSDeliveryMode DeliveryMode, Byte Priority, Cardinal TimeToLive)
 Sends the message for dispatch by the broker.

Public Attributes

TAcknowledgementMode AcknowledgementMode
 The acknowledgement mode of the session.
TBTJMSConnection Connection
 
See also:
GetConnection For reading

Boolean Running
 
See also:
FStarted For reading

Boolean Transacted
 Whether the session uses transactions.
TBTTransactionContext TransactionContext
 The transaction context of the session.

Protected Member Functions

 CheckClosed ()
 Check if the session is closed.

Protected Attributes

TSessionID SessionID
 
See also:
FSessionID For reading


Detailed Description

Session.

A Session object is a single-threaded context for producing and consuming messages. Although it may allocate provider resources outside the Java virtual machine (JVM), it is considered a lightweight JMS object.

A session serves several purposes:

A session can create and service multiple message producers and consumers.

One typical use is to have a thread block on a synchronous MessageConsumer until a message arrives. The thread may then use one or more of the Session'sMessageProducers.

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 and a set of message receives into an atomic unit of work. In effect, transactions organize a session's input message stream and output message stream into series of atomic units. When a transaction commits, its atomic unit of input is acknowledged and its associated atomic unit of output is sent. If a transaction rollback is done, the transaction's sent messages are destroyed and the session's input is automatically recovered.

The content of a transaction's input and output units is simply those messages that have been produced and consumed within the session's current transaction.

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.

The Java Transaction Service (JTS) or some other transaction monitor may be used to combine a session's transaction with transactions on other resources (databases, other JMS sessions, etc.). Since Java distributed transactions are controlled via the Java Transaction API (JTA), use of the session's commit and rollback methods in this context is prohibited.

The JMS API does not require support for JTA; however, it does define how a provider supplies this support.

Although it is also possible for a JMS client to handle distributed transactions directly, it is unlikely that many JMS clients will do this. Support for JTA in the JMS API is targeted at systems vendors who will be integrating the JMS API into their application server products.


Member Function Documentation

TBTJMSSession::CheckClosed (  )  [protected]

Check if the session is closed.

It is used for ensuring that the session is open before performing various operations.

Exceptions:
IllegalStateException if the Session is closed

TBTJMSSession::SetTransformer ( const IMessageTransformer  Transformer  ) 

Set the message transformer.

See also:
http://activemq.apache.org/message-transformation.html

TBTJMSSession::Acknowledge (  ) 

Acknowledges all consumed messages of the session of this consumed message.

All consumed JMS messages support the acknowledge method for use when a client has specified that its JMS session's consumed messages are to be explicitly acknowledged. By invoking acknowledge on a consumed message, a client acknowledges all messages consumed by the session that the message was delivered to.

Calls to acknowledge are ignored for both transacted sessions and sessions specified to use implicit acknowledgement modes.

A client may individually acknowledge each message as it is consumed, or it may choose to acknowledge messages as an application-defined group (which is done by calling acknowledge on the last received message of the group, thereby acknowledging all messages consumed by the session.)

Messages that have been received but not acknowledged may be redelivered.

Exceptions:
JMSException if the JMS provider fails to acknowledge the messages due to some internal error.
IllegalStateException if this method is called on a closed session.

IBytesMessage TBTJMSSession::CreateBytesMessage (  ) 

Creates a BytesMessage object.

A BytesMessage object is used to send a message containing a stream of uninterpreted bytes.

Returns:
the IBtytesMessage

IMessage TBTJMSSession::CreateMessage (  ) 

Creates a Message object.

The Message interface is the root interface of all JMS messages. A Message object holds all the standard message header information. It can be sent when a message containing only header information is sufficient.

Returns:
an IMessage

ITextMessage TBTJMSSession::CreateTextMessage (  ) 

Creates a TextMessage object.

A TextMessage object is used to send a message containing a String object.

Returns:
an ITextMessage

ITextMessage TBTJMSSession::CreateTextMessage ( const WideString  Text  ) 

Creates an initialized TextMessage object.

A TextMessage object is used to send a message containing a String.

Parameters:
Text the string used to initialize this message
Returns:
an ActiveMQTextMessage

IMessageConsumer TBTJMSSession::CreateConsumer ( const IDestination  Destination  ) 

Creates a MessageConsumer for the specified destination.

Since Queue and Topic both inherit from Destination, they can be used in the destination parameter to create a MessageConsumer.

Parameters:
Destination the Destination to access.
Returns:
the MessageConsumer

IMessageConsumer TBTJMSSession::CreateConsumer ( const IDestination  Destination,
const string  MessageSelector 
)

Creates a MessageConsumer for the specified destination, using a message selector.

Since Queue and Topic both inherit from Destination, they can be used in the destination parameter to create a MessageConsumer.

A client uses a MessageConsumer object to receive messages that have been sent to a destination.

Parameters:
Destination the Destination to access
MessageSelector only messages with properties matching the message selector expression are delivered. A value of null or an empty string indicates that there is no message selector for the message consumer.
Returns:
the MessageConsumer

IMessageConsumer TBTJMSSession::CreateConsumer ( const IDestination  Destination,
const string  MessageSelector,
const Boolean  NoLocal 
)

Creates MessageConsumer 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 Queue and Topic both inherit from Destination, they can be used in the destination parameter to create a MessageConsumer.

A client uses a MessageConsumer 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.

Parameters:
Destination the Destination to access
MessageSelector only messages with properties matching the message selector expression are delivered. A value of null or 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.
Returns:
the MessageConsumer

IMessageConsumer TBTJMSSession::CreateConsumer ( const IDestination  Destination,
const string  MessageSelector,
const Boolean  NoLocal,
IMessageListener  MessageListener 
)

Creates MessageConsumer 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 Queue and Topic both inherit from Destination, they can be used in the destination parameter to create a MessageConsumer.

A client uses a MessageConsumer 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.

Parameters:
Destination the Destination to access
MessageSelector only messages with properties matching the message selector expression are delivered. A value of null or 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.
MessageListener the listener to use for async consumption of messages
Returns:
the MessageConsumer

IObjectMessage TBTJMSSession::CreateObjectMessage (  ) 

Creates an ObjectMessage object.

An ObjectMessage object is used to send a message that contains a serializable Java object.

IObjectMessage TBTJMSSession::CreateObjectMessage ( const TObject  AObject  ) 

Creates an initialized ObjectMessage object.

An ObjectMessage object is used to send a message that contains a serializable Java object.

Parameters:
AObject the object to use to initialize this message

IQueue TBTJMSSession::CreateQueue ( const string  QueueName  ) 

Creates a queue identity given a Queue 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. The one exception is the creation of temporary queues, which is accomplished with the createTemporaryQueue method.

Parameters:
QueueName the name of this Queue
Returns:
a Queue with the given name

ITopic TBTJMSSession::CreateTopic ( const string  TopicName  ) 

Creates a topic identity given a Topic 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. The one exception is the creation of temporary topics, which is accomplished with the createTemporaryTopic method.

Parameters:
TopicName the name of this Topic
Returns:
a Topic with the given name

TBTJMSSession::Send ( IMessageProducer  Producer,
IDestination  Destination,
IMessage  Message,
TJMSDeliveryMode  DeliveryMode,
Byte  Priority,
Cardinal  TimeToLive 
)

Sends the message for dispatch by the broker.

Parameters:
Producer - message producer.
Destination - message destination.
Message - message to be sent.
DeliveryMode - JMS messsage delivery mode.
Priority - message priority.
TimeToLive - message expiration.


Member Data Documentation

TAcknowledgementMode TBTJMSSession::AcknowledgementMode

The acknowledgement mode of the session.

The acknowledgement mode is set at the time that the session is created. If the session is transacted, the acknowledgement mode is ignored.

See also:
GetAcknowledgementMode For reading

SetAcknowledgementMode For writing

TBTJMSConnection TBTJMSSession::Connection

See also:
GetConnection For reading

See also:
SetConnection For writing

Boolean TBTJMSSession::Transacted

Whether the session uses transactions.

See also:
GetTransacted For reading

TBTTransactionContext TBTJMSSession::TransactionContext

The transaction context of the session.

See also:
FTransactionContext For reading

SetTransactionContext For writing


Generated by doxygen