OSMQ
v2.0.1

osmq.clients
Class BatchPublisher

java.lang.Object
  extended byosmq.clients.PublisherBase
      extended byosmq.clients.PublisherBean
          extended byosmq.clients.BatchPublisher
All Implemented Interfaces:
ClientAdapter, ExceptionListener, Publisher, java.lang.Runnable

public class BatchPublisher
extends PublisherBean
implements java.lang.Runnable


Constructor Summary
BatchPublisher()
           
BatchPublisher(java.lang.String identifier)
           
 
Method Summary
 void addMessageBuilder(MessageBuilder builder)
          Adds a message builder that will create messages that will be written by the message publisher.
 MessageBuilder getControlMessageBuilder()
          Returns a reference to the MessageBuilder that will create preliminary and final control messages.
 int getFocusBuilder()
           
 java.lang.String getFocusBuilderName()
           
 int getMaxRate()
          Returns the maximum rate (in messages-per-second) at which message will be published.
 int getTotalBuilders()
           
 void halt()
          Terminate published messages.
 boolean isPublishing()
          Returns true if this is a threaded publisher and messages are currently being published.
 boolean isThreaded()
          Returns true if batch publishing will be performed by a seperate thread, and false if by the thread that calls PublishMessages()
 void publishMessages()
          Called to initiate message publishing.
 void removeMessageBuilder(MessageBuilder builder)
          Removes a MessageBuilder from the set that will publish messages.
 void run()
          Called by the internal methods.
 void setControlMessageBuilder(MessageBuilder mb)
          Sets the control MessageBuilder that will create preliminary and a final control message.
 void setMaxRate(int rate)
          Sets the maximum rate of message publishing (in messages per second).
 void setThreaded(boolean threaded)
          Determines whether batch publishing will be performed by a seperate thread, or by the thread that calls PublishMessages().
 
Methods inherited from class osmq.clients.PublisherBean
close, commit, getBrokerName, getClientID, getCommitTransactionCount, getConnectionPublishedCount, getExceptionListener, getHostName, getPortID, getPublishedCount, isAutoCommit, isOpen, onException, open, publish, rollback, setAutoCommit, setBrokerName, setClientID, setExceptionListener, setHostName, setPortID
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface osmq.clients.Publisher
commit, getConnectionPublishedCount, getPublishedCount, isOpen, publish, rollback
 

Constructor Detail

BatchPublisher

public BatchPublisher()

BatchPublisher

public BatchPublisher(java.lang.String identifier)
Method Detail

setThreaded

public void setThreaded(boolean threaded)
Determines whether batch publishing will be performed by a seperate thread, or by the thread that calls PublishMessages().

Specified by:
setThreaded in interface Publisher
Overrides:
setThreaded in class PublisherBean

isThreaded

public boolean isThreaded()
Returns true if batch publishing will be performed by a seperate thread, and false if by the thread that calls PublishMessages()

Specified by:
isThreaded in interface Publisher
Overrides:
isThreaded in class PublisherBean

addMessageBuilder

public void addMessageBuilder(MessageBuilder builder)
Adds a message builder that will create messages that will be written by the message publisher. The MessageBuilder's getMessage() method is called iteratively when the BatchPublisher is started. (The publisher is started by calling PublishMessages().) As long as the MessageBuilder returns a non-null message, that message will be published. When the builder's getMessage() method returns a null value, publishing is terminated, and the connection to the broker is closed.


removeMessageBuilder

public void removeMessageBuilder(MessageBuilder builder)
Removes a MessageBuilder from the set that will publish messages.


isPublishing

public boolean isPublishing()
Returns true if this is a threaded publisher and messages are currently being published.


getFocusBuilder

public int getFocusBuilder()

getFocusBuilderName

public java.lang.String getFocusBuilderName()

getTotalBuilders

public int getTotalBuilders()

run

public void run()
Called by the internal methods. NOTE: This method should NOT be directly invoked by a user application.

Specified by:
run in interface java.lang.Runnable

publishMessages

public void publishMessages()
                     throws java.lang.Exception
Called to initiate message publishing. The message builder should be set before calling this method.

Throws:
java.lang.Exception

setMaxRate

public void setMaxRate(int rate)
Sets the maximum rate of message publishing (in messages per second). A value of zero allows messages to be published at the maximum possible rate.


getMaxRate

public int getMaxRate()
Returns the maximum rate (in messages-per-second) at which message will be published. A value of zero indicates no maximum rate has been established.


halt

public void halt()
Terminate published messages. This is suitable only when the BatchPublisher is executed in threaded mode.

See Also:
setThreaded(boolean)

setControlMessageBuilder

public void setControlMessageBuilder(MessageBuilder mb)
Sets the control MessageBuilder that will create preliminary and a final control message. Setting a control message builder is optional.


getControlMessageBuilder

public MessageBuilder getControlMessageBuilder()
Returns a reference to the MessageBuilder that will create preliminary and final control messages.


(c) 2000 - 2003 MQue Systems
All Rights Reserved