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

Quick Search    Search Deep

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

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

public class MessageBatch
extends java.lang.Object

Provides a mechanism to collect several messages published in succession.

The messages may then sent to any subscribed listeners (see MessageListener). If the batch is not sent, the messages are thrown away and not sent to the listeners.


Field Summary
protected  MessageBrokerConnection brokerConnection
          The MessageBrokerConnection to send the messages through.
protected  java.util.ArrayList messages
          Contains the messages published to this batch.
protected  java.util.ArrayList topics
          Contains the topics published to this batch.
protected  long uniqueIdentifier
          Contains the current unique identifier for the batch.
 
Constructor Summary
MessageBatch(MessageBrokerConnection setConnection)
          Constructs a MessageBatch.
 
Method Summary
 void clear()
          Removes all messages currently in the batch.
 long getIdentifier()
          Returns the unique identifier for this batch.
 void publish(MessageTopic topic, Message message)
          Publishes a message to the specific topic.
 void send()
          Send the batch.
 void start()
          Prepares this MessageBatch for publishing.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

brokerConnection

protected MessageBrokerConnection brokerConnection
The MessageBrokerConnection to send the messages through.


topics

protected java.util.ArrayList topics
Contains the topics published to this batch.


messages

protected java.util.ArrayList messages
Contains the messages published to this batch.


uniqueIdentifier

protected long uniqueIdentifier
Contains the current unique identifier for the batch. The identifier changes everytime a new batch is started (see start 55 or sent (see send 55 ).

Constructor Detail

MessageBatch

public MessageBatch(MessageBrokerConnection setConnection)
Constructs a MessageBatch.

Method Detail

getIdentifier

public long getIdentifier()
Returns the unique identifier for this batch.


start

public void start()
Prepares this MessageBatch for publishing.


send

public void send()
Send the batch. All message published to this batch will be sent to any listeners (see MessageListener).


clear

public void clear()
Removes all messages currently in the batch.


publish

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