commons-jmx

Library of utilities to assist with developing applications monitored via JMX.

License

License

GroupId

GroupId

com.carmatechnologies.commons
ArtifactId

ArtifactId

commons-jmx
Last Version

Last Version

0.2
Release Date

Release Date

Type

Type

jar
Description

Description

commons-jmx
Library of utilities to assist with developing applications monitored via JMX.
Project URL

Project URL

https://github.com/marccarre/commons-jmx
Source Code Management

Source Code Management

https://github.com/marccarre/commons-jmx.git

Download commons-jmx

How to add to project

<!-- https://jarcasting.com/artifacts/com.carmatechnologies.commons/commons-jmx/ -->
<dependency>
    <groupId>com.carmatechnologies.commons</groupId>
    <artifactId>commons-jmx</artifactId>
    <version>0.2</version>
</dependency>
// https://jarcasting.com/artifacts/com.carmatechnologies.commons/commons-jmx/
implementation 'com.carmatechnologies.commons:commons-jmx:0.2'
// https://jarcasting.com/artifacts/com.carmatechnologies.commons/commons-jmx/
implementation ("com.carmatechnologies.commons:commons-jmx:0.2")
'com.carmatechnologies.commons:commons-jmx:jar:0.2'
<dependency org="com.carmatechnologies.commons" name="commons-jmx" rev="0.2">
  <artifact name="commons-jmx" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.carmatechnologies.commons', module='commons-jmx', version='0.2')
)
libraryDependencies += "com.carmatechnologies.commons" % "commons-jmx" % "0.2"
[com.carmatechnologies.commons/commons-jmx "0.2"]

Dependencies

compile (2)

Group / Artifact Type Version
com.google.guava : guava jar 13.0.1
org.slf4j : slf4j-api jar 1.7.2

test (4)

Group / Artifact Type Version
org.slf4j : slf4j-log4j12 jar 1.7.2
log4j : log4j jar 1.2.17
junit : junit jar 4.11
org.hamcrest : hamcrest-all jar 1.3

Project Modules

There are no modules declared in this project.

Build Status Coverage Status

commons-jmx

Library of utilities to assist with developing applications monitored via JMX.

Features

  • MBeans helper allow you to easily register/unregister MBeans.
  • Use the builder to easily and transparently customize the MBeans' names.
  • Decorators to easily expose the state of your collections (maps, queues) via JMX:
    • current size
    • current items (using toString() to convert all items, keys, values to something understandable for JMX)

Examples

  1. Register a MBean:

     IYourMXBean mbean = new YourMXBean();
     ObjectName objectName = MBeans.register(mbean); 
     // Object name is: '<YourMXBean's package>:type=YourMXBean'
    
  2. Register a MBean with a custom name:

     IYourMXBean mbean = new YourMXBean();
     ObjectName objectName = MBeans.register(new Builder(mbean)
             .packageName("my.custom.package")
             .type("Cache")
             .property("name", "FirstLevelCache")
             .property("group", "InMemoryCaches"));
     // Object name is: 'my.custom.package:type=Cache,name=FirstLevelCache,group=InMemoryCaches'
    
  3. Decorate your collections to expose them via JMX:

  • ConcurrentMap:

    ConcurrentMap<String, Integer> jmxMap = new JmxConcurrentMap<String, Integer>(new ConcurrentHashMap<String, Integer>());
    jmxMap.put("A", 1);
    jmxMap.put("B", 2);
    jmxMap.put("C", 3);
    // Object name is: 'com.carmatechnologies.commons.jmx:type=JmxConcurrentMap'
    

    or, using a Builder:

    ConcurrentMap<String, Integer> jmxMap = new JmxConcurrentMap<String, Integer>(new ConcurrentHashMap<String, Integer>(), new Builder(mbean)
            .packageName("my.custom.package")
            .type("Cache")
            .property("name", "FirstLevelCache")
            .property("group", "InMemoryCaches"));
    jmxMap.put("A", 1);
    jmxMap.put("B", 2);
    jmxMap.put("C", 3);
    // Object name is: 'my.custom.package:type=Cache,name=FirstLevelCache,group=InMemoryCaches'
    
  • LinkedBlockingQueue:

    LinkedBlockingQueue<String> jmxQueue = new JmxLinkedBlockingQueue<String>(new LinkedBlockingQueue<String>());
    jmxQueue.put("A");
    jmxQueue.put("B");
    jmxQueue.put("C");
    // Object name is: 'com.carmatechnologies.commons.jmx:type=JmxLinkedBlockingQueue'
    

    or, using a Builder:

    LinkedBlockingQueue<String> jmxQueue = new JmxLinkedBlockingQueue<String>(new LinkedBlockingQueue<String>(), new Builder(mbean)
            .packageName("my.custom.package")
            .type("WorkQueue")
            .property("name", "TweetsNotifications")
            .property("group", "WorkQueues"));
    jmxQueue.put("A");
    jmxQueue.put("B");
    jmxQueue.put("C");
    // Object name is: 'my.custom.package:type=WorkQueue,name=TweetsNotifications,group=WorkQueues'
    

Versions

Version
0.2
0.1.1
0.1