Check available services with WildFly

WildFly Services are classes which implement the interface org.jboss.msc.service.Service:

 

In order to query for active services from the CLI you can query the service-container as follows:

/core-service=service-container:dump-services()

As the list can be quite verbose, you can launch the CLI command in combination with the grep command from the shell. Here’s for example how to query for the jgroups service to be active:

$ ./jboss-cli.sh --connect --command="/core-service=service-container:dump-services()" | grep jgroups

As an alternative, you could query the MBean jboss.msc:type=container,name=jboss-as via JMX as in the following example:

If you want to query the status programmatically, here’s an example which shows how to query for the infinispan.server service using the getServicesStatus method:

JMXServiceURL address = new JMXServiceURL("service:jmx:remote+http://localhost:9990");

connector = JMXConnectorFactory.connect(address, null);

connection = connector.getMBeanServerConnection();

System.out.println("Connected to MBean Server");

ObjectName mbeanName = new ObjectName("jboss.msc:type=container,name=jboss-as");

//  Invoke operation

String opParams[] = {"jboss.infinispan.server"};

String opSig[] = {java.lang.String.class.getName()};
javax.management.openmbean.CompositeDataSupport out = (javax.management.openmbean.CompositeDataSupport) connection.invoke(mbeanName, "getServiceStatus", opParams, opSig);
System.out.println(out.get("stateName"));
Found the article helpful? if so please follow us on Socials