OSMQ
v2.0.1

osmq.clients
Interface Publisher

All Superinterfaces:
ClientAdapter
All Known Implementing Classes:
PublisherBean

public interface Publisher
extends ClientAdapter

A class used by client applications to write messages.

The Publisher dynamically locates and connects to a message broker. Once connected, the Publisher supports sending messages to a single recipient, or publishing anonymous topical messages to multiple subscribers.


Method Summary
 void close()
          Closes the message queues and halts message processing.
 void commit()
           Transmits all messages that were published since the last call to commit() or rollback().
 java.lang.String getBrokerName()
          Returns the name of the remote message broker for this session.
 java.lang.String getClientID()
          Returns the client identifier used by this session to communicate with the message broker.
 long getConnectionPublishedCount()
          Returns the number of messages that have been published using this publisher's connection.
 ExceptionListener getExceptionListener()
          Return the ExceptionListener that will be notified when there is an exception due to an inability to connect with the broker, or due to an I/O or communications failure.
 java.lang.String getHostName()
          Returns the message broker's host address as a DNS host name or IP address.
 int getPortID()
          Returns the port id that will be used to connect to the message broker.
 long getPublishedCount()
          Returns the number of messages that have been published by this Publisher.
 boolean isAutoCommit()
          Returns true if the publisher is in auto-commit mode.
 boolean isOpen()
          Returns true if there is a connection to the message broker.
 boolean isThreaded()
           
 void open()
          Locates and connects to the remote message broker, and performs the necessary publisher authentication.
 void publish(Message ds)
          Writes a message to the outbound queue.
 void rollback()
           Discards all messages that were published since the last call to commit() or rollback().
 void setAutoCommit(boolean autocommit)
          Turns on or off the autocommitment of published messages to the message broker.
 void setBrokerName(java.lang.String broker)
          Defines the named message broker that should be used for message processing (publishing).
 void setClientID(java.lang.String id)
          Sets the identity of the application as a message originator (publisher)
 void setExceptionListener(ExceptionListener listener)
          Sets an ExceptionListener that will be notified when there is an exception due to an inability to connect with the broker, or due to an I/O or communications failure.
 void setHostName(java.lang.String hostname)
          Overrides the host name / IP address of the remote server;
 void setPortID(int port)
          Overrides the port ID that the remote message server uses for connections.
 void setThreaded(boolean threaded)
           
 

Method Detail

open

public void open()
          throws java.io.IOException
Locates and connects to the remote message broker, and performs the necessary publisher authentication.

Specified by:
open in interface ClientAdapter
Throws:
java.io.IOException

setClientID

public void setClientID(java.lang.String id)
Sets the identity of the application as a message originator (publisher)

Specified by:
setClientID in interface ClientAdapter
Parameters:
id - a unique name identifying the client application to the message broker.

getClientID

public java.lang.String getClientID()
Returns the client identifier used by this session to communicate with the message broker.

Specified by:
getClientID in interface ClientAdapter

setBrokerName

public void setBrokerName(java.lang.String broker)
Defines the named message broker that should be used for message processing (publishing). Generally, this method should not be called. Rather, the default broker should be used, especially in a production environment.

Specified by:
setBrokerName in interface ClientAdapter

getBrokerName

public java.lang.String getBrokerName()
Returns the name of the remote message broker for this session.

Specified by:
getBrokerName in interface ClientAdapter

setPortID

public void setPortID(int port)
Overrides the port ID that the remote message server uses for connections.

NOTE: Normally this method should NOT be called by the client application.

Specified by:
setPortID in interface ClientAdapter

getPortID

public int getPortID()
Returns the port id that will be used to connect to the message broker. A value of 0 indicates that dynamic discovery will be used to identify the broker port.

Specified by:
getPortID in interface ClientAdapter
See Also:
setPortID(int)

setHostName

public void setHostName(java.lang.String hostname)
Overrides the host name / IP address of the remote server;

NOTE: Normally this method should NOT be called by the client application.

Specified by:
setHostName in interface ClientAdapter

getHostName

public java.lang.String getHostName()
Returns the message broker's host address as a DNS host name or IP address. This is the name that was set by the application. A value of null indicates that dynamic discovery will be used to identify the host address.

Specified by:
getHostName in interface ClientAdapter
See Also:
setHostName(String)

publish

public void publish(Message ds)
             throws java.io.IOException,
                    MessageException
Writes a message to the outbound queue. This object will be routed through the message broker to the appropriate recipient(s), based on the topic and recipient values found in the message; If a recipient ID has been set, the message will be routed only to that subscriber, even in the case where others have subscribed to the message topic.

Throws:
java.io.IOException
MessageException

isOpen

public boolean isOpen()
Returns true if there is a connection to the message broker.

Specified by:
isOpen in interface ClientAdapter

close

public void close()
Closes the message queues and halts message processing.

Specified by:
close in interface ClientAdapter

getPublishedCount

public long getPublishedCount()
Returns the number of messages that have been published by this Publisher.


getConnectionPublishedCount

public long getConnectionPublishedCount()
Returns the number of messages that have been published using this publisher's connection.


setExceptionListener

public void setExceptionListener(ExceptionListener listener)
Sets an ExceptionListener that will be notified when there is an exception due to an inability to connect with the broker, or due to an I/O or communications failure.

Specified by:
setExceptionListener in interface ClientAdapter

getExceptionListener

public ExceptionListener getExceptionListener()
Return the ExceptionListener that will be notified when there is an exception due to an inability to connect with the broker, or due to an I/O or communications failure.

Specified by:
getExceptionListener in interface ClientAdapter

setAutoCommit

public void setAutoCommit(boolean autocommit)
                   throws java.io.IOException
Turns on or off the autocommitment of published messages to the message broker.

When autocommit is ON, each message that is published gets transmitted to the message broker for distribution.

When autocommit is OFF, the user must call commit() to send published messages to the broker. Published messages that have not been committed can be discarded by a call to the method rollback().

The commit() method transmits all messages that were published since the last call to commit() or rollback(). NOTE: The default mode is autocommit ON.

Throws:
java.io.IOException - an attempt to set autocommit to true when there are messages that have been published but not commited or rolled back.
See Also:
commit(), rollback()

isAutoCommit

public boolean isAutoCommit()
Returns true if the publisher is in auto-commit mode.

See Also:
setAutoCommit(boolean)

commit

public void commit()
            throws java.io.IOException,
                   MessageException

Transmits all messages that were published since the last call to commit() or rollback(). This method is available when autocommit mode is OFF.

Throws:
java.io.IOException - autocommit mode is ON
MessageException
See Also:
rollback(), setAutoCommit(boolean)

rollback

public void rollback()
              throws java.io.IOException

Discards all messages that were published since the last call to commit() or rollback(). This method is available when autocommit mode is OFF.

Throws:
java.io.IOException - autocommit mode is ON
See Also:
commit(), setAutoCommit(boolean)

setThreaded

public void setThreaded(boolean threaded)

isThreaded

public boolean isThreaded()

(c) 2000 - 2003 MQue Systems
All Rights Reserved