xmlBlaster 2.2.0 API

org.xmlBlaster.client.qos
Class PublishQos

java.lang.Object
  extended by org.xmlBlaster.client.qos.PublishQos

public final class PublishQos
extends java.lang.Object

This class encapsulates the qos of a publish() message.

So you don't need to type the 'ugly' XML ASCII string by yourself. After construction access the ASCII-XML string with the toXml() method.
A typical publish qos in Publish/Subcribe mode could look like this:

  <qos>
     <priority>5</priority>
     <expiration lifeTime='60000' forceDestroy='false'/>
     <persistent />  <!-- The message shall be recoverable if xmlBlaster crashes -->
     <forceUpdate>true</forceUpdate>
     <readonly />
  </qos>
 
A typical publish qos in PtP mode could look like this:
  <qos>
     <destination queryType='EXACT' forceQueuing='true'>
        joe
     </destination>
     <destination>
        /node/heron/client/Tim/-2
     </destination>
  </qos>
 

see xmlBlaster/src/dtd/XmlQoS.xml

See Also:
MsgQosSaxFactory, publish interface

Field Summary
private  Global glob
           
private  MsgQosData msgQosData
           
 
Constructor Summary
PublishQos(Global glob)
          Default constructor for transient messages.
PublishQos(Global glob, boolean persistent)
           
PublishQos(Global glob, Destination destination)
          Default constructor for transient PtP messages.
PublishQos(Global glob, java.lang.String serialData)
           
 
Method Summary
 void addClientProperty(java.lang.String key, boolean value)
           
 void addClientProperty(java.lang.String key, byte value)
           
 void addClientProperty(java.lang.String key, double value)
           
 void addClientProperty(java.lang.String key, float value)
           
 void addClientProperty(java.lang.String key, int value)
           
 void addClientProperty(java.lang.String key, long value)
           
 void addClientProperty(java.lang.String key, java.lang.Object value)
          Sets a client property (an application specific property) to the given value
 void addClientProperty(java.lang.String key, short value)
           
 void addDestination(Destination destination)
          Add a destination where to send the message.
 ClientProperty getClientProperty(java.lang.String key)
          Read back a property.
 MsgQosData getData()
           
 PriorityEnum getPriority()
          Message priority.
 SessionName getSender()
          Access sender name.
 java.lang.String getState()
           
 java.lang.String getStateInfo()
           
 boolean isVolatile()
           
static void main(java.lang.String[] args)
          For testing invoke: java org.xmlBlaster.client.PublishQos
 void setAdministrative(boolean administrative)
           
 void setContentEncoding(java.lang.String encoding)
          Sets the encoding in the client properties of the content of the message to be published.
 void setForceDestroy(boolean forceDestroy)
          Control message life cycle on message expiry, defaults to false.
 void setForceUpdate(boolean force)
          Send message to subscriber even if the content is the same as the previous?
Default is that xmlBlaster does send messages to subscribed clients, even the content didn't change.
 void setLifeTime(long lifeTime)
          The message expires after given milliseconds.
 void setPersistent(boolean persistent)
          Mark a message to be persistent.
 void setPriority(PriorityEnum priority)
          Set message priority value, PriorityEnum.NORM_PRIORITY (5) is default.
 void setReadonly(boolean readonly)
          Mark a message to be readonly.
 void setSender(SessionName sender)
          Access sender name.
 void setState(java.lang.String state)
           
 void setStateInfo(java.lang.String stateInfo)
           
 void setSubscribable(boolean isSubscribable)
          As a default setting you can subscribe on all messages (PtP or PubSub).
 void setTopicProperty(TopicProperty topicProperty)
          Administer/configure the message topic.
 void setVolatile(boolean volatileFlag)
          Mark a message to be volatile or not.
 java.lang.String toString()
          Converts the data into a valid XML ASCII string.
 java.lang.String toXml()
          Converts the data into a valid XML ASCII string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

glob

private final Global glob

msgQosData

private final MsgQosData msgQosData
Constructor Detail

PublishQos

public PublishQos(Global glob,
                  java.lang.String serialData)

PublishQos

public PublishQos(Global glob)
Default constructor for transient messages.


PublishQos

public PublishQos(Global glob,
                  Destination destination)
Default constructor for transient PtP messages.

To make the message persistent, use the setPersistent() method

Parameters:
destination - The object containing the destination address.
To add more destinations, us the addDestination() method.

PublishQos

public PublishQos(Global glob,
                  boolean persistent)
Parameters:
persistent - true = store the message persistently
Method Detail

setContentEncoding

public void setContentEncoding(java.lang.String encoding)
Sets the encoding in the client properties of the content of the message to be published. Defaults to UTF-8 Is usually not interpreted by xmlBlaster. But special server plugins (like regex filter plugin may want to look into the content and should know the encoding or the receiving client may want to know. Note that "text/xml" contents are usually self contained, the processing instruction tells the xml encoding to the sax/dom parser and this clientProperty is ignored.

Parameters:
encoding - like "cp1252"

getData

public MsgQosData getData()

setSubscribable

public void setSubscribable(boolean isSubscribable)
As a default setting you can subscribe on all messages (PtP or PubSub).

Parameters:
isSubscribable - true if Publish/Subscribe style is used
false Only possible for PtP messages to keep PtP secret (you can't subscribe them)

getPriority

public PriorityEnum getPriority()
Message priority.

Returns:
priority 0 (=Lowest) - 9 (=Highest)

setPriority

public void setPriority(PriorityEnum priority)
Set message priority value, PriorityEnum.NORM_PRIORITY (5) is default. PriorityEnum.MIN_PRIORITY (0) is slowest whereas PriorityEnum.MAX_PRIORITY (9) is highest priority.

See Also:
The engine.qos.publish.priority requirement

setForceUpdate

public void setForceUpdate(boolean force)
Send message to subscriber even if the content is the same as the previous?
Default is that xmlBlaster does send messages to subscribed clients, even the content didn't change.


setReadonly

public void setReadonly(boolean readonly)
Mark a message to be readonly.
Only the first publish() will be accepted, followers are denied.


setVolatile

public void setVolatile(boolean volatileFlag)
Mark a message to be volatile or not.
A non-volatile messages stays in memory as long as the server runs or the message expires.
A volatile messages exists only during publish and processing it (doing the updates).
Defaults to false.
NOTE: This is a convenience method for setLifeTime(0L) and setForceDestroy(false).


isVolatile

public boolean isVolatile()
See Also:
isVolatile()

setPersistent

public void setPersistent(boolean persistent)
Mark a message to be persistent.


setLifeTime

public void setLifeTime(long lifeTime)
The message expires after given milliseconds.

Parameters:
lifeTime - in milliseconds
See Also:
MsgQosData.setLifeTime(long)

setForceDestroy

public void setForceDestroy(boolean forceDestroy)
Control message life cycle on message expiry, defaults to false.

Parameters:
forceDestroy - true Force message destroy on message expire
false On message expiry messages which are already in callback queues are delivered.

addDestination

public void addDestination(Destination destination)
Add a destination where to send the message.

Note you can invoke this multiple times to send to multiple destinations.

Note that the default lifeTime is set to 0 (PtP are volatile messages as default)

Parameters:
destination - The loginName of a receiver or some destination XPath query

getSender

public SessionName getSender()
Access sender name.

Returns:
loginName of sender or null if not known

setSender

public void setSender(SessionName sender)
Access sender name.

Parameters:
loginName - of sender

setAdministrative

public void setAdministrative(boolean administrative)

setState

public void setState(java.lang.String state)
Parameters:
state - The state to return to the server. e.g. Contants.STATE_OK, see Constants.java

getState

public java.lang.String getState()

setStateInfo

public void setStateInfo(java.lang.String stateInfo)
Parameters:
stateInfo - The state info attribute to return to the server.

getStateInfo

public java.lang.String getStateInfo()

setTopicProperty

public void setTopicProperty(TopicProperty topicProperty)
Administer/configure the message topic.


addClientProperty

public void addClientProperty(java.lang.String key,
                              java.lang.Object value)
Sets a client property (an application specific property) to the given value

Parameters:
key -
value -

addClientProperty

public void addClientProperty(java.lang.String key,
                              boolean value)

addClientProperty

public void addClientProperty(java.lang.String key,
                              int value)

addClientProperty

public void addClientProperty(java.lang.String key,
                              byte value)

addClientProperty

public void addClientProperty(java.lang.String key,
                              long value)

addClientProperty

public void addClientProperty(java.lang.String key,
                              short value)

addClientProperty

public void addClientProperty(java.lang.String key,
                              double value)

addClientProperty

public void addClientProperty(java.lang.String key,
                              float value)

getClientProperty

public ClientProperty getClientProperty(java.lang.String key)
Read back a property.

Returns:
The client property or null if not found

toString

public java.lang.String toString()
Converts the data into a valid XML ASCII string.

Overrides:
toString in class java.lang.Object
Returns:
An XML ASCII string

toXml

public java.lang.String toXml()
Converts the data into a valid XML ASCII string.

Returns:
An XML ASCII string

main

public static void main(java.lang.String[] args)
                 throws XmlBlasterException
For testing invoke: java org.xmlBlaster.client.PublishQos

Throws:
XmlBlasterException

xmlBlaster 2.2.0 API

Copyright © 1999-2014 The xmlBlaster.org contributers.