📄 eventplugin.java
字号:
} } catch (Throwable e) {} if (this.smtpDestinationHelper != null) { sendEmail(summary, description, eventType, errorCode, false); } /* if (this.publishDestinationHelper != null) { if (Logger.LOG_WARN == level) { // log.fine("Too dangerous as it could produce looping messages"); // e.g. [WARN XmlBlaster.DispatchWorkerPool.heron-1 RequestBroker] Generating dead message 'callback:/node/heron/client/subscribe/1/NORM/1136329068010000002/__sys__Event' from publisher=/node/heron/client/__RequestBroker_internal[heron]/1 because delivery with queue 'null' failed: XmlBlasterException errorCode=[communication.noConnection.dead] serverSideException=true location=[SOCKET-HandleClient-subscribe/1] message=[#14515:14516M update() invocation ignored, we are shutdown. : Original erroCode=communication.noConnection] [See URL http://www.xmlblaster.org/xmlBlaster/doc/requirements/admin.errorcodes.listing.html#communication.noConnection.dead] } else { // if (Logger.LOG_ERROR == level) // Should suppress as well ? // Lead to looping messages if during publish a log.error is done sendMessage(summary, description, eventType, errorCode, false); } } */ if (this.jmxDestinationHelper != null) { sendJmxNotification(summary, description, eventType, errorCode, false); } } catch (Throwable e) { e.printStackTrace(); } } /** * The xmlBlaster-JMX notification data sink. * Sends a JMX notification with the current event occurred. * <p> * Open <code>jconsole</code> 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. * </p> * @see #replaceTokens(String str, String summary, String description, String eventType, String errorCode) { */ protected void sendJmxNotification(String summary, String description, String eventType, String errorCode, boolean forceSending) { if (this.jmxDestinationHelper == null) return; if (!this.isActive) return; try { SessionName sessionName = null; //String message = eventType + ": " + summary; // Shows up under 'Message' in jconsole String message =this.jmxDestinationHelper.getMessage(summary, description, eventType, errorCode, sessionName); String attributeName = eventType; String oldValue = ""; // TODO what to put here? String newValue = eventType + ": " + summary; // Won't work if attributeName is illegal this.engineGlob.sendNotification(this, message, attributeName, "java.lang.String", oldValue, newValue); } catch (Throwable e) { e.printStackTrace(); } } /** * The xmlBlaster-message data sink. * Publishes a message with the current event occurred. * @param useEventTypeAsContent TODO * @see #replaceTokens(String str, String summary, String description, String eventType, String errorCode) { */ protected void sendMessage(String summary, String description, String eventType, String errorCode, SessionName sessionName) { if (this.publishDestinationHelper == null) return; if (!this.isActive) return; try { MsgUnit msgUnit = this.publishDestinationHelper.getMsgUnit(summary, description, eventType, errorCode, sessionName); // Done already in getMsgUnit() above //msgUnit.getQosData().addClientProperty("_summary", summary); this.requestBroker.publish(this.sessionInfo, msgUnit); } catch (Throwable e) { e.printStackTrace(); } } /** * Sending email as configured with <code>destination.smtp</code>. * @param summary The email summary line to use, it is injected to the template as $_{summary} * @param description The event description to send, it is injected as $_{description} * @param eventType For example "logging/severe/*" * @param forceSending If true send directly and ignore the timeout * @see http://www.faqs.org/rfcs/rfc2822.html */ protected void sendEmail(String summary, String description, String eventType, String errorCode, boolean forceSending) { try { if (this.smtpDestinationHelper == null) return; if (!this.isActive) return; if (summary == null) summary = ""; if (description == null) description = ""; if (forceSending) { EmailData emailData = this.smtpDestinationHelper.createEmailData(); emailData.setSubject(replaceTokens( this.smtpDestinationHelper.subjectTemplate, summary, description, eventType, errorCode)); emailData.setContent(replaceTokens( this.smtpDestinationHelper.contentTemplate, summary, description, eventType, errorCode)); this.smtpDestinationHelper.smtpClient.sendEmail(emailData); return; } synchronized(this.smtpDestinationMonitor) { // Build the email, if timer is active append new logging to the content of the existing mail ... EmailData emailData = (this.currentEmailData == null) ? this.smtpDestinationHelper.createEmailData() : this.currentEmailData; emailData.setSubject(replaceTokens( this.smtpDestinationHelper.subjectTemplate, summary, description, eventType, errorCode)); String old = (emailData.getContent().length() == 0) ? "" : emailData.getContent() + this.smtpDestinationHelper.contentSeparator; emailData.setContent(old + replaceTokens( this.smtpDestinationHelper.contentTemplate, summary, description, eventType, errorCode)); // If no timer was active send immeditately (usually the first email) if (this.smtpTimeoutHandle == null) { try { smtpDestinationHelper.smtpClient.sendEmail(emailData); } catch (Throwable e) { e.printStackTrace(); } finally { this.currentEmailData = null; } } else { // If a timer is active return, the timout will send the mail this.currentEmailData = emailData; return; } // Now span timer, other emails are collected until this timer elapses if (this.smtpDestinationHelper.collectIntervall > 0) { this.smtpTimeoutHandle = this.smtpTimeout.addTimeoutListener(new I_Timeout() { public void timeout(Object userData) { synchronized(smtpDestinationMonitor) { smtpTimeoutHandle = null; if (currentEmailData == null) return; try { smtpDestinationHelper.smtpClient.sendEmail(currentEmailData); // todo: Probably respan timer here to have the same minimal gap again } catch (Throwable e) { e.printStackTrace(); } finally { currentEmailData = null; } } } }, this.smtpDestinationHelper.collectIntervall, null); } } // sync } catch (Throwable e) { e.printStackTrace(); } } /* (non-Javadoc) * @see org.xmlBlaster.engine.runlevel.I_RunlevelListener#getName() */ public String getName() { return ME; } /* (non-Javadoc) * @see org.xmlBlaster.engine.runlevel.I_RunlevelListener#runlevelChange(int, * int, boolean) */ public void runlevelChange(int from, int to, boolean force) { if (to == from) return; if (this.runlevelSet == null) return; // "service/RunlevelManager/event/startupRunlevel8", "service/RunlevelManager/event/shutdownRunlevel7" String found = this.engineGlob.getRunlevelManager().getContextNode().getRelativeName()+"/event/"; String tmp = (to > from) ? ("startupRunlevel"+to) : ("shutdownRunlevel"+to); String foundEvent = found + tmp; if (!this.runlevelSet.contains(foundEvent)) { foundEvent = found + "*"; if (!this.runlevelSet.contains(foundEvent)) return; } try { String summary = null; String description = null; String eventType = null; if (to > from) { // startup summary = "Startup to " + RunlevelManager.toRunlevelStr(to) + " (" + to + ")"; description = "xmlBlaster startup runlevel from " + RunlevelManager.toRunlevelStr(from) + " to " + RunlevelManager.toRunlevelStr(to); eventType = foundEvent; } if (to < from) { // shutdown summary = "Shutdown to " + RunlevelManager.toRunlevelStr(to) + " (" + to + ")"; description = "xmlBlaster shutdown runlevel from " + RunlevelManager.toRunlevelStr(from) + " to " + RunlevelManager.toRunlevelStr(to); eventType = foundEvent; } if (eventType == null) return; if (this.smtpDestinationHelper != null) { sendEmail(summary, description, eventType, null, false); } if (this.publishDestinationHelper != null) { try { sendMessage(summary, description, eventType, null, null); } catch (Throwable e) { e.printStackTrace(); } } if (this.jmxDestinationHelper != null) { sendJmxNotification(summary, description, eventType, null, false); } } catch (Throwable e) { e.printStackTrace(); } } /** * Enforced by I_EventDispatcher * @param summary * @param description * @param eventType */public void dispatchEvent(String summary, String description, String eventType) { try { if (this.smtpDestinationHelper != null) { sendEmail(summary, description, eventType, null, false); } if (this.publishDestinationHelper != null) { try { sendMessage(summary, description, eventType, null, null); } catch (Throwable e) { e.printStackTrace(); } } if (this.jmxDestinationHelper != null) { sendJmxNotification(summary, description, eventType, null, false); } } catch (Throwable e) { e.printStackTrace(); } } /* (non-Javadoc) * @see org.xmlBlaster.authentication.I_ClientListener#sessionAdded(org.xmlBlaster.authentication.ClientEvent) */ public void sessionAdded(ClientEvent clientEvent) throws XmlBlasterException { if (this.pendingCallbackSessionInfoSet != null) { synchronized (this.pendingCallbackSessionInfoSet) { try { SessionName currSessionName = clientEvent.getSessionInfo().getSessionName(); String name = currSessionName.getAbsoluteName(); boolean found = this.pendingCallbackSessionInfoSet.remove(name); if (!found) { // wild card entries remain found = this.pendingCallbackSessionInfoSe
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -