Welcome!

Machine Learning Authors: Ed Featherston, Destiny Bertucci, Liz McMillan, Elizabeth White, Dan Blacharski

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
A strange thing is happening along the way to the Internet of Things, namely far too many devices to work with and manage. It has become clear that we'll need much higher efficiency user experiences that can allow us to more easily and scalably work with the thousands of devices that will soon be in each of our lives. Enter the conversational interface revolution, combining bots we can literally talk with, gesture to, and even direct with our thoughts, with embedded artificial intelligence, whic...
As DevOps methodologies expand their reach across the enterprise, organizations face the daunting challenge of adapting related cloud strategies to ensure optimal alignment, from managing complexity to ensuring proper governance. How can culture, automation, legacy apps and even budget be reexamined to enable this ongoing shift within the modern software factory? In her Day 2 Keynote at @DevOpsSummit at 21st Cloud Expo, Aruna Ravichandran, VP, DevOps Solutions Marketing, CA Technologies, was jo...
"Storpool does only block-level storage so we do one thing extremely well. The growth in data is what drives the move to software-defined technologies in general and software-defined storage," explained Boyan Ivanov, CEO and co-founder at StorPool, in this SYS-CON.tv interview at 16th Cloud Expo, held June 9-11, 2015, at the Javits Center in New York City.
As Marc Andreessen says software is eating the world. Everything is rapidly moving toward being software-defined – from our phones and cars through our washing machines to the datacenter. However, there are larger challenges when implementing software defined on a larger scale - when building software defined infrastructure. In his session at 16th Cloud Expo, Boyan Ivanov, CEO of StorPool, provided some practical insights on what, how and why when implementing "software-defined" in the datacent...
Blockchain. A day doesn’t seem to go by without seeing articles and discussions about the technology. According to PwC executive Seamus Cushley, approximately $1.4B has been invested in blockchain just last year. In Gartner’s recent hype cycle for emerging technologies, blockchain is approaching the peak. It is considered by Gartner as one of the ‘Key platform-enabling technologies to track.’ While there is a lot of ‘hype vs reality’ discussions going on, there is no arguing that blockchain is b...
Blockchain is a shared, secure record of exchange that establishes trust, accountability and transparency across business networks. Supported by the Linux Foundation's open source, open-standards based Hyperledger Project, Blockchain has the potential to improve regulatory compliance, reduce cost as well as advance trade. Are you curious about how Blockchain is built for business? In her session at 21st Cloud Expo, René Bostic, Technical VP of the IBM Cloud Unit in North America, discussed the b...
You know you need the cloud, but you’re hesitant to simply dump everything at Amazon since you know that not all workloads are suitable for cloud. You know that you want the kind of ease of use and scalability that you get with public cloud, but your applications are architected in a way that makes the public cloud a non-starter. You’re looking at private cloud solutions based on hyperconverged infrastructure, but you’re concerned with the limits inherent in those technologies.
Is advanced scheduling in Kubernetes achievable?Yes, however, how do you properly accommodate every real-life scenario that a Kubernetes user might encounter? How do you leverage advanced scheduling techniques to shape and describe each scenario in easy-to-use rules and configurations? In his session at @DevOpsSummit at 21st Cloud Expo, Oleg Chunikhin, CTO at Kublr, answered these questions and demonstrated techniques for implementing advanced scheduling. For example, using spot instances and co...
The use of containers by developers -- and now increasingly IT operators -- has grown from infatuation to deep and abiding love. But as with any long-term affair, the honeymoon soon leads to needing to live well together ... and maybe even getting some relationship help along the way. And so it goes with container orchestration and automation solutions, which are rapidly emerging as the means to maintain the bliss between rapid container adoption and broad container use among multiple cloud host...
The cloud era has reached the stage where it is no longer a question of whether a company should migrate, but when. Enterprises have embraced the outsourcing of where their various applications are stored and who manages them, saving significant investment along the way. Plus, the cloud has become a defining competitive edge. Companies that fail to successfully adapt risk failure. The media, of course, continues to extol the virtues of the cloud, including how easy it is to get there. Migrating...
Imagine if you will, a retail floor so densely packed with sensors that they can pick up the movements of insects scurrying across a store aisle. Or a component of a piece of factory equipment so well-instrumented that its digital twin provides resolution down to the micrometer.
The need for greater agility and scalability necessitated the digital transformation in the form of following equation: monolithic to microservices to serverless architecture (FaaS). To keep up with the cut-throat competition, the organisations need to update their technology stack to make software development their differentiating factor. Thus microservices architecture emerged as a potential method to provide development teams with greater flexibility and other advantages, such as the abili...
In his keynote at 18th Cloud Expo, Andrew Keys, Co-Founder of ConsenSys Enterprise, provided an overview of the evolution of the Internet and the Database and the future of their combination – the Blockchain. Andrew Keys is Co-Founder of ConsenSys Enterprise. He comes to ConsenSys Enterprise with capital markets, technology and entrepreneurial experience. Previously, he worked for UBS investment bank in equities analysis. Later, he was responsible for the creation and distribution of life settle...
Product connectivity goes hand and hand these days with increased use of personal data. New IoT devices are becoming more personalized than ever before. In his session at 22nd Cloud Expo | DXWorld Expo, Nicolas Fierro, CEO of MIMIR Blockchain Solutions, will discuss how in order to protect your data and privacy, IoT applications need to embrace Blockchain technology for a new level of product security never before seen - or needed.
Leading companies, from the Global Fortune 500 to the smallest companies, are adopting hybrid cloud as the path to business advantage. Hybrid cloud depends on cloud services and on-premises infrastructure working in unison. Successful implementations require new levels of data mobility, enabled by an automated and seamless flow across on-premises and cloud resources. In his general session at 21st Cloud Expo, Greg Tevis, an IBM Storage Software Technical Strategist and Customer Solution Architec...
Nordstrom is transforming the way that they do business and the cloud is the key to enabling speed and hyper personalized customer experiences. In his session at 21st Cloud Expo, Ken Schow, VP of Engineering at Nordstrom, discussed some of the key learnings and common pitfalls of large enterprises moving to the cloud. This includes strategies around choosing a cloud provider(s), architecture, and lessons learned. In addition, he covered some of the best practices for structured team migration an...
In his general session at 21st Cloud Expo, Greg Dumas, Calligo’s Vice President and G.M. of US operations, discussed the new Global Data Protection Regulation and how Calligo can help business stay compliant in digitally globalized world. Greg Dumas is Calligo's Vice President and G.M. of US operations. Calligo is an established service provider that provides an innovative platform for trusted cloud solutions. Calligo’s customers are typically most concerned about GDPR compliance, application p...
Coca-Cola’s Google powered digital signage system lays the groundwork for a more valuable connection between Coke and its customers. Digital signs pair software with high-resolution displays so that a message can be changed instantly based on what the operator wants to communicate or sell. In their Day 3 Keynote at 21st Cloud Expo, Greg Chambers, Global Group Director, Digital Innovation, Coca-Cola, and Vidya Nagarajan, a Senior Product Manager at Google, discussed how from store operations and ...
In his session at 21st Cloud Expo, Raju Shreewastava, founder of Big Data Trunk, provided a fun and simple way to introduce Machine Leaning to anyone and everyone. He solved a machine learning problem and demonstrated an easy way to be able to do machine learning without even coding. Raju Shreewastava is the founder of Big Data Trunk (www.BigDataTrunk.com), a Big Data Training and consulting firm with offices in the United States. He previously led the data warehouse/business intelligence and B...
"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...