|
xmlBlaster 2.2.0 client API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.xmlBlaster.util.dispatch.plugins.prio.PriorizedDispatchPlugin
public final class PriorizedDispatchPlugin
This dispatcher plugin allows to control how messages are sent to the remote side.
We subscribe to a status message which describes the current connection to the remote side. Depending on a status message we pick messages with specific priorities and send only these.
This allows for example to send all messages if a 2MBit connection is up, and send only high priority messages when the line drops to 64kBit.
The class ConfigurationParser Javadoc has an xml example of the configuration
This plugin class has only one instance per typeVersion for each Global scope. The xmlBlaster client used to subscribe to the status messages is a singleton (in Global.instance() scope).
Note that two status sources exist:
ConfigurationParser
,
org.xmlBlaster.test.dispatch.TestPriorizedDispatchPlugin
,
the dispatch.control.plugin requirementField Summary | |
---|---|
static java.lang.String |
CONFIG_PROPERTY_KEY
|
DispatchAction |
QUEUE_ACTION
|
Constructor Summary | |
---|---|
PriorizedDispatchPlugin()
|
Method Summary | |
---|---|
void |
addDispatchManager(I_DispatchManager dispatchManager)
This is called once for each dispatch manager using this plugin. |
boolean |
doActivate(I_DispatchManager dispatchManager)
Called when new messages are available. |
java.lang.String |
getType()
Enforced by I_Plugin |
java.lang.String |
getVersion()
Enforced by I_Plugin |
java.util.List<I_Entry> |
handleNextMessages(I_DispatchManager dispatchManager,
java.util.List<I_Entry> entries)
Enforced by I_MsgDispatchInterceptor. |
void |
init(Global glob,
PluginInfo pluginInfo)
Enforced by I_Plugin |
void |
initialize(Global glob,
java.lang.String typeVersion)
Is called by DispatchPluginManager after the instance is created. |
boolean |
isShutdown()
|
void |
onDispatchWorkerException(I_DispatchManager dispatchManager,
java.lang.Throwable ex)
Not doing anything in this method since no Exception handling is done. |
void |
postHandleNextMessages(I_DispatchManager dispatchManager,
MsgUnit[] processedEntries)
Not doing anything in this method since no cleanup needed. |
void |
propertyChanged(PropertyChangeEvent ev)
Invoked when the configuration PriorizedDispatchPlugin/config has changed. |
void |
shutdown()
Shutdown the implementation, sync with data store |
void |
shutdown(I_DispatchManager dispatchManager)
Deregister a dispatch manager. |
void |
statusChanged(java.lang.String status)
Changing the status of the dispatch strategy. |
void |
toAlive(I_DispatchManager dispatchManager,
ConnectionStateEnum oldState)
Call by DispatchConnectionsHandler on state transition. |
void |
toAliveSync(I_DispatchManager dispatchManager,
ConnectionStateEnum oldState)
|
void |
toDead(I_DispatchManager dispatchManager,
ConnectionStateEnum oldState,
XmlBlasterException xmlBlasterException)
Call by DispatchConnectionsHandler on state transition Enforced by interface I_ConnectionStatusListener |
void |
toPolling(I_DispatchManager dispatchManager,
ConnectionStateEnum oldState)
Call by DispatchConnectionsHandler on state transition Enforced by interface I_ConnectionStatusListener |
java.lang.String |
toXml(java.lang.String extraOffset)
|
java.lang.String |
usage()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String CONFIG_PROPERTY_KEY
public DispatchAction QUEUE_ACTION
Constructor Detail |
---|
public PriorizedDispatchPlugin()
Method Detail |
---|
public void initialize(Global glob, java.lang.String typeVersion) throws XmlBlasterException
initialize
in interface I_MsgDispatchInterceptor
XmlBlasterException
I_MsgDispatchInterceptor.initialize(Global, String)
public void addDispatchManager(I_DispatchManager dispatchManager)
addDispatchManager
in interface I_MsgDispatchInterceptor
public void propertyChanged(PropertyChangeEvent ev)
propertyChanged
in interface I_PropertyChangeListener
public void init(Global glob, PluginInfo pluginInfo)
init
in interface I_Plugin
I_Plugin.init(org.xmlBlaster.util.Global, PluginInfo)
public java.lang.String getType()
getType
in interface I_Plugin
public final java.lang.String getVersion()
getVersion
in interface I_Plugin
public final void statusChanged(java.lang.String status)
Enforced by I_Notify
On initialize: addPropertyChangeListener(this.CONFIG_PROPERTY_KEY, "startup", this); an initial event is fired an calls this method to initialize all attributes here
statusChanged
in interface I_Notify
public final boolean doActivate(I_DispatchManager dispatchManager)
doActivate
in interface I_MsgDispatchInterceptor
I_MsgDispatchInterceptor#doActivate(DispatchManager)
public final java.util.List<I_Entry> handleNextMessages(I_DispatchManager dispatchManager, java.util.List<I_Entry> entries) throws XmlBlasterException
NOTE: When copying entries from one queue to another one we have to take care that the reference counter in msgUnitStore is not temporary zero (and is garbage collected). This is avoided by a peek() and later remove() - which is necessary for persistent messages anyhow to ensure 100% crash safety.
handleNextMessages
in interface I_MsgDispatchInterceptor
entries
- null: Take messages yourself from queue (async mode) XmlBlasterException
I_MsgDispatchInterceptor#handleNextMessages(DispatchManager, ArrayList)
public final void toAlive(I_DispatchManager dispatchManager, ConnectionStateEnum oldState)
toAlive
in interface I_ConnectionStatusListener
public void toAliveSync(I_DispatchManager dispatchManager, ConnectionStateEnum oldState)
toAliveSync
in interface I_ConnectionStatusListener
public final void toPolling(I_DispatchManager dispatchManager, ConnectionStateEnum oldState)
toPolling
in interface I_ConnectionStatusListener
public final void toDead(I_DispatchManager dispatchManager, ConnectionStateEnum oldState, XmlBlasterException xmlBlasterException)
toDead
in interface I_ConnectionStatusListener
xmlBlasterException
- Can be nullpublic void shutdown(I_DispatchManager dispatchManager) throws XmlBlasterException
shutdown
in interface I_MsgDispatchInterceptor
XmlBlasterException
I_MsgDispatchInterceptor#shutdown(DispatchManager)
public void shutdown() throws XmlBlasterException
I_MsgDispatchInterceptor
shutdown
in interface I_MsgDispatchInterceptor
shutdown
in interface I_Plugin
XmlBlasterException
- if an exception occurs. The exception is
handled by the RunLevelManager depending on how the plugin has been
configured with the action:
<action do='STOP' onShutdownRunlevel='2' sequence='5'
onFail='resource.configuration.pluginFailed'>
If onFail is defined to something, the RunLevelManager will stop.public boolean isShutdown()
isShutdown
in interface I_MsgDispatchInterceptor
public java.lang.String usage()
usage
in interface I_MsgDispatchInterceptor
public java.lang.String toXml(java.lang.String extraOffset)
toXml
in interface I_MsgDispatchInterceptor
extraOffset
- Indent the dump with given ASCII blanks
I_MsgDispatchInterceptor.toXml(String)
public void postHandleNextMessages(I_DispatchManager dispatchManager, MsgUnit[] processedEntries) throws XmlBlasterException
postHandleNextMessages
in interface I_MsgDispatchInterceptor
dispatchManager
- The used dispatch manager.processedEntries
- The entries which have been previously processed.
XmlBlasterException
public void onDispatchWorkerException(I_DispatchManager dispatchManager, java.lang.Throwable ex)
onDispatchWorkerException
in interface I_MsgDispatchInterceptor
|
xmlBlaster 2.2.0 client API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |