msgbartop
Various ramblings-on, mostly about Red5
msgbarbottom

27 May 08 Using JMX in Red5

The first step to perform when using JMX in Red5 is to get the MBeanServer. Once you have a server instance you may look up, create, register, and unregister mbeans. MBeans provide access to methods on classes which implement the associated MBean interface, most of the details about this are beyond the scope of this post. Today, we will cover the loading and unloading of a Red5 context.

    MBeanServer mbs = JMXFactory.getMBeanServer();
    ObjectName oName = JMXFactory.createObjectName("type", "ContextLoader");
    ContextLoaderMBean contextLoader = null;
    if (mbs.isRegistered(oName)) {
        contextLoader = (ContextLoaderMBean) MBeanServerInvocationHandler.newProxyInstance
(mbs, oName, ContextLoaderMBean.class, true);
        System.out.println("Context loader was found");
    } else {
        System.err.println("Context loader was not found");
    }

Once you have the context loader you can load the context. The context in this case is a Red5 default context consisting of a group of web applications that have been Red5 enabled. To be Red5 enabled means that they have the proper configurations and a class extending org.red5.server.adapter.ApplicationAdapter.

    if (contextLoader != null) {
	contextLoader.loadContext("localhost", "c:/red5/webapps/red5-default.xml");		
    }

To unload the context perform this step.

    if (contextLoader != null) {
	contextLoader.unloadContext("localhost");
    }

See how simple that is?

Please note that I do not condone the use of System.out as a substitute for proper logging

Tags: , ,



Reader's Comments

  1. |

    […] Paul Gregoire at Infrared5 has just posted on using JMX in Red5.

  2. |

    For you VBScript kiddies.. here is an example of VBS and JMX communication http://blogs.sun.com/jmxnetbeans/entry/vbscript_to_play_poker_with1

  3. |

    Hi,
    I’m trying to stream a live video but to no avail.
    I have install Adobe Flash Encoder and have installed RED5 server, whats next, remember i’m looking for live video streaming!

  4. |

    I’ve been fiddling with JMX and Red5 for a while now. I have no problems with local connections, but am totally stumped with remote connections.

    Is there any chance you could write a small article about how this works?

    As far as I can tell Red5 includes the MBeanServer, and Connectors. In 0.6 at least, these are setup in red5-common.xml. What I’m not clear on is how the “rmiregistry” comes into all of this :-)

  5. |

    I got the Below error when i stop the red5

    [root@localhost ~]# /etc/init.d/red5 stop
    Stopping red5: Starting Red5 (org.red5.server.Shutdown)…
    Attempting to connect to RMI port: 9999
    java.io.IOException: Failed to retrieve RMIServer stub: javax.naming.ServiceUnavailableException [Root exception is java.rmi.ConnectException: Connection refused to host: 127.0.0.1; nested exception is:
    java.net.ConnectException: Connection refused]
    at javax.management.remote.rmi.RMIConnector.connect(Unknown Source)
    at javax.management.remote.JMXConnectorFactory.connect(Unknown Source)
    at org.red5.server.Shutdown.main(Shutdown.java:70)
    Caused by: javax.naming.ServiceUnavailableException [Root exception is java.rmi.ConnectException: Connection refused to host: 127.0.0.1; nested exception is:
    java.net.ConnectException: Connection refused]
    at com.sun.jndi.rmi.registry.RegistryContext.lookup(Unknown Source)
    at com.sun.jndi.toolkit.url.GenericURLContext.lookup(Unknown Source)
    at javax.naming.InitialContext.lookup(Unknown Source)
    at javax.management.remote.rmi.RMIConnector.findRMIServerJNDI(Unknown Source)
    at javax.management.remote.rmi.RMIConnector.findRMIServer(Unknown Source)
    … 3 more
    Caused by: java.rmi.ConnectException: Connection refused to host: 127.0.0.1; nested exception is:
    java.net.ConnectException: Connection refused
    at sun.rmi.transport.tcp.TCPEndpoint.newSocket(Unknown Source)
    at sun.rmi.transport.tcp.TCPChannel.createConnection(Unknown Source)
    at sun.rmi.transport.tcp.TCPChannel.newConnection(Unknown Source)
    at sun.rmi.server.UnicastRef.newCall(Unknown Source)
    at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)
    … 8 more
    Caused by: java.net.ConnectException: Connection refused
    at java.net.PlainSocketImpl.socketConnect(Native Method)
    at java.net.PlainSocketImpl.doConnect(Unknown Source)
    at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
    at java.net.PlainSocketImpl.connect(Unknown Source)
    at java.net.SocksSocketImpl.connect(Unknown Source)
    at java.net.Socket.connect(Unknown Source)
    at java.net.Socket.connect(Unknown Source)
    at java.net.Socket.(Unknown Source)
    at java.net.Socket.(Unknown Source)
    at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(Unknown Source)
    at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(Unknown Source)
    … 13 more
    [root@localhost ~]#



Leave a Comment


Fatal error: Call to undefined function akismet_counter() in C:\xampp\htdocs\paulgregoireblog\wp-content\themes\googlechrome\footer.php on line 9