xmlBlaster 2.2.0 API

org.xmlBlaster.util.checkpoint
Class Checkpoint

java.lang.Object
  extended by org.xmlBlaster.util.checkpoint.Checkpoint
All Implemented Interfaces:
I_AdminPlugin, I_AdminService, I_AdminUsage, CheckpointMBean, I_Checkpoint, I_Plugin

public class Checkpoint
extends java.lang.Object
implements I_Checkpoint

Plugin to trace the message flow into log files.

Currently there are 4 checkpoints defined inside the xmlBlaster core (see I_Checkpoint.java).
You can add a client property (e.g. "wfguid") to your PublishQos and register this here with filterClientPropertyKey="wfguid". When such a marked message passes one of the checkpoints a logging entry will be written to a log file (as configured in logging.properties). See logging.properties for examples on how to control which checkpoints are logged and if the complete message shall be dumped.

Is adjustable during runtime using JMX (jconsole)

Needs to be loaded in xmlBlasterPlugins.xml at run level 1:

  <plugin create='true' id='Checkpoint' className='org.xmlBlaster.util.checkpoint.Checkpoint'>
  <action do='LOAD' onStartupRunlevel='1' sequence='1'
  onFail='resource.configuration.pluginFailed'/>
  <action do='STOP' onShutdownRunlevel='0' sequence='1'/>
  <attribute id='filterClientPropertyKey'>wfguid</attribute>
  <attribute id='xmlStyle'>true</attribute>
  <attribute id='showAllMessages'>false</attribute>
  <attribute id='showAllClientProperties'>false</attribute>
  </plugin>
 
If showAllMessages is set to true all messages are logged and the filter is ignored.

A typical log entry looks like this:

 Oct 20, 2007 7:14:29 PM org.xmlBlaster.util.checkpoint.Checkpoint passingBy
  INFO: <cp>publish.ack</cp> <topicId>Hello</topicId> <wfguid>234345667777</wfguid> <sender>client/Publisher/1</sender>
 
or if you set xmlStyle to false like this:
 Oct 20, 2007 7:26:46 PM org.xmlBlaster.util.checkpoint.Checkpoint passingBy
  INFO: [cp=update.ack] [topicId=Hello] [wfguid=234345667777] [sender=client/Publisher/1] [destination=client/Subscribe/1]
 
You can extend this class and change the output style by overwriting the method append()

Author:
Marcel Ruff
See Also:
The admin.checkpoint requirement

Field Summary
protected  ContextNode contextNode
           
protected  java.lang.String[] excludeIfKeys
          If given messages containing such keys are not logged
protected  java.lang.String filterClientPropertyKey
          If given will be used to filter which messages are logged
protected  java.lang.String[] filterKeys
          Is parsed from comma separated list of filterClientPropertyKey
private  Global glob
           
private static java.util.logging.Logger log
          Normal logging
protected  java.lang.String log4jConfiguration
           
protected  org.apache.commons.logging.Log[] loggers
          Checkpoint logging
protected  java.lang.String logImpl
           
protected  java.lang.Object mbeanHandle
          My JMX registration
private  java.lang.String ME
           
private  PluginInfo pluginInfo
          xmlBlasterPlugins.xml awareness
private  boolean running
           
private  ServerScope serverScope
           
protected  boolean showAllClientProperties
           
protected  boolean showAllMessages
          If false show only messages marked by filterClientPropertyKey=wfguid
private  boolean shutdown
           
protected  boolean xmlStyle
           
 
Fields inherited from interface org.xmlBlaster.util.checkpoint.I_Checkpoint
CP_CONNECTION_PUBLISH_ACK, CP_CONNECTION_PUBLISH_ENTER, CP_NAMES, CP_PUBLISH_ACK, CP_PUBLISH_ENTER, CP_UPDATE_ACK, CP_UPDATE_QUEUE_ADD
 
Constructor Summary
Checkpoint()
           
 
Method Summary
 void activate()
          Activate this service
protected  void append(java.lang.StringBuilder buf, java.lang.String key, java.lang.String value)
          Format the key/value output.
 void deActivate()
          Deactivate the service to standby.
 java.lang.String getCheckpointList()
          A comma separated list of checkpoints used
 java.lang.String getFilter()
           
 java.lang.String getType()
          The unique name of the plugin (together with the version).
 java.lang.String getUsageUrl()
           
 java.lang.String getVersion()
          The version of the plugin
 void init(Global glob, PluginInfo pluginInfo)
          This method is called by the PluginManager.
 boolean isActive()
          Access the current state
private  boolean isClusterEnvironment()
           
 boolean isShowAllClientProperties()
           
 boolean isShowAllMessages()
           
 boolean isShutdown()
          Check status
 boolean isXmlStyle()
           
 void passingBy(int checkpoint, MsgUnit msgUnit, SessionName destination, java.lang.String[] context)
          A message is passing a checkpoint.
 void setExcludeIf(java.lang.String excludeIfClientPropertyKey)
          If one of the keys is found the checkpoint is not logged.
 void setFilter(java.lang.String filterClientPropertyKey)
          A key (or a key-list) of a ClientProperty, only those messages containing such a ClientProperty are logged
 void setShowAllClientProperties(boolean showAllClientProperties)
           
 void setShowAllMessages(boolean showAllMessages)
           
 void setUsageUrl(java.lang.String url)
           
 void setXmlStyle(boolean xmlStyle)
           
 void shutdown()
          Shutdown the plugin, free resources.
 java.lang.String usage()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ME

private java.lang.String ME

glob

private Global glob

serverScope

private ServerScope serverScope

log

private static java.util.logging.Logger log
Normal logging


loggers

protected org.apache.commons.logging.Log[] loggers
Checkpoint logging
 fatal error warn info debug trace
 

See Also:
http://commons.apache.org/logging/guide.html#Quick%20Start

pluginInfo

private PluginInfo pluginInfo
xmlBlasterPlugins.xml awareness


running

private boolean running

shutdown

private boolean shutdown

mbeanHandle

protected java.lang.Object mbeanHandle
My JMX registration


contextNode

protected ContextNode contextNode

excludeIfKeys

protected java.lang.String[] excludeIfKeys
If given messages containing such keys are not logged


filterClientPropertyKey

protected java.lang.String filterClientPropertyKey
If given will be used to filter which messages are logged


filterKeys

protected java.lang.String[] filterKeys
Is parsed from comma separated list of filterClientPropertyKey


showAllClientProperties

protected boolean showAllClientProperties

showAllMessages

protected boolean showAllMessages
If false show only messages marked by filterClientPropertyKey=wfguid


xmlStyle

protected boolean xmlStyle

log4jConfiguration

protected java.lang.String log4jConfiguration

logImpl

protected java.lang.String logImpl
Constructor Detail

Checkpoint

public Checkpoint()
Method Detail

passingBy

public void passingBy(int checkpoint,
                      MsgUnit msgUnit,
                      SessionName destination,
                      java.lang.String[] context)
Description copied from interface: I_Checkpoint
A message is passing a checkpoint. Note: This method may never throw any exceptions

Specified by:
passingBy in interface I_Checkpoint
Parameters:
checkpoint - The checkpoint, e.g. CP_PUBLISH_ACK
msgUnit - The message processed
destination - Can be null
context - Additional key values like { "subscriptionId", "__suvbId:2349", "comment", "blabla" }

append

protected void append(java.lang.StringBuilder buf,
                      java.lang.String key,
                      java.lang.String value)
Format the key/value output. Default is xml style

Parameters:
buf -
key -
value -

init

public void init(Global glob,
                 PluginInfo pluginInfo)
          throws XmlBlasterException
Description copied from interface: I_Plugin
This method is called by the PluginManager.

Example how options are evaluated:

   // An entry in xmlBlaster.properties (in one line):
   MimeSubscribePlugin[ContentLenFilter][1.0]=\
                 org.xmlBlaster.engine.mime.demo.ContentLenFilter,\
                 DEFAULT_MAX_LEN=200,DEFAULT_MIN_LEN=20

  // Access it like this:
  java.util.Properties props = pluginInfo.getParameters();
  String maxLen = (String)props.get("DEFAULT_MAX_LEN");
  String throwLen = (String)props.get("THROW_EXCEPTION_FOR_LEN");
 

Specified by:
init in interface I_Plugin
Throws:
XmlBlasterException

isClusterEnvironment

private final boolean isClusterEnvironment()

getType

public java.lang.String getType()
Description copied from interface: I_AdminPlugin
The unique name of the plugin (together with the version).

Specified by:
getType in interface I_AdminPlugin
Specified by:
getType in interface I_Plugin
Returns:
For example "IOR"

getVersion

public java.lang.String getVersion()
Description copied from interface: I_AdminPlugin
The version of the plugin

Specified by:
getVersion in interface I_AdminPlugin
Specified by:
getVersion in interface I_Plugin
Returns:
For example "1.0"

shutdown

public void shutdown()
              throws XmlBlasterException
Description copied from interface: I_AdminPlugin
Shutdown the plugin, free resources.

Specified by:
shutdown in interface I_AdminPlugin
Specified by:
shutdown in interface I_Plugin
Throws:
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.


getCheckpointList

public java.lang.String getCheckpointList()
Description copied from interface: CheckpointMBean
A comma separated list of checkpoints used

Specified by:
getCheckpointList in interface CheckpointMBean
Returns:
"publish.ack,update.ack,update.queue.add"

activate

public void activate()
              throws java.lang.Exception
Description copied from interface: I_AdminService
Activate this service

Specified by:
activate in interface I_AdminService
Throws:
java.lang.Exception

deActivate

public void deActivate()
Description copied from interface: I_AdminService
Deactivate the service to standby. A call to activate() fires the service up again

Specified by:
deActivate in interface I_AdminService

isActive

public boolean isActive()
Description copied from interface: I_AdminService
Access the current state

Specified by:
isActive in interface I_AdminService
Returns:
true if active

isShutdown

public boolean isShutdown()
Description copied from interface: I_AdminPlugin
Check status

Specified by:
isShutdown in interface I_AdminPlugin
Returns:
true if down

getUsageUrl

public java.lang.String getUsageUrl()
Specified by:
getUsageUrl in interface I_AdminUsage
Returns:
A link on javadoc for JMX usage

setUsageUrl

public void setUsageUrl(java.lang.String url)
Specified by:
setUsageUrl in interface I_AdminUsage

usage

public java.lang.String usage()
Specified by:
usage in interface I_AdminUsage
Returns:
a human readable usage help string

isShowAllClientProperties

public boolean isShowAllClientProperties()
Specified by:
isShowAllClientProperties in interface CheckpointMBean
Returns:
the showAllClientProperties

setShowAllClientProperties

public void setShowAllClientProperties(boolean showAllClientProperties)
Specified by:
setShowAllClientProperties in interface CheckpointMBean
Parameters:
showAllClientProperties - the showAllClientProperties to set

isShowAllMessages

public boolean isShowAllMessages()
Specified by:
isShowAllMessages in interface CheckpointMBean
Returns:
If set to true the getFilter() is ignored

setShowAllMessages

public void setShowAllMessages(boolean showAllMessages)
Specified by:
setShowAllMessages in interface CheckpointMBean
Parameters:
showAllMessages - If set to true the getFilter() is ignored

getFilter

public java.lang.String getFilter()
Specified by:
getFilter in interface CheckpointMBean
Returns:
the filterClientPropertyKey

setFilter

public void setFilter(java.lang.String filterClientPropertyKey)
A key (or a key-list) of a ClientProperty, only those messages containing such a ClientProperty are logged

Specified by:
setFilter in interface CheckpointMBean
Parameters:
filterClientPropertyKey - A client property key like "wfguid" or a comma separated list of keys like "transId,wfguid,guid"

setExcludeIf

public void setExcludeIf(java.lang.String excludeIfClientPropertyKey)
If one of the keys is found the checkpoint is not logged.

Parameters:
excludeIfClientPropertyKey - comma separated list

isXmlStyle

public boolean isXmlStyle()
Specified by:
isXmlStyle in interface CheckpointMBean
Returns:
the xmlStyle

setXmlStyle

public void setXmlStyle(boolean xmlStyle)
Specified by:
setXmlStyle in interface CheckpointMBean
Parameters:
xmlStyle - the xmlStyle to set

xmlBlaster 2.2.0 API

Copyright © 1999-2014 The xmlBlaster.org contributers.