• How to expose an attribute or method of a custom application module through JMX/JConsole

    By default, all custom modules are exposed in JMX/JConsole at runtime. You can easily add attributes or operations to your custom module that are available through JMX/JConsole at runtime. To make an attribute available, be sure you add public getter and setter methods to access your attribute. All public methods will be made available through JMX as long as they use simple Java types (String, int, long, Boolean, short, etc.).

    This code only applies to Wowza Media Server™ 3.

    For example, if you have a module MyModule and you want to expose the attribute connectionLimit and the method logSomething, the code will look something like this:

    package com.wowza.wms.plugin.test.module; 
    
    import com.wowza.wms.module.*;
    
    public class MyModule extends ModuleBase
    {
    	private int connectionLimit  = 100;
    	
    	public void onAppStart(IApplicationInstance appInstance)
    	{
    		getLogger().info("onAppStart " );
    	}
    
    	public void onAppStop(IApplicationInstance appInstance)
    	{
    		getLogger().info("onAppStop " );
    	}
    
    	public int testGetConnectionLimit()
    	{
    		return this.connectionLimit;
    	}
    	
    	public void testSetConnectionLimit(int connectionLimit)
    	{
    		this.connectionLimit = connectionLimit;
    	}
    	
    	public void logSomething(String logStr)
    	{
    		getLogger().info("logSomething: "+logStr);
    	}
    }
    Your module will be located in the MBeans tab of JConsole in the following path:
    WowzaMediaServerPro:VHosts,_defaultVHost_,Applications,[application],ApplicationInstances,_definst_,Modules,MyModul,Instance
    The attributes will be available in the Attributes section and the methods in the Operations section.


    If you're having problems or want to discuss this article, post in our forum.