12-12 Oracle Complex Event Processing Administrators Guide
For details see Section 12.2, Configuring JMX
.
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. One of the first things you must do in your JMX program is to establish a
connection to the JMX server running in the Oracle CEP server as Example 12–2
shows.
Example 12–3 Establishing a Connection to the Oracle CEP JMX Server
public static void initConnectionString hostname, int port, String username, char[] password
throws IOException,MalformedURLException { MapString,Object env = makeSecureEnv;
This is an OSGi necessity env.put
JMXConnectorFactory.DEFAULT_CLASS_LOADER, com.bea.core.jmx.remote.provider.msarmi.ServerProvider.class.getClassLoader
; env.put
JMXConnectorFactory.PROTOCOL_PROVIDER_CLASS_LOADER, com.bea.core.jmx.remote.provider.msarmi.ServerProvider.class.getClassLoader
; JMXServiceURL serviceUrl = new JMXServiceURL
MSARMI,localhost,9002,jndijmxconnector ;
System.out.printlnService: + serviceURL.toString; env.put
JMXConnectorFactory.PROTOCOL_PROVIDER_PACKAGES, com.bea.core.jmx.remote.provider
; System.setPropertymx4j.remote.resolver.pkgs, com.bea.core.jmx.remote.resolver;
JMXConnector connector = JMXConnectorFactory.connecturl, env; connector.connect;
MBeanServerConnection connection = connector.getMBeanServerConnection; ...
} The JMXConnectorFactory.connect method’s second parameter is a Map object that sets up a
secure environment using the makeSecureEnv method, which looks like the following: private static MapString,Object makeSecureEnv {
MapString,Object env = new HashMapString,Object; String username = wlevs ;
char[] password = { w,l,e,v,s }; env.putJMXConnector.CREDENTIALS, new Serializable[]{username,password};
env.putjmx.remote.authenticator, com.bea.core.jmx.server.CEAuthenticator; System.setPropertyjmx.remote.authenticator,
com.bea.core.jmx.server.CEAuthenticator; return env;
}
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.