Back Home

Jolokia protocol

Using Jolokia JMX-HTTP bridge it's possible to access

  • broker metrics (like memory usage)
  • execute management operations (like purging queues) using REST API

By default the management API is exposed at http://localhost:8161/api/jolokia/ URL. So you can for example get basic broker data with or to be more specific, total consumer count with


Request Types

version Version and server information
read Reading of attributes
write Writing of attributes
exec Execution of operations
search Pattern search for MBeans
list MBean meta data

Jolokia and Mule

Jolokia has also a Mule ESB agent which can be deployed on the Mule ESB (running in standalone mode).

The agent jar needs to be stored within the Mule installation in lib/opt/. Additionally, the Mule configuration needs to be adapted to contain the following section:

Graphing and Monitoring

JVM Agent

Jolokia has also a native Java JVM agent. The only dependency is on Sun's JDK 6, which contains a lightweight HTTP Server used for exporting the jolokia protocol. This is the most generic agent which can instrument any Java application using a JDK6. It is suitable for situations where the other agents don't fit.


public static void main(String [] args){
		def localHost = InetAddress.getLoopbackAddress()
		//		def urlStr = "http://${localHost.hostAddress}:8161/api/jolokia/"
		def urlStr = "http://localhost:8161/api/jolokia/"
		def j4pClient =   J4pClient.url(urlStr).user("admin").password("admin").connectionTimeout(30000).build()
		println "Attempting to connect to ${urlStr}..."
		def heapMemoryRequest = new J4pReadRequest("java.lang:type=Memory","HeapMemoryUsage")
		def threadingRequest = new J4pReadRequest("java.lang:type=Threading", "ThreadCount")
		def operatingSystemRequest = new J4pReadRequest("java.lang:type=OperatingSystem", "Arch")
		def queueDepth = new J4pReadRequest("org.apache.activemq:type=Broker,brokerName=localhost,destinationType=Queue,destinationName=1D.IP_BSS_DOC","QueueSize")
		J4pReadResponse heapMemoryResponse = null
		J4pReadResponse threadingResponse = null
		J4pReadResponse osResponse = null
		J4pReadResponse qResponse = null
			//			J4pReadRequest request = new J4pReadRequest("java.lang:type=Memory","HeapMemoryUsage");
			//			request.setPath("used");
			//			J4pReadResponse response = j4pClient.execute(request);
			//			System.out.println("Memory used: " + response.getValue());
			heapMemoryResponse = j4pClient.execute(heapMemoryRequest)
			threadingResponse = j4pClient.execute(threadingRequest)
			osResponse = j4pClient.execute(operatingSystemRequest)
			qResponse = j4pClient.execute(queueDepth)
		catch (J4pConnectException connEx)
			println "ERROR: Cannot connect to ${urlStr}\n${connEx.message}"
		catch (J4pRemoteException remoteEx)
			println "ERROR encountered while trying to access Jolokia-exposed JVM\n${remoteEx.message}"
			println "Status: ${remoteEx.status}"
			println "Error Code: ${remoteEx.errorType}"
			println "Remote Stack Trace: ${remoteEx.remoteStackTrace}"
		println "Heap Memory: ${heapMemoryResponse?.value}"
		println "Thread Count: ${threadingResponse?.value}"
		println "Operating System Architecture: ${osResponse?.value}"
		println "Queue Depth " + qResponse.value
jolokia.txt · Last modified: 2014/02/05 00:46 by root
RSS - 200 © CrosswireDigitialMedia Ltd