Configuring JMX for Oracle CEP 12-13
12.3.3 How to Programmatically Configure an Oracle CEP Component Using JMX APIs
This section describes how to write Java code using the JMX API http:java.sun.comjavasetechnologiescoremntr-mgmtjavamana
gement to access Oracle CEP MBeans.
To programmatically configure an Oracle CEP component using JMX APIs: 1.
Acquire a connection to the Oracle CEP JMX server. For details see
Section 12.3.1, How to Programmatically Connect to the Oracle CEP JMX Server From a Non-Oracle CEP Client
.
2.
Write the http:java.sun.comjavasetechnologiescoremntr-mgmtjavama
nagement Java code to configure the component using the appropriate MBean.
Consider the following JMX programming hints. Example 12–4
shows how to use the connection to start getting information about the domain and its deployed applications by querying MBeans.
First the code shows how to get all MBeans whose type is Domain; there should only be one. Then, using the DomainMBean, the sample shows how to retrieve a
list of all the deployed applications in the domain using ApplicationMBean:
Example 12–4 Querying MBeans
Set domainObjectNames = connection.queryMBeans ObjectName.getInstance
ManagementConstants.DOMAIN_NAME + : + ManagementConstants.TYPE_PROPERTY + = +
DomainMBean.MBEAN_TYPE + , ,
null ;
ObjectName domainName = ObjectInstance domainObjectNames.iterator.next.getObjectName;
System.out.printlnDomain Name: + domainName.getKeyPropertyManagementConstants.NAME_ PROPERTY;
ObjectName [] applicationNames =
ObjectName[] connection.getAttributedomainName, ApplicationMBeans; ObjectName selectedApplicationObjectName = null ;
for ObjectName applicationName : applicationNames { String name =
applicationName.getKeyPropertyManagementConstants.NAME_PROPERTY; String status =
String connection.getAttributeapplicationName, State; System.out.printlnApplication: + name + Status: + status;
selectedApplicationObjectName = applicationName ; }
12.3.4 How to Programmatically Monitor the Throughput and Latency of an Oracle CEP Component Using JMX APIs
This section describes how to write Java code using the JMX API http:java.sun.comjavasetechnologiescoremntr-mgmtjavamana
gement to access Oracle CEP MBeans and dynamically monitor the throughput and
latency of an Oracle CEP component.
To dynamically configure an Oracle CEP component using JMX APIs: 1.
Acquire a connection to the Oracle CEP JMX server.
12-14 Oracle Complex Event Processing Administrators Guide
For details see Section 12.3.1, How to Programmatically Connect to the Oracle
CEP JMX Server From a Non-Oracle CEP Client .
2.
Acquire an instance of a MonitorRuntimeMBean for the component you want to monitor as
Example 12–5 shows.
Example 12–5 Acquiring an Instance of a MonitorRuntimeMBean
m_processorInbound = ObjectName.getInstance com.bea.wlevs:Name=myprocessor,
Type=EPLProcessor, Application=myapplication,
Direction=INBOUND ;
Be sure you specify whether you want to monitor incoming events INBOUND or outgoing events OUTBOUND. For example:
3.
Use the MonitorRuntimeMBean to acquire an instance of ProbeRuntimeMBean for the type of statistic you want as
Example 12–6 shows.
Example 12–6 Acquiring an Instance of ProbeRuntimeMBean
ProbeRuntimeMBean probeON = m_testBean.getMonitorRuntimeMBean.monitorAvgThroughput m_processorInbound,
1000, 1000
;
The MonitorRuntimeMBean has methods for each type of statistic you can gather. For example, you execute monitorAvgLatency if you want to monitor
the average latency, monitorAvgThroughput to monitor the average throughput, and so on. These methods all return ProbeRuntimeMBean.
4.
Use the ProbeRuntimeMbean instance to get the actual runtime metrics in one of the following ways:
a.
Use the ProbeRuntimeMBean method getMetric to pull the information.
b.
Use javax.management.NotificationBroadcaster.addNotificationLi
stener to have the information pushed to you every time there is a change in the metrics.
5.
When you are finished gathering monitoring information, unregister the MBean from the MBean server as
Example 12–7 shows.
Example 12–7 Unregistering the MBean
probON.terminate;
For additional details about these MBean interfaces and how to use them to monitor throughput and latency, see the
com.bea.wlevs.monitor.management package in the Oracle Fusion Middleware Java API Reference for Oracle Complex Event Processing.