30.1 Creating Custom MBean Service for the FioranoMQ Server
Below are the steps to create and register a custom MBean Service for the FioranoMQ Server:
1. Create Service: (See Sample 1.)
- Create an MBean Java Class and extend the fiorano.jms.jmx.ComponentMBean.
- Override life cycle methods including createService(), startService() and stopService() which are invoked by the Fiorano Server during server initialization.
- Write the code specific to the service in these methods. (Look at the sample 1.)
- Compile using compile-client.bat.
- Write an .xml file of the same name describing the MBean's attributes and save it in the same directory as the MBean class file. Create a jar file. (See Sample 4.)Update the fmq.conf with the location of this jar file (under the java.classpath heading).
- To install FioranoMQ as a Windows NT Service, update %FIORANO_HOME%/WinService/conf/fmq.conf with the location of this jar file.
Sample 1:
package com.customMBean.mq.fiorano;
import fiorano.jms.jmx.ComponentMBean;
import java.io.PrintStream;
import fiorano.jms.common.FioranoException;
import fiorano.jms.route.def.*;
public class PubSubTestAdapterMBean extends ComponentMBean
{
public PubSubTestAdapterMBean()
{
}
public void createService()
{
System.err.println("creating PubSubTest...");
pubsubtest = new PubSubTest();
pubsubtest.printConfiguration();
}
public void startService()
{
System.err.println("starting PubSubTest...");
pubsubtest.run();
}
public void stopService()
{
System.err.println("stopping PubSubTest...");
}
public void destroyService()
{
System.err.println("destroying PubSubTest...");
}
public Object getResource()
{
return this;
}
public void setFMQConnectionManager(javax.management.ObjectName obj){
}
protected PubSubTest pubsubtest;
}
2. Configure Service: (See Sample 2.)
- Create a directory in the %FIORANO_INSTALL_DIR%\fmq\profiles\FioranoMQ\deploy\services.
- For example- Create a directory PubSubTest in the location. Create a service descriptor file with the MBean Class name, the name and type of service and copy this file into the above directory.
- If this service is dependent on other services, use the dependent element in the Service Descriptor:
PubSubTestAdapterMBean0-service.xml:
<server>
<mbean code="com.cunstomMBean.mq.fiorano.PubSubTestAdapterMBean" name="Iris:ServiceType=PubSubTest,Name=PubSubTestService" xmbean-dd="com/customMBean/mq/fiorano/PubSubTestAdapterMBean.xml">
<depends >Fiorano.mq.pubsub:ServiceType=PubSubManager,Name=TopicSubSystem</depends>
</mbean>
</server>
4. If the service on which this is dependent is not known, configure this service to start after all other Server services have started. as stated in step 3
Sample 2:
<server>
<mbean code="com.customMBean.mq.fiorano.PubSubTestAdapterMBean" name="Iris:ServiceType=PubSubTest,Name=PubSubTestService" xmbean-dd="com/ customMBean /mq/fiorano/PubSubTestAdapterMBean.xml">
</mbean>
</server>
3. Deploy Service: (See Sample 3.)
- If the required dependencies have been specified in the service descriptor file then this file can be appended to any the FioranoMQ.lst file. (Note: The sorting order is defined by the dependency specified not by the location of the dependency in the file.)
- If required dependencies have not been specified start the service after all other Server services are started. Create a separate list file and add service entries to this file. Add this file to the end of the list file entries in the deploy.xml file.
Sample 3:
(Deploy.xml)
<?xml version="1.0" encoding="UTF-8"?>
<list>FMQBootstrap.lst,FioranoMQ.lst,DefaultMQObjects.lst,TestService.lst</list>
4. Start the FioranoMQ server
Sample 4:
<mbean>
<descriptors>
<descriptor name="ComponentName" value="ComponentValue"/>
...
...
...
</descriptors>
<class><!--Name of class --></class>
<!-attributes->
<attribute access="read-only" getMethod="getStateString">
<description>(no description)</description>
<name>StateString</name>
<type>java.lang.String</type>
</attribute>
...
...
...
<!--operations -->
<description>Save the Current State</description>
<name>save</name>
<return-type>boolean</return-type>
<descriptors>
</descriptors>
...
...
...
</mbean>