Page 1 of 2 12 LastLast
Results 1 to 10 of 18

Thread: Spring JMX in a distributed Websphere environment

  1. #1
    Join Date
    Nov 2005
    Posts
    5

    Default Spring JMX in a distributed Websphere environment

    Anyone have any expierence with Spring JMX on WebSphere 5.1 and willing share some code snippets? Its seems WebSphere requires you to jump through some hoops in terms of registering an MBean in a manner that will allow it to participate in a distributed environment (for example using the WebSphere specific AdminService or MBeanFactory).

    The vanilla MBeanExporter works, but to use the MBean in a distributed environment, it looks like at minimum the object name needs to contain a type, the cell name, the node name, and process name. Anyone got any ideas?

  2. #2
    Join Date
    Aug 2004
    Location
    Southampton, UK
    Posts
    826

    Default

    I can't be sure that MBeanExporter will work in a distributed environment. The JMX spec doesn't really cover distribution currently so most vendors have their own custom solution.

    Rob
    Rob Harrop
    Lead Engineer, dm Server
    SpringSource
    http://www.springsource.com

    Co-Author - Pro Spring

  3. #3
    Join Date
    Nov 2005
    Posts
    5

    Default

    Ya, I don't expect it to work out of the box, just wondering if anyone has used the MBeanExporter in WebSphere ...

  4. #4
    Join Date
    Mar 2005
    Posts
    10

    Default AdminService

    The MBean needs to be 'declared' using the AdminService.activateMBean method. Then it becomes 'distributed'.

    Note, JMX with WAS has the following features

    A) If you want to connect to the DMgr from the JMX clients then the DMGR and the node agent on the node with the server hosting the MBean need to be running.

    B) You can avoid this by attaching directly to the SOAP port on the JVM hosting the MBean but if the MBean moves from server to server, this doesn't work.

    We're looking at fixing this in the future by allowing clients to connect to any JVM and find any MBean.

    Billy (IBM)
    http://www.billynewport.com

  5. #5
    Join Date
    Nov 2005
    Posts
    5

    Default

    So it needs more than just having the the cell name, node name, and process name in the object name?

    The article here seems to imply that if your object name is crafted correctly it'll work.

  6. #6

    Default Help, any response to this ?

    any info from the WAS gurus

  7. #7
    Join Date
    Nov 2005
    Posts
    5

    Default The following worked

    Get ahold of WebSphere's admin service

    Code:
    <bean id="adminService" class="com.ibm.websphere.management.AdminServiceFactory" factory-method="getAdminService"/>
    Get the bits from the admin service needed for the object name.

    Code:
    <bean id="adminService.defaultDomain" class="org.springframework.beans.factory.config.PropertyPathFactoryBean"/>
    <bean id="adminService.cellName" class="org.springframework.beans.factory.config.PropertyPathFactoryBean"/>
    <bean id="adminService.nodeName" class="org.springframework.beans.factory.config.PropertyPathFactoryBean"/>
    <bean id="adminService.processName" class="org.springframework.beans.factory.config.PropertyPathFactoryBean"/>
    Create the WebSphere object naming strategy

    Code:
    <bean id="websphereNamingStrategy" class="WebsphereNamingStrategy">
        	<property name="domainName" ref="adminService.defaultDomain"/>
    	<property name="cellName" ref="adminService.cellName"/>
    	<property name="nodeName" ref="adminService.nodeName"/>
    	<property name="processName" ref="adminService.processName"/>
    </bean>
    Export someBean with using the WebSphere object naming strategy.

    Code:
    <bean id="beanExporter" class="org.springframework.jmx.export.MBeanExporter">
        	<property name="beans">
          		<map>
            		<entry key="someBean" value-ref="someBean"/>
          		</map>
        	</property>
    	<property name="namingStrategy" ref="websphereNamingStrategy"/>
     </bean>
    WebSphere Object Naming Strategy. Creates an object name with the WebSphere required bits.

    Code:
    public class WebsphereNamingStrategy implements ObjectNamingStrategy 	
    {
        private String domainName;
        private String cellName;
        private String nodeName;
        private String processName;
        
        public ObjectName getObjectName(Object object, String name)
            throws MalformedObjectNameException
        {
            StringBuffer objectName = new StringBuffer();
            objectName.append(domainName);
            objectName.append(":cell=");
            objectName.append(cellName);
            objectName.append(",name=");
            objectName.append(name);
            objectName.append(",type=");
            objectName.append(ClassUtils.getShortName(object.getClass()));
            objectName.append(",node=");
            objectName.append(nodeName);
            objectName.append(",process=");
            objectName.append(processName);
            
    
    	return ObjectNameManager.getInstance(objectName.toString());
        }
        
        
        public String getCellName()
        {
            return cellName;
        }
        
        public void setCellName(String cellName)
        {
            this.cellName = cellName;
        }
        
        public String getDomainName()
        {
            return domainName;
        }
        
        public void setDomainName(String domainName)
        {
            this.domainName = domainName;
        }
        public String getNodeName()
        {
            return nodeName;
        }
        
        public void setNodeName(String nodeName)
        {
            this.nodeName = nodeName;
        }
        
        public String getProcessName()
        {
            return processName;
        }
        
        public void setProcessName(String processName)
        {
            this.processName = processName;
        }
    }

  8. #8
    Join Date
    Jan 2005
    Location
    Bucharest, Romania
    Posts
    5,403

    Default

    Can you post this on wiki? thanks.
    Costin Leau
    SpringSource - http://www.SpringSource.com- Spring Training, Consulting, and Support - "From the Source"
    http://twitter.com/costinl
    Please use [ c o d e ] [ / c o d e ] tags

  9. #9
    Join Date
    Nov 2005
    Posts
    5

    Default

    Where in the wikki should I add it?

  10. #10
    Join Date
    Jan 2005
    Location
    Bucharest, Romania
    Posts
    5,403

    Default

    why not here: http://opensource2.atlassian.com/con...DOC/Spring+JMX ? Add it as a child page
    Costin Leau
    SpringSource - http://www.SpringSource.com- Spring Training, Consulting, and Support - "From the Source"
    http://twitter.com/costinl
    Please use [ c o d e ] [ / c o d e ] tags

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •