|
xmlBlaster 1.6.2 API | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectjavax.management.NotificationBroadcasterSupport
org.xmlBlaster.engine.EventPlugin
Registers for events from the xmlBlaster core and forwards them as configured.
This is useful for clients or administrators to be notified on certain core events.
This EventPlugin plugin is started with the run level manager as
configured in xmlBlasterPlugins.xml, for example:
<plugin id='EventPlugin' className='org.xmlBlaster.engine.EventPlugin'>
<action do='LOAD' onStartupRunlevel='7' sequence='11'
onFail='resource.configuration.pluginFailed'/>
<action do='STOP' onShutdownRunlevel='6' sequence='11'/>
<attribute id='eventTypes'>
logging/severe/*,
logging/warning/*,
service/RunlevelManager/event/startupRunlevel8,
client/joe/session/1/event/connect
</attribute>
<attribute id='destination.smtp'>
mail.smtp.from=xmlBlaster@localhost,
mail.smtp.to=demo@localhost,
mail.collectMillis=10000
</attribute>
<attribute id='destination.jmx'/>
</plugin>
In the above example an email is send if any logging/severe/* (==log/error) or logging/warning/* occurs.
Further an event is emitted on xmlBlaster startup in run level 8
and if a new client logs in.
Those events are send as JMX notifications as well.
Adding <attribute id='destination.publish'/> would send
the event as a xmlBlaster message as well, but take care to not send logging events
as such messages will most certainly loop (if they log something they will trigger another message and so forth)!
List of supported event sources, note that this plugin must be active on a runlevel early enough depending on the event you want to capture:
| logging/severe/* | Captures all errors logged |
| logging/warning/* | Captures all warnings logged |
| service/RunlevelManager/event/startupRunlevel9 | Captures event when startup run level reaches 9 (RUNNING), any other runlevel is possible as well (note that this plugin must be active beforehand) |
| service/RunlevelManager/event/shutdownRunlevel8 | Captures event when shutdown runlevel reaches 8 (RUNNING_RPE), any other run level is possible as well (note that this plugin must be active beforehand) |
| client/* /session/* /event/connect | Captures event on client login (all clients) |
| client/[subjectId]/session/[publicSessionId]/event/connect | Captures event on given client login, e.g. "client/joe/session/1/event/connect" |
| client/* /session/* /event/disconnect | Captures event on client logout (all clients) |
| client/[subjectId]/session/[publicSessionId]/event/disconnect | Captures event on given client logout, e.g. "client/joe/session/1/event/disconnect" |
| topic/* /event/subscribe | Captures if subscribe() is invoked (on all topics) |
| topic/[topicId]/event/subscribe | Captures if subscribe() on the specified topic is invoked |
| client/[subjectId]/session/[publicSessionId]/event/subscribe | Captures if the given client has invoked subscribe(), e.g. "client/joe/session/1/event/subscribe". The publicSessionId can be a wildcard "*". |
| topic/* /event/unSubscribe | Captures if unSubscribe() is invoked (on all topics) |
| topic/[topicId]/event/unSubscribe | Captures if unSubscribe() on the specified topic is invoked |
| client/[subjectId]/session/[publicSessionId]/event/unSubscribe | Captures if the given client has invoked unSubscribe(), e.g. "client/joe/session/1/event/unSubscribe". The publicSessionId can be a wildcard "*". |
| topic/* /event/alive | Captures if a topic is created (on all topics) |
| topic/hello/event/alive | Captures event if the topic 'hello' is created |
| topic/* /event/dead | Captures if a topic is destroyed (on all topics) |
| topic/hello/event/dead | Captures event if the topic 'hello' is destroyed |
| client/[subjectId]/session/[publicSessionId]/event/callbackState | Captures event if the client callback server goes to ALIVE or POLLING. Note that the status change to DEAD is currently not implemented (it is reported as POLLING). Wildcards are not supported. |
| heartbeat.360000 | Sends a heartbeat notification every given milli seconds. Setting heartbeat defaults to one notification per day (86400000 millis). |
List of supported event sinks:
| destination.smtp | Sends an email about the occurred event.
Collects multiple events to one mail depending on configuration.
You need to configure at least the email address parameters
mail.stmp.from and mail.smtp.to and
activate the SmtpClient plugin in xmlBlasterPlugins.xml.
If you have a reasonable email provider you can configure it to
forward the mail as an SMS (mine offers this feature). |
| destination.publish | Publishes an xmlBlaster message which contains the occurred event, currently all messages are published into a topic named '__sys__Event' |
| destination.jmx | Emits an JMX notification for the occurred event. Open 'jconsole' and 'MBeans->org.xmlBlaster->node->xxx->service->EventPlugin[yyy]' there choose the 'Notifications[0]' tabulator and click the 'Subscribe' button. Now you receive the configured events. |
We access the xmlBlaster core directly to register the supported internal events, hence this plugin works only if it is in the same virtual machine (JVM) as the xmlBlaster server.
All events don't throw any exceptions as this plugin should have no influence on the regular work-flow of xmlBlaster.
| Nested Class Summary | |
(package private) class |
EventPlugin.JmxDestinationHelper
Helper class to send a JMX notification. |
(package private) class |
EventPlugin.PublishDestinationHelper
Helper class to publish messages. |
(package private) class |
EventPlugin.SmtpDestinationHelper
Helper class to send emails |
| Nested classes inherited from class javax.management.NotificationBroadcasterSupport |
|
| Fields inherited from class javax.management.NotificationBroadcasterSupport |
|
| Fields inherited from interface org.xmlBlaster.engine.I_SubscriptionListener |
PRIO_01, PRIO_05, PRIO_10 |
| Constructor Summary | |
EventPlugin()
|
|
| Method Summary | |
void |
activate()
Activate this service |
protected void |
callbackStateChange(DispatchManager dispatchManager,
ConnectionStateEnum oldState,
ConnectionStateEnum newState)
|
void |
changed(TopicEvent topicEvent)
Invoked on topic lifecycle change. |
int |
clearPendingEmails()
JMX |
int |
compareTo(java.lang.Object obj)
|
static java.lang.String |
createStatusDump(ServerScope g,
java.lang.String summary,
java.lang.String description,
java.lang.String eventType,
java.lang.String errorCode)
Create an XML xmlBlaster dump which contains the most important status informations. |
void |
deActivate()
Deactivate the service to standby. |
void |
dispatchEvent(java.lang.String summary,
java.lang.String description,
java.lang.String eventType)
Enforced by I_EventDispatcher |
java.lang.String |
dumpPendingEmails()
JMX |
boolean |
equals(java.lang.Object obj)
|
java.lang.String |
getEventTypes()
The comma separated list of active events. |
int |
getInstanceCounter()
|
java.lang.String |
getJmxDestinationConfiguration()
JMX |
long |
getMailCollectMillis()
How long to collect outgoing emails? |
java.lang.String |
getName()
A human readable name of the listener for logging. |
int |
getNumOfPendingEmails()
JMX |
java.lang.Integer |
getPriority()
The priority by which it will be invoked. |
java.lang.String |
getPublishDestinationConfiguration()
JMX |
SmtpClient |
getSmtpClient()
TODO: Put into engine.Global and util.Global (see EmailExecutor.java) |
java.lang.String |
getSmtpDestinationConfiguration()
Configuration properties of the email sink. |
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 utilGlob,
PluginInfo pluginInfo)
Initializes the plugin |
boolean |
isActive()
Access the current state |
static boolean |
isCallbackStateEvent(java.lang.String txt)
|
static boolean |
isPersistenceEvent(java.lang.String txt)
|
static boolean |
isQueueEvent(java.lang.String txt)
|
boolean |
isShutdown()
Check status |
boolean |
isWildcard(java.lang.String pattern)
|
void |
log(java.util.logging.LogRecord record)
Redirect logging. |
private static boolean |
matchesRegex(java.lang.String pattern,
java.lang.String txt)
|
protected void |
newHeartbeatNotification(java.lang.String eventType)
Send a heartbeat message/notification. |
private void |
registerEventTypes(java.lang.String eventTypes)
Find out which events to listen. |
protected java.lang.String |
replaceTokens(java.lang.String str,
java.lang.String summary,
java.lang.String description,
java.lang.String eventType,
java.lang.String errorCode,
SessionName sessionName)
Replace some $_{} tokens. |
void |
runlevelChange(int from,
int to,
boolean force)
Invoked on run level change, see for example RunlevelManager.RUNLEVEL_HALTED and RunlevelManager.RUNLEVEL_RUNNING |
protected void |
sendEmail(java.lang.String summary,
java.lang.String description,
java.lang.String eventType,
java.lang.String errorCode,
SessionName sessionName,
boolean forceSending)
Sending email as configured with destination.smtp. |
protected void |
sendJmxNotification(java.lang.String summary,
java.lang.String description,
java.lang.String eventType,
java.lang.String errorCode,
boolean forceSending)
The xmlBlaster-JMX notification data sink. |
protected void |
sendMessage(java.lang.String summary,
java.lang.String description,
java.lang.String eventType,
java.lang.String errorCode,
SessionName sessionName,
ClientProperty[] clientProperties)
The xmlBlaster-message data sink. |
java.lang.String |
sendPendingEmails()
JMX |
java.lang.String |
sendTestEmail()
JMX |
void |
sessionAdded(ClientEvent clientEvent)
Invoked on successful client login |
void |
sessionPreRemoved(ClientEvent clientEvent)
Invoked before a client does a logout |
void |
sessionRemoved(ClientEvent clientEvent)
Invoked when client does a logout |
void |
setEventTypes(java.lang.String eventTypes)
A comma separated list of active events. |
void |
setJmxDestinationConfiguration(java.lang.String jmxDestinationConfiguration)
|
void |
setMailCollectMillis(long mailCollectMillis)
|
void |
setPublishDestinationConfiguration(java.lang.String publishDestinationConfiguration)
|
void |
setSmtpDestinationConfiguration(java.lang.String smtpDestinationConfiguration)
Configuration properties of the email sink. |
void |
setupSmtpSink(java.lang.String destination)
Initialize email sending. |
void |
setUsageUrl(java.lang.String url)
|
void |
shutdown()
Shutdown the plugin |
void |
subjectAdded(ClientEvent e)
Invoked on first successful client login, when SubjectInfo is created |
void |
subjectRemoved(ClientEvent e)
Invoked when client does its last logout |
void |
subscriptionAdd(SubscriptionEvent subscriptionEvent)
Invoked on successful subscription login |
void |
subscriptionRemove(SubscriptionEvent subscriptionEvent)
Invoked when subscription does a logout |
void |
toAlive(DispatchManager dispatchManager,
ConnectionStateEnum oldState)
|
void |
toDead(DispatchManager dispatchManager,
ConnectionStateEnum oldState,
java.lang.String errorText)
|
void |
toPolling(DispatchManager dispatchManager,
ConnectionStateEnum oldState)
|
java.lang.String |
triggerHeartbeatNotification()
Manually trigger a heart beat message. |
java.lang.String |
triggerTestLogSevere()
Triggers a log.severe to test the configuration. |
java.lang.String |
triggerTestLogWarning()
Triggers a log.warning to test the configuration. |
void |
update(SessionInfo sessionInfo,
java.util.Map remoteProperties)
Called when a client sends his remote properties, for example client side errors. |
java.lang.String |
usage()
|
void |
verifyInternetAddress(java.lang.String address)
Check string addresses if they have valid email syntax. |
boolean |
wildcardMatch(long pattern,
long pubSessionId)
SessionName.java parsed "client/joe/session/*" to pubSessionId=Long.MIN_VALUE |
boolean |
wildcardMatch(java.lang.String pattern,
java.lang.String name)
|
| Methods inherited from class javax.management.NotificationBroadcasterSupport |
addNotificationListener, getNotificationInfo, handleNotification, removeNotificationListener, removeNotificationListener, sendNotification |
| Methods inherited from class java.lang.Object |
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
private static final java.lang.String ME
private static java.util.logging.Logger log
private java.lang.Object mbeanHandle
private ContextNode contextNode
protected Global glob
protected I_PluginConfig pluginConfig
protected ServerScope engineGlob
protected RequestBroker requestBroker
protected SessionInfo sessionInfo
protected boolean isActive
protected boolean isShutdown
protected java.lang.String eventTypes
protected java.util.Set loggingSet
protected java.util.Set runlevelSet
protected java.util.Set clientSet
protected java.util.Set topicSet
protected java.util.Set pendingCallbackSessionInfoSet
protected java.util.Set callbackSessionStateSet
protected static int staticInstanceCounter
protected int instanceCounter
private java.lang.String uniqueInstanceName
protected SmtpClient smtpClient
protected final java.lang.Object smtpDestinationMonitor
protected EventPlugin.SmtpDestinationHelper smtpDestinationHelper
protected java.lang.String smtpDestinationConfiguration
protected Timeout smtpTimeout
protected Timestamp smtpTimeoutHandle
protected EmailData currentEmailData
protected long heartbeatInterval
protected Timeout heartbeatTimeout
protected Timestamp heartbeatTimeoutHandle
protected EventPlugin.PublishDestinationHelper publishDestinationHelper
protected java.lang.String publishDestinationConfiguration
protected EventPlugin.JmxDestinationHelper jmxDestinationHelper
protected java.lang.String jmxDestinationConfiguration
| Constructor Detail |
public EventPlugin()
| Method Detail |
public void init(Global utilGlob,
PluginInfo pluginInfo)
throws XmlBlasterException
init in interface I_PluginXmlBlasterExceptionI_Plugin.init(org.xmlBlaster.util.Global,
org.xmlBlaster.util.plugin.PluginInfo)
private void registerEventTypes(java.lang.String eventTypes)
throws XmlBlasterException
eventTypes - A commas seperated list of supported events, e.g. logging/severe/*,logging/warning/*
XmlBlasterExceptionpublic static boolean isQueueEvent(java.lang.String txt)
public static boolean isPersistenceEvent(java.lang.String txt)
public static boolean isCallbackStateEvent(java.lang.String txt)
public final boolean isWildcard(java.lang.String pattern)
public final boolean wildcardMatch(java.lang.String pattern,
java.lang.String name)
public final boolean wildcardMatch(long pattern,
long pubSessionId)
private static boolean matchesRegex(java.lang.String pattern,
java.lang.String txt)
public void update(SessionInfo sessionInfo,
java.util.Map remoteProperties)
update in interface I_RemotePropertiesListenersessionInfo - The client sending the properties,
the remoteProperties are added to this sessionInfo alreadyremoteProperties - Key is a string, value is of type ClientPropertiesprotected void newHeartbeatNotification(java.lang.String eventType)
eventType - public java.lang.String triggerHeartbeatNotification()
EventPluginMBean
triggerHeartbeatNotification in interface EventPluginMBean
public static java.lang.String createStatusDump(ServerScope g,
java.lang.String summary,
java.lang.String description,
java.lang.String eventType,
java.lang.String errorCode)
g - The global of the running server instance
public void setupSmtpSink(java.lang.String destination)
throws XmlBlasterException
destination - The configuration string, a comma separated list of key/value properties, e.g.
mail.smtp.from=xmlBlaster@localhost,mail.smtp.to=demo@localhost,mail.collectMillis=10000
XmlBlasterException
protected java.lang.String replaceTokens(java.lang.String str,
java.lang.String summary,
java.lang.String description,
java.lang.String eventType,
java.lang.String errorCode,
SessionName sessionName)
str - The string to check and replacesummary - The value for a $_{summary}, can be nulldescription - The value for a $_{description}, can be nulleventType - The value for a $_{eventType}, can be nullerrorCode - The value for a $_{errorCode}, can be nullsessionName - TODO
public java.lang.String getType()
I_AdminPlugin
getType in interface I_PluginI_Plugin.getType()public java.lang.String getVersion()
I_AdminPlugin
getVersion in interface I_PluginI_Plugin.getVersion()
public void shutdown()
throws XmlBlasterException
shutdown in interface I_PluginXmlBlasterException - 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.I_Plugin.shutdown()
public SmtpClient getSmtpClient()
throws XmlBlasterException
XmlBlasterExceptionpublic void log(java.util.logging.LogRecord record)
log in interface I_LogListenerrecord - I_LogListener.log(LogRecord)
protected void sendJmxNotification(java.lang.String summary,
java.lang.String description,
java.lang.String eventType,
java.lang.String errorCode,
boolean forceSending)
Open jconsole and from the menue
'MBeans->org.xmlBlaster->node->xxx->service->EventPlugin[yyy]',
there choose the 'Notifications[0]' tabulator and click the 'Subscribe' button.
Now you receive the configured events.
{
protected void sendMessage(java.lang.String summary,
java.lang.String description,
java.lang.String eventType,
java.lang.String errorCode,
SessionName sessionName,
ClientProperty[] clientProperties)
clientProperties - Can be null{
protected void sendEmail(java.lang.String summary,
java.lang.String description,
java.lang.String eventType,
java.lang.String errorCode,
SessionName sessionName,
boolean forceSending)
destination.smtp.
summary - The email summary line to use, it is injected to the template as $_{summary}description - The event description to send, it is injected as $_{description}eventType - For example "logging/severe/*"sessionName - TODOforceSending - If true send directly and ignore the timeouthttp://www.faqs.org/rfcs/rfc2822.htmlpublic java.lang.String getName()
I_RunlevelListener
getName in interface I_RunlevelListener
public void runlevelChange(int from,
int to,
boolean force)
I_RunlevelListener
runlevelChange in interface I_RunlevelListenerfrom - The current runlevelto - The runlevel we want to switch toforce - If true force the change even if messages are lost
public void dispatchEvent(java.lang.String summary,
java.lang.String description,
java.lang.String eventType)
dispatchEvent in interface I_EventDispatchersummary - description - eventType -
public void sessionAdded(ClientEvent clientEvent)
throws XmlBlasterException
I_ClientListener
sessionAdded in interface I_ClientListenerXmlBlasterException
public void sessionPreRemoved(ClientEvent clientEvent)
throws XmlBlasterException
I_ClientListener
sessionPreRemoved in interface I_ClientListenerXmlBlasterException
public void sessionRemoved(ClientEvent clientEvent)
throws XmlBlasterException
I_ClientListener
sessionRemoved in interface I_ClientListenerXmlBlasterException
public void subjectAdded(ClientEvent e)
throws XmlBlasterException
I_ClientListener
subjectAdded in interface I_ClientListenerXmlBlasterException
public void subjectRemoved(ClientEvent e)
throws XmlBlasterException
I_ClientListener
subjectRemoved in interface I_ClientListenerXmlBlasterException
public void verifyInternetAddress(java.lang.String address)
throws XmlBlasterException
address - Can be a comma separated list of email addresses
XmlBlasterException - If one of the addresses has invalid syntaxpublic java.lang.String sendTestEmail()
sendTestEmail in interface EventPluginMBeanpublic java.lang.String dumpPendingEmails()
dumpPendingEmails in interface EventPluginMBeanpublic int clearPendingEmails()
clearPendingEmails in interface EventPluginMBeanpublic int getNumOfPendingEmails()
getNumOfPendingEmails in interface EventPluginMBeanpublic java.lang.String sendPendingEmails()
sendPendingEmails in interface EventPluginMBean
public void activate()
throws java.lang.Exception
I_AdminService
activate in interface I_AdminServicejava.lang.Exceptionpublic void deActivate()
I_AdminService
deActivate in interface I_AdminServicepublic boolean isActive()
I_AdminService
isActive in interface I_AdminServicepublic boolean isShutdown()
I_AdminPlugin
isShutdown in interface I_AdminPluginpublic java.lang.String usage()
usage in interface I_AdminUsagepublic java.lang.String getUsageUrl()
getUsageUrl in interface I_AdminUsagepublic void setUsageUrl(java.lang.String url)
setUsageUrl in interface I_AdminUsagepublic long getMailCollectMillis()
getMailCollectMillis in interface EventPluginMBeanpublic void setMailCollectMillis(long mailCollectMillis)
setMailCollectMillis in interface EventPluginMBeanmailCollectMillis - The mailCollectMillis to set.public java.lang.String getEventTypes()
EventPluginMBean
getEventTypes in interface EventPluginMBeanpublic void setEventTypes(java.lang.String eventTypes)
EventPluginMBean
setEventTypes in interface EventPluginMBeaneventTypes - The eventTypes to set.public java.lang.String getSmtpDestinationConfiguration()
EventPluginMBean
getSmtpDestinationConfiguration in interface EventPluginMBeanpublic void setSmtpDestinationConfiguration(java.lang.String smtpDestinationConfiguration)
EventPluginMBean
setSmtpDestinationConfiguration in interface EventPluginMBeansmtpDestinationConfiguration - The smtpDestinationConfiguration to set.public java.lang.Integer getPriority()
I_SubscriptionListener
getPriority in interface I_SubscriptionListener
public void subscriptionAdd(SubscriptionEvent subscriptionEvent)
throws XmlBlasterException
I_SubscriptionListener
subscriptionAdd in interface I_SubscriptionListenerXmlBlasterException
public void subscriptionRemove(SubscriptionEvent subscriptionEvent)
throws XmlBlasterException
I_SubscriptionListener
subscriptionRemove in interface I_SubscriptionListenerXmlBlasterExceptionpublic java.lang.String triggerTestLogSevere()
EventPluginMBean
triggerTestLogSevere in interface EventPluginMBeanpublic java.lang.String triggerTestLogWarning()
EventPluginMBean
triggerTestLogWarning in interface EventPluginMBean
public void changed(TopicEvent topicEvent)
throws XmlBlasterException
I_TopicListener
changed in interface I_TopicListenerXmlBlasterExceptionpublic int compareTo(java.lang.Object obj)
compareTo in interface java.lang.Comparablepublic boolean equals(java.lang.Object obj)
public int getInstanceCounter()
protected void callbackStateChange(DispatchManager dispatchManager,
ConnectionStateEnum oldState,
ConnectionStateEnum newState)
public void toAlive(DispatchManager dispatchManager,
ConnectionStateEnum oldState)
toAlive in interface I_ConnectionStatusListener
public void toPolling(DispatchManager dispatchManager,
ConnectionStateEnum oldState)
toPolling in interface I_ConnectionStatusListener
public void toDead(DispatchManager dispatchManager,
ConnectionStateEnum oldState,
java.lang.String errorText)
toDead in interface I_ConnectionStatusListenerpublic java.lang.String getJmxDestinationConfiguration()
getJmxDestinationConfiguration in interface EventPluginMBeanpublic java.lang.String getPublishDestinationConfiguration()
getPublishDestinationConfiguration in interface EventPluginMBeanpublic void setJmxDestinationConfiguration(java.lang.String jmxDestinationConfiguration)
jmxDestinationConfiguration - The jmxDestinationConfiguration to set.public void setPublishDestinationConfiguration(java.lang.String publishDestinationConfiguration)
publishDestinationConfiguration - The publishDestinationConfiguration to set.
|
xmlBlaster 1.6.2 API | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||