Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

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 our document data model can map directly to how you program your app, and native database features like secondary indexes, geospatial and text search give you full access to your data. Brought to you in partnership with MongoDB.

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")
  .newGraphDatabase()

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"
db.shutdown()

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


Discover when your data grows or your application performance demands increase, MongoDB Atlas allows you to scale out your deployment with an automated sharding process that ensures zero application downtime. Brought to you in partnership with MongoDB.

Topics:

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

Opinions expressed by DZone contributors are their own.

THE DZONE NEWSLETTER

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.

X

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

{{ parent.tldr }}

{{ parent.urlSource.name }}