Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

com.aendvari.hermes.broker
Class MessageTransaction  view MessageTransaction download MessageTransaction.java

java.lang.Object
  extended bycom.aendvari.hermes.broker.MessageTransaction

public class MessageTransaction
extends java.lang.Object

Provides a mechanism to collect several messages published in succession. The transaction may be commited or rolled back at any time.

When commited, the messages are sent to any subscribed listeners (see MessageListener).

When rolled back, all messages published during the transaction are thrown away and not sent to the listeners.


Field Summary
protected  boolean active
          Specifies whether the transaction is current active.
protected  MessageBatch messages
          Contains the messages published to this batch.
 
Constructor Summary
protected MessageTransaction(MessageBrokerConnection setConnection)
          Constructs a MessageTransaction.
 
Method Summary
 void commit()
          Commits the transaction.
 boolean isActive()
          Returns true if a transaction is currently in progress.
 void publish(MessageTopic topic, Message message)
          Publishes a message to the specific topic.
 void rollback()
          Tells the transaction to rollback.
 void start()
          Starts a transaction.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

messages

protected MessageBatch messages
Contains the messages published to this batch.


active

protected boolean active
Specifies whether the transaction is current active.

Constructor Detail

MessageTransaction

protected MessageTransaction(MessageBrokerConnection setConnection)
Constructs a MessageTransaction.

Method Detail

start

public void start()
Starts a transaction. All messages published are handle within the transaction until either a commit or rollback is performed.


commit

public void commit()
Commits the transaction. All message published during the transaction will be sent to any listeners (see MessageListener).


rollback

public void rollback()
Tells the transaction to rollback. All messages published during the transaction are thrown away and not sent to the listeners.


isActive

public boolean isActive()
Returns true if a transaction is currently in progress.


publish

public void publish(MessageTopic topic,
                    Message message)
Publishes a message to the specific topic.