Welcome!

Machine Learning Authors: Elizabeth White, William Schmarzo, Stackify Blog, Liz McMillan, Progress Blog

Related Topics: Java IoT

Java IoT: Article

Integrating AJAX with the JMX Notification Framework

Opposite Ends of the Systems Management Stack

Each step is described in detail below.

Register MBeans and MBean Listeners
On each J2EE server instance, two start-up classes are run at server start-up:

  • ManagementStartup: Registers the UserWeb MBean in the local MBean server. Startup class parameters include default settings of the alert status, as well as the MBean name and MBean class. For example:

    <StartupClass
       Arguments="ServerName=admin,
         MBeanName=ExampleApp:Name=UserWeb,
         MBeanClass=com.grahamh.management.userWeb.UserWeb"
         ClassName="com.grahamh.management.startup.ManagementStartup"
       FailureIsFatal="true" Name="UserWEB" Notes=""
       Targets="admin,OLTPCluster"/>

  • MbeanRegistrations: Used to register a Singleton POJO, ManagementListener, with the UserWeb MBean on the administration server.

    A javax.management.NotificationFilterSupport object is used to list the notification types that the UserWeb MBean will generate and the listener will receive:

    // MbeanRegistrations.java
    MBeanHelperFactory.getWebHelper().registerListener();

    // UserWebMbeanListener.java
    public void registerListener() throws UserWebException{

    try {
    // get listener and filter
    ManagementListener listener = MBeanHelperFactory.getListener();
    NotificationFilterSupport filter = listener.getSupportedEvents();

    // get admin mbean server;
    //register the listener and filter with the UserWeb MBean
    RemoteMBeanServer rmbs = getAdminMbeanServer();
    rmbs.addNotificationListener
    ("ExampleApp:Name=UserWeb", listener, filter, null);
    }
    catch (Exception e) {
    throw new UserWebException
    ("Unable to registerListener: "+ e.getMessage(), e);
    }
    }

    The listener.getSupportedEvents() method returns the following filter:

    NotificationFilterSupport filter = new NotificationFilterSupport();
    filter.enableType("alert.broadcast");

When ManagementListener is run at server start-up, a connection is made to the MBean server on the (remote) administration server and the (local) ManagementListener is registered as a listener on events generated by the UserWeb MBean, with a filter set to "alert.broadcast" event types.

Because the ManagementListener implements Weblogic.management.RemoteNotificationListener, it can get JMX notifications that are generated in either the local JVM or a remote JVM; in this case, generated in the remote administration server JVM.

Broadcast Admin MBean properties
The administration and managed UserWeb MBeans can be set independently, giving any one J2EE server a localized AJAX response. However, a general Operations, Administration & Support (OA&M) support pattern would set the admin MBean properties and then broadcast these properties to the MBeans on the remote application servers, using the Notification model, for subsequent AJAX retrieval.

Because the UserWeb MBean is based on ApplicationMBean, which extends javax.management.NotificationBroadcasterSupport, the infrastructure is in place for the UserWeb MBean to notify all listeners. Hence, the administrator sets the relevant MBean properties (using the HTMLAdaptor) and clicks BroadcastState (see Figure 2).

Consequently, the UserWeb.broadcastState()method is executed, which notifies all listeners synchronously with the state of the admin MBean:

public void broadcastState() throws Exception {
try {
Notification n = new Notification
("alert.broadcast", "ExampleApp:Name=UserWeb", 0);
n.setUserData(new UserWeb(this));
this.sendNotification(n);
}
catch (Exception e) {
throw e;
}
}

Because the data is serialized over the network, the non-transient object graph must be serializable.

Receive Notification of MBean Props via Listener
The event listener is the ManagementListener Singleton. The JMX Notification framework on the administration server makes a remote call to the ManagementListener handleNotification() method in each listener on each of the OLTP cluster JVMs, which registered on server start-up:

public void handleNotification(Notification notification, Object handback) {
System.out.println("Received alert: " + notification.getType());

// get event userdata from notification
Object userData = notification.getUserData();

if (userData instanceof UserWeb) {
// comes from destin8 Web
UserWeb WebVo = (UserWeb)userData;
UserWebMBeanHelper helper = MBeanHelperFactory.getWebHelper();

// get from value object and set into local MBean using
MBeanHelper
helper.setAlertMessage(WebVo.getAlertMessage());
helper.setAlertStatus(WebVo.getAlertStatus());
helper.setCallBack(WebVo.getCallBack());
helper.setRefreshAlertStatus(WebVo.getRefreshAlertStatus());
}
}

The 'master' UserWeb data is set into the local User-Web MBean via its MBean helper. Consequently each managed server is updated with the master UserWeb state.

That's as far as the JMX elements need to go.

AJAX Request of Management State
The browser client is AJAX-enabled as follows:

  • main.jsp - instrumented JSP page that checks the (JMX) alert status and polls the server for alerts. It includes admin.js
  • admin.js - JavaScript utilities that use XMLHttpRequest to poll the server for the management state, parse the XML response, and repaint the 'status' area of the screen
JavaScript (described below) is included in main.jsp as follows:

<script type="text/javascript" src="./js/admin.js" ></script>

Rather than poll continuously, we will only poll if alerting is enabled. We use the UserWebMBeanHelper to check this status. If enabled, the JavaScript function initAdmin() is invoked when the page loads:

<%
if (MBeanHelperFactory.getWebHelper().isAlertEnabled()) {
%>
<body bgcolor="#F4FFE4" onload="initAdmin();">
<%
} else {
%>
<body bgcolor="#F4FFE4">
<%
}
%>

More Stories By Graham P. Harrison

Previously a Senior Consultant with BEA, Graham is the author of Dynamic Web Programming using Java (Prentice Hall, 2000) in addition to a number of articles for the Java Developers Journal and IBM DeveloperWorks. He has a focus on Enterprise Architecture, Performance Tuning and Capacity Planning

Comments (7) View Comments

Share your thoughts on this story.

Add your comment
You must be signed in to add a comment. Sign-in | Register

In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.


Most Recent Comments
Mark 09/29/06 02:36:10 PM EDT

I would like to get a copy of the source code that accompanies this article. Please send it to elihusmails[at]gmail[dot]com

thank you.

Mark 09/29/06 02:29:13 PM EDT

I would like to get a copy of the source code that accompanies this article. Please send it to elihusmails[at]gmail[dot]com

thank you.

hong li 05/29/06 09:40:54 AM EDT

My email address is : [email protected]

hong li 05/29/06 09:38:44 AM EDT

Could you please forward the whole source code to me which show those code to implement function of notification system useing Ajax and JMX?

Thanks!

Pete 02/05/06 09:10:28 AM EST

Great article when you want to understand an integration point between AJAX and wider J2EE space.

Bill Ley 01/31/06 07:44:42 PM EST

This is an awful article.

?? ???? 12/22/05 09:12:21 PM EST

Trackback Added: AJAX with the JMX Notification Framework; blockquote>Integrating AJAX with the JMX Notifica

@CloudExpo Stories
"Cloud Academy is an enterprise training platform for the cloud, specifically public clouds. We offer guided learning experiences on AWS, Azure, Google Cloud and all the surrounding methodologies and technologies that you need to know and your teams need to know in order to leverage the full benefits of the cloud," explained Alex Brower, VP of Marketing at Cloud Academy, in this SYS-CON.tv interview at 21st Cloud Expo, held Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clar...
In his session at 21st Cloud Expo, Carl J. Levine, Senior Technical Evangelist for NS1, will objectively discuss how DNS is used to solve Digital Transformation challenges in large SaaS applications, CDNs, AdTech platforms, and other demanding use cases. Carl J. Levine is the Senior Technical Evangelist for NS1. A veteran of the Internet Infrastructure space, he has over a decade of experience with startups, networking protocols and Internet infrastructure, combined with the unique ability to it...
While some developers care passionately about how data centers and clouds are architected, for most, it is only the end result that matters. To the majority of companies, technology exists to solve a business problem, and only delivers value when it is solving that problem. 2017 brings the mainstream adoption of containers for production workloads. In his session at 21st Cloud Expo, Ben McCormack, VP of Operations at Evernote, discussed how data centers of the future will be managed, how the p...
"NetApp is known as a data management leader but we do a lot more than just data management on-prem with the data centers of our customers. We're also big in the hybrid cloud," explained Wes Talbert, Principal Architect at NetApp, in this SYS-CON.tv interview at 21st Cloud Expo, held Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA.
"We're focused on how to get some of the attributes that you would expect from an Amazon, Azure, Google, and doing that on-prem. We believe today that you can actually get those types of things done with certain architectures available in the market today," explained Steve Conner, VP of Sales at Cloudistics, in this SYS-CON.tv interview at 21st Cloud Expo, held Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA.
"Space Monkey by Vivent Smart Home is a product that is a distributed cloud-based edge storage network. Vivent Smart Home, our parent company, is a smart home provider that places a lot of hard drives across homes in North America," explained JT Olds, Director of Engineering, and Brandon Crowfeather, Product Manager, at Vivint Smart Home, in this SYS-CON.tv interview at @ThingsExpo, held Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA.
It is of utmost importance for the future success of WebRTC to ensure that interoperability is operational between web browsers and any WebRTC-compliant client. To be guaranteed as operational and effective, interoperability must be tested extensively by establishing WebRTC data and media connections between different web browsers running on different devices and operating systems. In his session at WebRTC Summit at @ThingsExpo, Dr. Alex Gouaillard, CEO and Founder of CoSMo Software, presented ...
Enterprises are adopting Kubernetes to accelerate the development and the delivery of cloud-native applications. However, sharing a Kubernetes cluster between members of the same team can be challenging. And, sharing clusters across multiple teams is even harder. Kubernetes offers several constructs to help implement segmentation and isolation. However, these primitives can be complex to understand and apply. As a result, it’s becoming common for enterprises to end up with several clusters. Thi...
"There's plenty of bandwidth out there but it's never in the right place. So what Cedexis does is uses data to work out the best pathways to get data from the origin to the person who wants to get it," explained Simon Jones, Evangelist and Head of Marketing at Cedexis, in this SYS-CON.tv interview at 21st Cloud Expo, held Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA.
WebRTC is great technology to build your own communication tools. It will be even more exciting experience it with advanced devices, such as a 360 Camera, 360 microphone, and a depth sensor camera. In his session at @ThingsExpo, Masashi Ganeko, a manager at INFOCOM Corporation, introduced two experimental projects from his team and what they learned from them. "Shotoku Tamago" uses the robot audition software HARK to track speakers in 360 video of a remote party. "Virtual Teleport" uses a multip...
"We work around really protecting the confidentiality of information, and by doing so we've developed implementations of encryption through a patented process that is known as superencipherment," explained Richard Blech, CEO of Secure Channels Inc., in this SYS-CON.tv interview at 21st Cloud Expo, held Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA.
High-velocity engineering teams are applying not only continuous delivery processes, but also lessons in experimentation from established leaders like Amazon, Netflix, and Facebook. These companies have made experimentation a foundation for their release processes, allowing them to try out major feature releases and redesigns within smaller groups before making them broadly available. In his session at 21st Cloud Expo, Brian Lucas, Senior Staff Engineer at Optimizely, discussed how by using ne...
The question before companies today is not whether to become intelligent, it’s a question of how and how fast. The key is to adopt and deploy an intelligent application strategy while simultaneously preparing to scale that intelligence. In her session at 21st Cloud Expo, Sangeeta Chakraborty, Chief Customer Officer at Ayasdi, provided a tactical framework to become a truly intelligent enterprise, including how to identify the right applications for AI, how to build a Center of Excellence to oper...
"IBM is really all in on blockchain. We take a look at sort of the history of blockchain ledger technologies. It started out with bitcoin, Ethereum, and IBM evaluated these particular blockchain technologies and found they were anonymous and permissionless and that many companies were looking for permissioned blockchain," stated René Bostic, Technical VP of the IBM Cloud Unit in North America, in this SYS-CON.tv interview at 21st Cloud Expo, held Oct 31 – Nov 2, 2017, at the Santa Clara Conventi...
In his session at 21st Cloud Expo, James Henry, Co-CEO/CTO of Calgary Scientific Inc., introduced you to the challenges, solutions and benefits of training AI systems to solve visual problems with an emphasis on improving AIs with continuous training in the field. He explored applications in several industries and discussed technologies that allow the deployment of advanced visualization solutions to the cloud.
Gemini is Yahoo’s native and search advertising platform. To ensure the quality of a complex distributed system that spans multiple products and components and across various desktop websites and mobile app and web experiences – both Yahoo owned and operated and third-party syndication (supply), with complex interaction with more than a billion users and numerous advertisers globally (demand) – it becomes imperative to automate a set of end-to-end tests 24x7 to detect bugs and regression. In th...
SYS-CON Events announced today that Telecom Reseller has been named “Media Sponsor” of SYS-CON's 22nd International Cloud Expo, which will take place on June 5-7, 2018, at the Javits Center in New York, NY. Telecom Reseller reports on Unified Communications, UCaaS, BPaaS for enterprise and SMBs. They report extensively on both customer premises based solutions such as IP-PBX as well as cloud based and hosted platforms.
"We're developing a software that is based on the cloud environment and we are providing those services to corporations and the general public," explained Seungmin Kim, CEO/CTO of SM Systems Inc., in this SYS-CON.tv interview at 21st Cloud Expo, held Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA.
Enterprises are moving to the cloud faster than most of us in security expected. CIOs are going from 0 to 100 in cloud adoption and leaving security teams in the dust. Once cloud is part of an enterprise stack, it’s unclear who has responsibility for the protection of applications, services, and data. When cloud breaches occur, whether active compromise or a publicly accessible database, the blame must fall on both service providers and users. In his session at 21st Cloud Expo, Ben Johnson, C...
SYS-CON Events announced today that CrowdReviews.com has been named “Media Sponsor” of SYS-CON's 22nd International Cloud Expo, which will take place on June 5–7, 2018, at the Javits Center in New York City, NY. CrowdReviews.com is a transparent online platform for determining which products and services are the best based on the opinion of the crowd. The crowd consists of Internet users that have experienced products and services first-hand and have an interest in letting other potential buye...