xmlBlaster 2.2.0 client API

org.xmlBlaster.util.qos
Class MsgQosData

java.lang.Object
  extended by org.xmlBlaster.util.qos.QosData
      extended by org.xmlBlaster.util.qos.MsgQosData
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable

public final class MsgQosData
extends QosData
implements java.io.Serializable, java.lang.Cloneable

Data container handling of publish() and update() quality of services.

QoS Informations sent from the client to the server via the publish() method and back via the update() method
They are needed to control xmlBlaster and inform the client.

This data holder is accessible through 4 decorators, each of them allowing a specialized view on the data:

For the xml representation see MsgQosSaxFactory.

Author:
xmlBlaster@marcelruff.info
See Also:
MsgQosSaxFactory, org.xmlBlaster.test.classtest.qos.MsgQosFactoryTest, The interface.publish requirement, Serialized Form

Field Summary
static boolean DEFAULT_administrative
           
static boolean DEFAULT_forceDestroy
           
static boolean DEFAULT_forceUpdate
          Send message to subscriber even the content is the same as the previous?
Default is that xmlBlaster does send messages to subscribed clients, even the content didn't change.
static boolean DEFAULT_isSubscribable
           
static long DEFAULT_lifeTime
           
protected  Destination[] destinationArrCache
           
protected  java.util.ArrayList destinationList
          ArrayList for loginQoS, holding all destination addresses (Destination objects)
static Destination[] EMPTY_DESTINATION_ARR
           
 
Fields inherited from class org.xmlBlaster.util.qos.QosData
DEFAULT_persistent, glob, rcvTimestamp, routeNodeList, routeNodes, serialData
 
Constructor Summary
MsgQosData(Global glob, I_MsgQosFactory factory, MethodName methodName)
          Constructs the specialized quality of service object for a publish() or update() call.
MsgQosData(Global glob, I_MsgQosFactory factory, java.lang.String serialData, MethodName methodName)
          Constructs the specialized quality of service object for a publish() call.
MsgQosData(Global glob, MethodName methodName)
          Constructs the specialized quality of service object for a publish() or update() call.
 
Method Summary
 void addDestination(Destination destination)
          Add a destination.
 java.lang.Object clone()
          Returns a partly deep clone, you can change safely all basic or immutable types like boolean, String, int.
 PropBoolean getAdministrativeProp()
           
 Destination[] getDestinationArr()
           
 java.util.ArrayList getDestinations()
          Get all the destinations of this message.
 PropBoolean getForceDestroyProp()
           
 PropBoolean getForceUpdateProp()
           
 long getLifeTime()
          The life time of the message or -1L if forever
 PropLong getLifeTimeProp()
           
static long getMaxLifeTime()
          The server default for max.
 int getNumDestinations()
           
 PriorityEnum getPriority()
          Message priority.
 long getQueueIndex()
           
 long getQueueSize()
           
 java.lang.String getRcvTime()
          Deprecated. Use getXmlRcvTimestamp()
 int getRedeliver()
          Returns > 0 if the message probably is redelivered.
 long getRemainingLife()
           
 long getRemainingLifeStatic()
          This is the value delivered in the QoS (as it was calculated by the server on sending) and is NOT dynamically recalculated.
 PropBoolean getSubscribableProp()
           
 java.lang.String getSubscriptionId()
          If Pub/Sub style update: contains the subscribe ID which caused this update
 TopicProperty getTopicProperty()
          The configuration for the TopicHandler (topic)
 java.lang.String getXmlRcvTimestamp()
          Tagged form of message receive, e.g.:
<rcvTimestamp nanos='1007764305862000004'/>
 boolean hasTopicProperty()
          The getTopicProperty() creates an initial TopicHandler, this method allows to check without creation
 void incrRedeliver()
          Increment the redeliver counter
 boolean isAdministrative()
           
 boolean isExpired()
          Calculates if we are expired
 boolean isForceDestroy()
           
 boolean isForceUpdate()
           
 boolean isFromPersistenceStore()
          Internal use only, is this message sent from the persistence layer?
 boolean isPtp()
          Test if Point to Point addressing style is used.
 boolean isReadonly()
           
 boolean isSubscribable()
          Test if Publish/Subscribe style is used.
 boolean isVolatile()
           
static void main(java.lang.String[] args)
           
 void removeDestination(Destination destination)
          Remove a destination.
 void setAdministrative(boolean administrative)
          Marks a message to be administrative only, in this case the topic is configured only.
 void setForceDestroy(boolean forceDestroy)
          Control message life cycle on message expiry, defaults to false.
 void setForceUpdate(boolean forceUpdate)
          Send message to subscriber even if the content is the same as the previous.
 void setFromPersistenceStore(boolean fromPersistenceStore)
          Internal use only, set if this message sent from the persistence layer
 void setGlobal(Global glob)
          Sets the global object (used when deserializing the object)
 void setLifeTime(long lifeTime)
          Control the life time of a message.
 void setPriority(PriorityEnum priority)
          Set message priority value, PriorityEnum.NORM_PRIORITY (5) is default.
 void setQueueIndex(long queueIndex)
           
 void setQueueSize(long queueSize)
           
 void setReadonly(boolean readonly)
           
 void setRedeliver(int redeliver)
          Set > 0 if the message probably is redelivered (number of retries).
 void setRemainingLifeStatic(long remainingLifeStatic)
           
 void setSubscribable(boolean isSubscribable)
           
 void setSubscriptionId(java.lang.String subscriptionId)
          If Pub/Sub style update: contains the subscribe ID which caused this update
 void setTopicProperty(TopicProperty topicProperty)
           
 void setVolatile(boolean volatileFlag)
           
 java.util.Hashtable toJXPath()
          Dump the QoS to a flattened JXPath representation.
 java.lang.String toString()
           
 java.lang.String toXml()
          Dump state of this object into a XML ASCII string.
 java.lang.String toXml(java.lang.String extraOffset)
           
 java.lang.String toXml(java.lang.String extraOffset, java.util.Properties props)
          Dump state of this object into a XML ASCII string.
 
Methods inherited from class org.xmlBlaster.util.qos.QosData
addClientProperty, addClientProperty, addClientProperty, addClientProperty, addClientProperty, addClientProperty, addClientProperty, addClientProperty, addClientProperty, addClientProperty, addRouteInfo, clearRoutes, count, dirtyRead, getClientProperties, getClientProperty, getClientProperty, getClientProperty, getClientProperty, getClientProperty, getClientProperty, getClientProperty, getClientProperty, getClientProperty, getClientProperty, getClientPropertyArr, getContentCharset, getContentStr, getContentStrNoEx, getGlobal, getMethod, getNumRouteNodes, getPersistentProp, getRcvTimestamp, getRcvTimestampNotNull, getRouteNodes, getSender, getState, getStateInfo, hasStateInfo, isAtMaster, isErase, isErased, isForwardError, isFromPersistenceRecovery, isFromPersistenceRecovery, isGet, isOk, isPersistent, isPublish, isSubscribe, isTimeout, isUnSubscribe, isUpdate, propertyExists, setMethod, setPersistent, setRcvTimestamp, setSender, setState, setStateInfo, size, touchRcvTimestamp, toXmlReadable, writePropertiesXml, writePropertiesXml
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_isSubscribable

public static final transient boolean DEFAULT_isSubscribable
See Also:
Constant Field Values

DEFAULT_forceUpdate

public static final transient boolean DEFAULT_forceUpdate
Send message to subscriber even the content is the same as the previous?
Default is that xmlBlaster does send messages to subscribed clients, even the content didn't change.

See Also:
Constant Field Values

DEFAULT_lifeTime

public static final long DEFAULT_lifeTime

DEFAULT_administrative

public static final transient boolean DEFAULT_administrative
See Also:
Constant Field Values

DEFAULT_forceDestroy

public static final transient boolean DEFAULT_forceDestroy
See Also:
Constant Field Values

destinationList

protected java.util.ArrayList destinationList
ArrayList for loginQoS, holding all destination addresses (Destination objects)


destinationArrCache

protected transient Destination[] destinationArrCache

EMPTY_DESTINATION_ARR

public static final Destination[] EMPTY_DESTINATION_ARR
Constructor Detail

MsgQosData

public MsgQosData(Global glob,
                  MethodName methodName)
Constructs the specialized quality of service object for a publish() or update() call.


MsgQosData

public MsgQosData(Global glob,
                  I_MsgQosFactory factory,
                  MethodName methodName)
Constructs the specialized quality of service object for a publish() or update() call.

Parameters:
factory - The factory which knows how to serialize and parse me

MsgQosData

public MsgQosData(Global glob,
                  I_MsgQosFactory factory,
                  java.lang.String serialData,
                  MethodName methodName)
Constructs the specialized quality of service object for a publish() call. For internal use only, this message is sent from the persistence layer

Parameters:
the - XML based ASCII string
Method Detail

setSubscribable

public void setSubscribable(boolean isSubscribable)
See Also:
isSubscribable()

isSubscribable

public boolean isSubscribable()
Test if Publish/Subscribe style is used.

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

getSubscribableProp

public PropBoolean getSubscribableProp()

isPtp

public boolean isPtp()
Test if Point to Point addressing style is used.

Returns:
true if addressing of the destination is used false if Publish/Subscribe style is used

setVolatile

public void setVolatile(boolean volatileFlag)
Parameters:
volatile - true sets lifeTime=0 and forceDestroy=false
false: does nothing

isVolatile

public boolean isVolatile()
Returns:
true/false

setSubscriptionId

public void setSubscriptionId(java.lang.String subscriptionId)
If Pub/Sub style update: contains the subscribe ID which caused this update

Parameters:
subscriptionId - null if PtP message

getSubscriptionId

public java.lang.String getSubscriptionId()
If Pub/Sub style update: contains the subscribe ID which caused this update

Returns:
subscribeId or null if PtP message

setForceUpdate

public void setForceUpdate(boolean forceUpdate)
Send message to subscriber even if the content is the same as the previous.

Parameters:
forceUpdate -
See Also:
The engine.qos.publish.forceUpdate requirement

isForceUpdate

public boolean isForceUpdate()
Returns:
true/false

getForceUpdateProp

public PropBoolean getForceUpdateProp()

setReadonly

public void setReadonly(boolean readonly)

isReadonly

public boolean isReadonly()
Returns:
true/false

setRedeliver

public void setRedeliver(int redeliver)
Set > 0 if the message probably is redelivered (number of retries).

Parameters:
redeliver - if == 0 The message is guaranteed to be delivered only once.

incrRedeliver

public void incrRedeliver()
Increment the redeliver counter


getRedeliver

public int getRedeliver()
Returns > 0 if the message probably is redelivered.

Returns:
== 0 The message is guaranteed to be delivered only once.

setQueueSize

public void setQueueSize(long queueSize)
Parameters:
queueSize - The number of queued messages

getQueueSize

public long getQueueSize()
Returns:
The number of queued messages

setQueueIndex

public void setQueueIndex(long queueIndex)
Parameters:
queueIndex - The index of the message in the queue

getQueueIndex

public long getQueueIndex()
Returns:
The index of the message in the queue

getPriority

public PriorityEnum getPriority()
Message priority.

Returns:
priority 0-9
See Also:
PriorityEnum

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:
PriorityEnum

isFromPersistenceStore

public boolean isFromPersistenceStore()
Internal use only, is this message sent from the persistence layer?

Returns:
true/false

setFromPersistenceStore

public void setFromPersistenceStore(boolean fromPersistenceStore)
Internal use only, set if this message sent from the persistence layer

Parameters:
true/false -

getLifeTime

public long getLifeTime()
The life time of the message or -1L if forever


getLifeTimeProp

public PropLong getLifeTimeProp()

setLifeTime

public void setLifeTime(long lifeTime)
Control the life time of a message.

This value is calculated relative to the rcvTimestamp in the xmlBlaster server.

Passing -1 milliseconds asks the server for unlimited livespan, which the server may or may not grant.

Parameters:
lifeTime - The life time of the message or -1L if forever.

Setting to 0 will behave as a volatile message (see setVolatile()) and the message will be invisible directly after being pushed into the subscribers callback queues, in the callback queues it will stay until retrieved by the subscriber.

Setting it to a value > 0 will expire the message after the given milliseconds, even if they remain in any callback queue.


getRemainingLife

public long getRemainingLife()
Returns:
Milliseconds until message expiration (from now) or -1L if forever if 0L the message is expired

getRemainingLifeStatic

public long getRemainingLifeStatic()
This is the value delivered in the QoS (as it was calculated by the server on sending) and is NOT dynamically recalculated. So trust this value only if your client clock is out of date (or not trusted) and if you know the message sending latency is not too big.

Returns:
Milliseconds until message expiration (from now) or -1L if forever if 0L the message is expired

setRemainingLifeStatic

public void setRemainingLifeStatic(long remainingLifeStatic)

isExpired

public boolean isExpired()
Calculates if we are expired


getMaxLifeTime

public static long getMaxLifeTime()
The server default for max. span of life, adjustable with property "message.maxLifeTime"

Returns:
max span of life for a message

getXmlRcvTimestamp

public java.lang.String getXmlRcvTimestamp()
Tagged form of message receive, e.g.:
<rcvTimestamp nanos='1007764305862000004'/>

See Also:
Timestamp

getRcvTime

public java.lang.String getRcvTime()
Deprecated. Use getXmlRcvTimestamp()

Human readable form of message receive time in xmlBlaster server, in SQL representation e.g.:
2001-12-07 23:31:45.862000004

Overrides:
getRcvTime in class QosData

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.
See Also:
The engine.qos.publish.isVolatile requirement

isForceDestroy

public boolean isForceDestroy()
Returns:
true/false, defaults to false

getForceDestroyProp

public PropBoolean getForceDestroyProp()

setAdministrative

public void setAdministrative(boolean administrative)
Marks a message to be administrative only, in this case the topic is configured only. Note the administrative messages have a default priority of MAX_PRIORITY

Parameters:
administrative - true The message is only used to configure the topic
false The message contains useful content (and may as initial publish configure the topic as well)
See Also:
PriorityEnum

isAdministrative

public boolean isAdministrative()
Returns:
true/false, defaults to false

getAdministrativeProp

public PropBoolean getAdministrativeProp()

getDestinations

public java.util.ArrayList getDestinations()
Get all the destinations of this message. This should only be used with PTP style messaging
Check if (isPtp()) ... before calling this method

Returns:
a valid ArrayList containing 0 - n Strings with destination names (loginName of clients)
null if Publish/Subscribe style is used

getNumDestinations

public int getNumDestinations()

getDestinationArr

public Destination[] getDestinationArr()
Returns:
The destinations in array form, never null

addDestination

public void addDestination(Destination destination)
Add a destination. Note that the default lifeTime is set to 0 (PtP are volatile as default)


removeDestination

public void removeDestination(Destination destination)
Remove a destination.


hasTopicProperty

public boolean hasTopicProperty()
The getTopicProperty() creates an initial TopicHandler, this method allows to check without creation


getTopicProperty

public TopicProperty getTopicProperty()
The configuration for the TopicHandler (topic)

Returns:
never null (a default is created if none is available)

setTopicProperty

public void setTopicProperty(TopicProperty topicProperty)
Parameters:
The - new topicProperty, usually you should create the instance with getTopicProperty() to not loose any readonly settings.
null resets the settings

toJXPath

public java.util.Hashtable toJXPath()
Dump the QoS to a flattened JXPath representation.

This is experimental code for the simple Applet client

   /qos/rcvTimestamp/@nanos                  -> 1042815836675000001
   /qos/methodName/text()                    -> update
   /qos/clientProperty[@name='myAge']/text() -> 12
   /qos/state/@id                            -> OK
 

Currently only an UpdateQos dump is supported

See Also:
Apache JXPath

toXml

public java.lang.String toXml()
Dump state of this object into a XML ASCII string.

Specified by:
toXml in class QosData
Returns:
internal state of the message QoS as a XML ASCII string

toXml

public java.lang.String toXml(java.lang.String extraOffset)

toXml

public java.lang.String toXml(java.lang.String extraOffset,
                              java.util.Properties props)
Dump state of this object into a XML ASCII string.

Specified by:
toXml in class QosData
Parameters:
extraOffset - indenting of tags for nice output
forceReadable - If true, any base64 is decoded to be more human readable
Returns:
internal state of the message QoS as a XML ASCII string

clone

public java.lang.Object clone()
Returns a partly deep clone, you can change safely all basic or immutable types like boolean, String, int. Currently TopicProperty is not cloned (so don't change it)

Overrides:
clone in class QosData

setGlobal

public void setGlobal(Global glob)
Sets the global object (used when deserializing the object)

Overrides:
setGlobal in class QosData

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

main

public static void main(java.lang.String[] args)

xmlBlaster 2.2.0 client API

Copyright © 1999-2014 The xmlBlaster.org contributers.