3 Replies Latest reply on Dec 16, 2013 11:28 AM by Radoslav Husar

    how to read proxylist from domain.xml using jmx

    Shankar Kodgal Newbie

      I need to get proxy-list from domain.xml using java.

      I tried using following JMX and its not working

      map = (Map<InetSocketAddress, String>)ManagementFactory.getPlatformMBeanServer().getAttribute(ObjectName.getInstance("jboss.web:type=Service,serviceName=ModCluster"),"proxyInfo");

       

      What is the best approach to get this list?

        • 1. Re: how to read proxylist from domain.xml using jmx
          Radoslav Husar Master

          The best way is to use the CLI:

           

          [standalone@localhost:9999 /] /subsystem=modcluster/mod-cluster-config=configuration:read-attribute(name=proxy-list)

          {

              "outcome" => "success",

              "result" => "localhost:6666"

          }

           

          See how to use the API programatically:

           

          The native management API - JBoss AS 7.1 - Project Documentation Editor

          • 2. Re: how to read proxylist from domain.xml using jmx
            Shankar Kodgal Newbie

            Thanks for the information.

             

            Yes, I can get this from CLI. But how to get same thru programatically?

            • 3. Re: Re: how to read proxylist from domain.xml using jmx
              Radoslav Husar Master

              Programatically, for example the following prints the JSON result on the standard output:

               

              import java.io.IOException;
              import java.net.InetAddress;
              
              
              import org.jboss.as.controller.client.ModelControllerClient;
              import org.jboss.dmr.ModelNode;
              
              
              /**
              * // TODO: Document this
              *
              * @author Radoslav Husar
              */
              public class Main {
              
              
                  public static void main(String[] args) throws IOException {
                      ModelControllerClient client = ModelControllerClient.Factory.create(InetAddress.getByName("localhost"), 9999);
              
              
                      ModelNode op = new ModelNode();
                      op.get("operation").set("read-attribute");
              
              
                      ModelNode address = op.get("address");
                      address.add("subsystem", "modcluster");
                      address.add("mod-cluster-config", "configuration");
              
              
                      op.get("name").set("proxy-list");
              
              
                      System.out.println(client.execute(op).toJSONString(false));
                  }
              }
              

               

              The dependencies section in maven could look like this:

               

                  <dependencies>
                      <dependency>
                          <groupId>org.jboss.as</groupId>
                          <artifactId>jboss-as-appclient</artifactId>
                          <version>7.1.3.Final</version>
                      </dependency>
                  </dependencies>