Over a million developers have joined DZone.

Getting Insight in Neo4j’s JMX Beans When Running Embedded

DZone's Guide to

Getting Insight in Neo4j’s JMX Beans When Running Embedded

· Java Zone
Free Resource

Learn how to troubleshoot and diagnose some of the most common performance issues in Java today. Brought to you in partnership with AppDynamics.

Neo4j exposes a lot of valuable information via JMX. Sometimes you want to gain some insight in some JMX beans when running Neo4j in embedded mode. For this it’s crucial to have the neo4j-jmx-[version].jar file on the classpath.

The following short Groovy script demos this by using the @Grab annotation to fetch dependencies:

@Grab(group="org.neo4j", module="neo4j-kernel", version="2.0.1")
@Grab(group="org.neo4j", module="neo4j-lucene-index", version="2.0.1")
@Grab(group='org.neo4j', module='neo4j-jmx', version='2.0.1')

import org.neo4j.graphdb.factory.GraphDatabaseFactory
import org.neo4j.jmx.JmxUtils
def db = new GraphDatabaseFactory().newEmbeddedDatabaseBuilder("/tmp/graph.db")

println "started embedded graph db"

def objectName = JmxUtils.getObjectName(db, "Primitive count")
def numberOfNodesIds = JmxUtils.getAttribute(objectName, "NumberOfNodeIdsInUse")

println "JMX says, we have $numberOfNodesIds node ids in use"

println "shutting down embedded graph db now"

For a full reference of all available JMX beans, see the Neo4j manual.

Understand the needs and benefits around implementing the right monitoring solution for a growing containerized market. Brought to you in partnership with AppDynamics.


Published at DZone with permission of Stefan Armbruster, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.


Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.


{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}