monitoring

Writing java based JMS Client for WildFly10 default ActiveMQ Artemis broker.

Hi,

The HornetQ codebase was donated to the Apache ActiveMQ project, and the HornetQ community joined to build a next-generation messaging broker. ActiveMQ Artemis includes many new features, and also retains protocol compatibility with the HornetQ broker. WildFly 10 includes this new exciting project as its JMS broker, and due to the protocol compatibility, it fully replaces the HornetQ project. So as part of this simple demo we will see how we can connect to the ActiveMQ broker present inside the WildFLy10 via Standalone java based client code using standard JMS APIs.

Find more about “Apache ActiveMQ Artemis” in http://hornetq.blogspot.in/2015/06/hornetq-apache-donation-and-apache.html
AND
http://activemq.apache.org/artemis/

This article is basically clone of http://middlewaremagic.com/jboss/?p=2724 with just few WildFly 10.x specific changes related to WildFly JMS configuration, However the client code will remain same.

In this example we will be learning the following things:

1. How to create a simple JMS Queue in WildFly 10.x
2. How to create a user in ApplicationRealm and assign it to “guest” role.
3. How to create the InitialContext on the standalone client side.
4. What all jars are needed on the client side in order to lookup the JNDI resources deployed on WildFly.
5. Some common issues which you might encounter while running sample java code are explained in the other article: http://middlewaremagic.com/jboss/?p=2724

Creating A Simple JMS Queue on WildFly 10 side

Step-1). Start the WildFly 10 “full” profile (which has messaging) as following:

   $ cd /PATH/TO/wildfly-10.0.0.CR3-SNAPSHOT/bin
   $ ./standalone.sh -c standalone-full.xml

Step-2). Create a simple JMS user on WildFly 10 side and this user must belong to “guest” role. Please see the “messaging subsystem” configuration of “standalone-full.xml” to know more about “guest” role.
username: jmsuser
password: jmsuser@123
user role: guest
Realm: ApplicationRealm

   $ cd /PATH/TO/wildfly-10.0.0.CR3-SNAPSHOT/bin
   $ ./add-user.sh 

What type of user do you wish to add? 
 a) Management User (mgmt-users.properties) 
 b) Application User (application-users.properties)
(a): b

Enter the details of the new user to add.
Using realm 'ApplicationRealm' as discovered from the existing property files.
Username : jmsuser
User 'jmsuser' already exists and is enabled, would you like to... 
 a) Update the existing user password and roles 
 b) Disable the existing user 
 c) Type a new username
(a): a
Password recommendations are listed below. To modify these restrictions edit the add-user.properties configuration file.
 - The password should be different from the username
 - The password should not be one of the following restricted values {root, admin, administrator}
 - The password should contain at least 8 characters, 1 alphabetic character(s), 1 digit(s), 1 non-alphanumeric symbol(s)
Password : 
Re-enter Password : 
What groups do you want this user to belong to? (Please enter a comma separated list, or leave blank for none)[guest]: guest
Updated user 'jmsuser' to file '/Users/jsensharma/NotBackedUp/Installed/wildfly-10.0.0.CR3-SNAPSHOT/standalone/configuration/application-users.properties'
Updated user 'jmsuser' to file '/Users/jsensharma/NotBackedUp/Installed/wildfly-10.0.0.CR3-SNAPSHOT/domain/configuration/application-users.properties'
Updated user 'jmsuser' with groups guest to file '/Users/jsensharma/NotBackedUp/Installed/wildfly-10.0.0.CR3-SNAPSHOT/standalone/configuration/application-roles.properties'
Updated user 'jmsuser' with groups guest to file '/Users/jsensharma/NotBackedUp/Installed/wildfly-10.0.0.CR3-SNAPSHOT/domain/configuration/application-roles.properties'
Is this new user going to be used for one AS process to connect to another AS process? 
e.g. for a slave host controller connecting to the master or for a Remoting connection for server to server EJB calls.
yes/no? yes
To represent the user add the following to the server-identities definition <secret value="am1zdXNlckAxMjM=" />

Step-3). Creating a simple JMS Queue using the WildFly CLI command line utility. NOTE the JNDI name should contain “java:/jboss/exported” prefix or else the JMS queue will can not be looked up remotely.

   $ cd /PATH/TO/wildfly-10.0.0.CR3-SNAPSHOT/bin
   $ ./jboss-cli.sh -c
   
   [standalone@localhost:9990 /] /subsystem=messaging-activemq/server=default/jms-queue=TestQ/:add(entries=["java:/jboss/exported/jms/queue/TestQ"])
     {"outcome" => "success"}
     
   [standalone@localhost:9990 /] :reload
     {
       "outcome" => "success",
       "result" => undefined
     }

The generated XML snippet in the “standalone-full.xml” file will look like following:

        <subsystem xmlns="urn:jboss:domain:messaging-activemq:1.0">
            <server name="default">
                <security-setting name="#">
                    <role name="guest" delete-non-durable-queue="true" create-non-durable-queue="true" consume="true" send="true"/>
                </security-setting>
                <address-setting name="#" message-counter-history-day-limit="10" page-size-bytes="2097152" max-size-bytes="10485760" expiry-address="jms.queue.ExpiryQueue" dead-letter-address="jms.queue.DLQ"/>
                <http-connector name="http-connector" endpoint="http-acceptor" socket-binding="http"/>
                <http-connector name="http-connector-throughput" endpoint="http-acceptor-throughput" socket-binding="http">
                    <param name="batch-delay" value="50"/>
                </http-connector>
                <in-vm-connector name="in-vm" server-id="0"/>
                <http-acceptor name="http-acceptor" http-listener="default"/>
                <http-acceptor name="http-acceptor-throughput" http-listener="default">
                    <param name="batch-delay" value="50"/>
                    <param name="direct-deliver" value="false"/>
                </http-acceptor>
                <in-vm-acceptor name="in-vm" server-id="0"/>
                <jms-queue name="ExpiryQueue" entries="java:/jms/queue/ExpiryQueue"/>
                <jms-queue name="DLQ" entries="java:/jms/queue/DLQ"/>

                <!-- Newly added JMS Queue is Here -->
                <jms-queue name="TestQ" entries="java:/jboss/exported/jms/queue/TestQ"/>

                <connection-factory name="InVmConnectionFactory" entries="java:/ConnectionFactory" connectors="in-vm"/>
                <connection-factory name="RemoteConnectionFactory" entries="java:jboss/exported/jms/RemoteConnectionFactory" connectors="http-connector"/>
                <pooled-connection-factory name="activemq-ra" transaction="xa" entries="java:/JmsXA java:jboss/DefaultJMSConnectionFactory" connectors="in-vm"/>
            </server>
        </subsystem>

NOTE: The “java:/jboss/exported” JNDI prefix is needed in the JNDI name here to ensure that a remote client (a client running outside of that JVM where the JNDI name is bound) can do the lookup.

Writing WildFly JMS Client

Step-4). Create a directory somewhere in your filesystem to place the project WildFly kms client project.

  $ mkdir WildFly10_JMS_Client
  $ mkdir -p WildFly10_JMS_Client/src/client

Step-5). Lets write the “WildFlyJmsQueueSender.java” program which will send some jms messages to the JMS Queue “TestQ” deployed on WildFly and Lets place it inside the “WildFly10_JMS_Client/src/client” as following:

package client;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import java.util.Properties;

//jms stuff
import javax.jms.JMSException;
import javax.jms.Queue;
import javax.jms.QueueConnection;
import javax.jms.QueueConnectionFactory;
import javax.jms.QueueSender;
import javax.jms.QueueSession;
import javax.jms.Session;
import javax.jms.TextMessage;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import java.io.IOException;

public class WildFlyJmsQueueSender {
  public final static String JMS_CONNECTION_FACTORY_JNDI="jms/RemoteConnectionFactory";
  public final static String JMS_QUEUE_JNDI="jms/queue/TestQ";
  public final static String JMS_USERNAME="jmsuser";       //  The role for this user is "guest" in ApplicationRealm
  public final static String JMS_PASSWORD="jmsuser@123";  
  public final static String WILDFLY_REMOTING_URL="http-remoting://localhost:8080";

  private QueueConnectionFactory qconFactory;
  private QueueConnection qcon;
  private QueueSession qsession;
  private QueueSender qsender;
  private Queue queue;
  private TextMessage msg;

  public static void main(String[] args) throws Exception {
    InitialContext ic = getInitialContext();
    WildFlyJmsQueueSender queueSender = new WildFlyJmsQueueSender();
    queueSender.init(ic, JMS_QUEUE_JNDI);
    readAndSend(queueSender);
    queueSender.close();
  }

  public void init(Context ctx, String queueName) throws NamingException, JMSException {
    qconFactory = (QueueConnectionFactory) ctx.lookup(JMS_CONNECTION_FACTORY_JNDI);
    
    //  If you won't pass jms credential here then you will get 
    // [javax.jms.JMSSecurityException: HQ119031: Unable to validate user: null]    
    qcon = qconFactory.createQueueConnection(this.JMS_USERNAME, this.JMS_PASSWORD);   
    
    qsession = qcon.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
    queue = (Queue) ctx.lookup(queueName);
    qsender = qsession.createSender(queue);
    msg = qsession.createTextMessage();
    qcon.start();
  }

  public void send(String message,int counter) throws JMSException {
    msg.setText(message);
    msg.setIntProperty("counter", counter);
    qsender.send(msg);
  }

  public void close() throws JMSException {
    qsender.close();
    qsession.close();
    qcon.close();
  }

  private static void readAndSend(WildFlyJmsQueueSender wildFlyJmsQueueSender) throws IOException, JMSException {
    String line="Test Message Body with counter = ";
    for(int i=0;i<10;i++) {
          wildFlyJmsQueueSender.send(line+i,i);
          System.out.println("JMS Message Sent: "+line+i+"\n");
       }
  }

  private static InitialContext getInitialContext() throws NamingException {
     InitialContext context=null;
     try {
           Properties props = new Properties();
           props.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");
           props.put(Context.PROVIDER_URL, WILDFLY_REMOTING_URL);   // NOTICE: "http-remoting" and port "8080"
           props.put(Context.SECURITY_PRINCIPAL, JMS_USERNAME);
           props.put(Context.SECURITY_CREDENTIALS, JMS_PASSWORD);
           //props.put("jboss.naming.client.ejb.context", true);
           context = new InitialContext(props);	
	       System.out.println("\n\tGot initial Context: "+context);		
      } catch (Exception e) {
           e.printStackTrace();
      }
    return context;
  }
}

Step-6). Lets write the “WildFlyJmsQueueReceive.java” program which will consume messages from the JMS Queue deployed in WildFly and Lets place it inside the “WildFly10_JMS_Client/src/client” as following:

package client;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import java.util.Properties;

//jms stuff
import javax.jms.JMSException;
import javax.jms.MessageListener;
import javax.jms.Queue;
import javax.jms.QueueConnection;
import javax.jms.QueueConnectionFactory;
import javax.jms.QueueReceiver;
import javax.jms.QueueSession;
import javax.jms.Session;
import javax.jms.TextMessage;
import javax.jms.Message;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import java.io.IOException;

public class WildFlyJmsQueueReceive  implements MessageListener {
  public final static String JMS_CONNECTION_FACTORY_JNDI="jms/RemoteConnectionFactory";
  public final static String JMS_QUEUE_JNDI="jms/queue/TestQ";
  public final static String JMS_USERNAME="jmsuser";       //  The role for this user is "guest" in ApplicationRealm
  public final static String JMS_PASSWORD="jmsuser@123";  
  public final static String WILDFLY_REMOTING_URL="http-remoting://localhost:8080";


  private QueueConnectionFactory qconFactory;
  private QueueConnection qcon;
  private QueueSession qsession;
  private QueueReceiver qReceiver;
  private Queue queue;
  private TextMessage msg;
  private boolean quit = false;

  public static void main(String[] args) throws Exception {
    InitialContext ic = getInitialContext();
    WildFlyJmsQueueReceive wildflyJmsQueueReceive = new WildFlyJmsQueueReceive();
    wildflyJmsQueueReceive.init(ic, JMS_QUEUE_JNDI);
    System.out.println("JMS Ready To Receive Messages (To quit, send a \"quit\" message from QueueSender.class).");
    // Waiting until a "quit" message has been received.
    synchronized(wildflyJmsQueueReceive) {
         while (! wildflyJmsQueueReceive.quit) {
             try {
                   wildflyJmsQueueReceive.wait();
             }
             catch (InterruptedException ie) {
                   ie.printStackTrace();
             }
         }
     }
     wildflyJmsQueueReceive.close();
  }
  
  public void init(Context ctx, String queueName) throws NamingException, JMSException {
    qconFactory = (QueueConnectionFactory) ctx.lookup(JMS_CONNECTION_FACTORY_JNDI);

    //  If you won't pass jms credential here then you will get 
    // [javax.jms.JMSSecurityException: HQ119031: Unable to validate user: null]    
    qcon = qconFactory.createQueueConnection(this.JMS_USERNAME, this.JMS_PASSWORD);   
    
    qsession = qcon.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
    queue = (Queue) ctx.lookup(queueName);
    qReceiver = qsession.createReceiver(queue);
    qReceiver.setMessageListener(this);
    qcon.start();
  }

  public void onMessage(Message msg) {
     try {
           String msgText;
           if (msg instanceof TextMessage) {
              msgText = ((TextMessage)msg).getText();
           } else {
              msgText = msg.toString();
           }
           System.out.println("\n<Msg_Receiver> "+ msgText );
           if (msgText.equalsIgnoreCase("quit")) {
             synchronized(this) {
             	 quit = true;
             	 this.notifyAll(); // Notify main thread to quit
             }
           }
      } catch (JMSException jmse) {
          jmse.printStackTrace();
     }
  }

  public void close() throws JMSException {
    qReceiver.close();
    qsession.close();
    qcon.close();
  }
  
  private static InitialContext getInitialContext() throws NamingException {
     InitialContext context=null;
     try {
           Properties props = new Properties();
           props.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");
           props.put(Context.PROVIDER_URL, WILDFLY_REMOTING_URL);   // NOTICE: "http-remoting" and port "8080"
           props.put(Context.SECURITY_PRINCIPAL, JMS_USERNAME);
           props.put(Context.SECURITY_CREDENTIALS, JMS_PASSWORD);
           //props.put("jboss.naming.client.ejb.context", true);
           context = new InitialContext(props);	
	   System.out.println("\n\tGot initial Context: "+context);		
      } catch (Exception e) {
           e.printStackTrace();
      }
    return context;
  }
}

Step-7). In order to run the above program easily we are going to use ANT, However users can also run the above programs manually by adding the “$JBOSS_HOME/bin/client/jboss-client.jar” in the class path of the client. Here we will be writing the following ind of “build.xml” file inside the “WildFly10_JMS_Client” as following:

<project name="WildFly_Jms_Client" default="runSender">
<property name="jboss.home" value="/Users/jsensharma/NotBackedUp/Installed/wildfly-10.0.0.CR3-SNAPSHOT" />
<property name="jboss.module.dir" value="${jboss.home}/modules" />
<property name="basedir" value="." />
<property name="tmp.dir" value="tmp" />
<property name="src.dir" value="src" />
<property name="output.dir" value="build" />
<property name="client.jar.name" value="wildfly_jms_client.jar" />

        <!-- Client Needs the following Jar to be present in the CLASSPATH including -->
        <path id="jboss.new.client.classpath">
           <fileset dir="${jboss.home}/bin/client">
               <include name="jboss-client.jar" />
           </fileset>  
        </path>

        <target name="runSender">
           <delete dir="${tmp.dir}" />
           <mkdir dir="${tmp.dir}" />
           <javac srcdir="${src.dir}/client" destdir="${tmp.dir}" includes="WildFlyJmsQueueSender.java" classpathref="jboss.new.client.classpath"/> 
           <copy file="${src.dir}/client/WildFlyJmsQueueSender.java" todir="${tmp.dir}/client"/>        
           <jar jarfile="${output.dir}/${client.jar.name}" basedir="${tmp.dir}" compress="true" />
           <delete dir="${tmp.dir}"/>
           <java classname="client.WildFlyJmsQueueSender" fork="true" classpathref="jboss.new.client.classpath">
               <classpath>
                  <pathelement location="${output.dir}/${client.jar.name}"/>
               </classpath>
           </java>
        </target>     

        <target name="runReceive">
           <delete dir="${tmp.dir}" />
           <mkdir dir="${tmp.dir}" />
           <javac srcdir="${src.dir}/client" destdir="${tmp.dir}" includes="WildFlyJmsQueueReceive.java" classpathref="jboss.new.client.classpath"/> 
           <copy file="${src.dir}/client/WildFlyJmsQueueReceive.java" todir="${tmp.dir}/client"/>        
           <jar jarfile="${output.dir}/${client.jar.name}" basedir="${tmp.dir}" compress="true" />
           <delete dir="${tmp.dir}"/>
           <java classname="client.WildFlyJmsQueueReceive" fork="true" classpathref="jboss.new.client.classpath">
               <classpath>
                  <pathelement location="${output.dir}/${client.jar.name}"/>
               </classpath>
           </java>
        </target>             
</project>

Running the WildFly 10 JMS client

Step-8). We can run the above ANT based kms client project simply by setting the ANT_HOME, JAVA_HOME and PATH as following :

For Unix Based OS:

$ export ANT_HOME=/PATH/TO/apache_ant_1.9.2
$ export JAVA_HOME=/PATH/TO/jdk1.8.0_60
$ export PATH=$JAVA_HOME/bin:$ANT_HOME/bin:$PATH
$ cd /PATH/TO/WildFly10_JMS_Client


<strong>For Windows Based OS</strong>
$ set ANT_HOME=C:\PATH\TO\apache_ant_1.9.2
$ set JAVA_HOME=C:\PATH\TO\jdk1.8.0_60
$ set PATH=%JAVA_HOME%\bin;%ANT_HOME%\bin;%PATH%
$ cd C:\WildFly10_JMS_Client

Step-9). In the same above command prompt, Lets run the “WildFlyJmsQueueSender.java” program which will send to messages to the “TestQ” present on WildFly 8 as following :

$ ant runSender

Buildfile: /Users/jsensharma/NotBackedUp/MM_Tests/WildFly/WildFly10_JMS_Client/build.xml

runSender:
    [mkdir] Created dir: /Users/jsensharma/NotBackedUp/MM_Tests/WildFly/WildFly10_JMS_Client/tmp
    [javac] /Users/jsensharma/NotBackedUp/MM_Tests/WildFly/WildFly10_JMS_Client/build.xml:20: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds
    [javac] Compiling 1 source file to /Users/jsensharma/NotBackedUp/MM_Tests/WildFly/WildFly10_JMS_Client/tmp
     [copy] Copying 1 file to /Users/jsensharma/NotBackedUp/MM_Tests/WildFly/WildFly10_JMS_Client/tmp/client
      [jar] Building jar: /Users/jsensharma/NotBackedUp/MM_Tests/WildFly/WildFly10_JMS_Client/build/wildfly_jms_client.jar
   [delete] Deleting directory /Users/jsensharma/NotBackedUp/MM_Tests/WildFly/WildFly10_JMS_Client/tmp
      Nov 08, 2015 4:15:53 PM org.xnio.Xnio <clinit>
      INFO: XNIO version 3.3.2.Final
      Nov 08, 2015 4:15:53 PM org.xnio.nio.NioXnio <clinit>
      INFO: XNIO NIO Implementation Version 3.3.2.Final
      
      	Got initial Context: javax.naming.InitialContext@5e7f2a19
      Nov 08, 2015 4:15:53 PM org.jboss.remoting3.EndpointImpl <clinit>
      INFO: JBoss Remoting version 4.0.14.Final
      Nov 08, 2015 4:15:54 PM org.jboss.ejb.client.remoting.VersionReceiver handleMessage
      INFO: EJBCLIENT000017: Received server version 2 and marshalling strategies [river]
      Nov 08, 2015 4:15:54 PM org.jboss.ejb.client.remoting.RemotingConnectionEJBReceiver associate
      INFO: EJBCLIENT000013: Successful version handshake completed for receiver context EJBReceiverContext{clientContext=org.jboss.ejb.client.EJBClientContext@785ae27e, receiver=Remoting connection EJB receiver [connection=Remoting connection <5720171f>,channel=jboss.ejb,nodename=banl13bca644a-3]} on channel Channel ID dfdae415 (outbound) of Remoting connection 13c57d7d to localhost/127.0.0.1:8080
      SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
      SLF4J: Defaulting to no-operation (NOP) logger implementation
      SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
      Nov 08, 2015 4:15:54 PM org.jboss.ejb.client.EJBClient <clinit>
      INFO: JBoss EJB Client version 2.1.2.Final
      JMS Message Sent: Test Message Body with counter = 0
      
      JMS Message Sent: Test Message Body with counter = 1
      
      JMS Message Sent: Test Message Body with counter = 2
      
      JMS Message Sent: Test Message Body with counter = 3
      
      JMS Message Sent: Test Message Body with counter = 4
      
      JMS Message Sent: Test Message Body with counter = 5
      
      JMS Message Sent: Test Message Body with counter = 6
      
      JMS Message Sent: Test Message Body with counter = 7
      
      JMS Message Sent: Test Message Body with counter = 8
      
      JMS Message Sent: Test Message Body with counter = 9
      

BUILD SUCCESSFUL
Total time: 2 seconds

Step-10). In the same above command prompt, Lets run the “WildFlyJmsQueueReceive.java” program which will receive the jms messages which are present in the “TestQ” present on WildFly 8 as following :

$ ant runReceive
Buildfile: /Users/jsensharma/NotBackedUp/MM_Tests/WildFly/WildFly10_JMS_Client/build.xml

runReceive:
    [mkdir] Created dir: /Users/jsensharma/NotBackedUp/MM_Tests/WildFly/WildFly10_JMS_Client/tmp
    [javac] /Users/jsensharma/NotBackedUp/MM_Tests/WildFly/WildFly10_JMS_Client/build.xml:34: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds
    [javac] Compiling 1 source file to /Users/jsensharma/NotBackedUp/MM_Tests/WildFly/WildFly10_JMS_Client/tmp
     [copy] Copying 1 file to /Users/jsensharma/NotBackedUp/MM_Tests/WildFly/WildFly10_JMS_Client/tmp/client
      [jar] Building jar: /Users/jsensharma/NotBackedUp/MM_Tests/WildFly/WildFly10_JMS_Client/build/wildfly_jms_client.jar
   [delete] Deleting directory /Users/jsensharma/NotBackedUp/MM_Tests/WildFly/WildFly10_JMS_Client/tmp
      Nov 08, 2015 4:28:23 PM org.xnio.Xnio <clinit>
      INFO: XNIO version 3.3.2.Final
      Nov 08, 2015 4:28:23 PM org.xnio.nio.NioXnio <clinit>
      INFO: XNIO NIO Implementation Version 3.3.2.Final
      Nov 08, 2015 4:28:23 PM org.jboss.remoting3.EndpointImpl <clinit>
      INFO: JBoss Remoting version 4.0.14.Final
      
      	Got initial Context: javax.naming.InitialContext@129458ea
      Nov 08, 2015 4:28:23 PM org.jboss.ejb.client.remoting.VersionReceiver handleMessage
      INFO: EJBCLIENT000017: Received server version 2 and marshalling strategies [river]
      Nov 08, 2015 4:28:23 PM org.jboss.ejb.client.remoting.RemotingConnectionEJBReceiver associate
      INFO: EJBCLIENT000013: Successful version handshake completed for receiver context EJBReceiverContext{clientContext=org.jboss.ejb.client.EJBClientContext@67d07b41, receiver=Remoting connection EJB receiver [connection=Remoting connection <533a0538>,channel=jboss.ejb,nodename=banl13bca644a-3]} on channel Channel ID c898038c (outbound) of Remoting connection 7a73ad16 to localhost/127.0.0.1:8080
      SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
      SLF4J: Defaulting to no-operation (NOP) logger implementation
      SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
      Nov 08, 2015 4:28:23 PM org.jboss.ejb.client.EJBClient <clinit>
      INFO: JBoss EJB Client version 2.1.2.Final
      JMS Ready To Receive Messages (To quit, send a "quit" message from QueueSender.class).
      
      <Msg_Receiver> Test Message Body with counter = 0
      
      <Msg_Receiver> Test Message Body with counter = 1
      
      <Msg_Receiver> Test Message Body with counter = 2
      
      <Msg_Receiver> Test Message Body with counter = 3
      
      <Msg_Receiver> Test Message Body with counter = 4
      
      <Msg_Receiver> Test Message Body with counter = 5
      
      <Msg_Receiver> Test Message Body with counter = 6
      
      <Msg_Receiver> Test Message Body with counter = 7
      
      <Msg_Receiver> Test Message Body with counter = 8
      
      <Msg_Receiver> Test Message Body with counter = 9

Issues which you may encounter

You might see some error/exceptions while running this demo in that case you can refer to the following article which explains some common issues which you might encounter while running this code. The following link also contains the remedies of those common exceptions.

Wildfly 8 based standalone JMS client code common issues and remedies ?
http://middlewaremagic.com/jboss/?p=2724

Monitoring JMS Queue using CLI

If we want to monitor the JMS Queue using jboss-cli.sh script then we can do it as following:

/subsystem=messaging-activemq/server=default/jms-queue=TestQ/:read-resource(recursive=true,include-runtime=true)
{
    "outcome" => "success",
    "result" => {
        "consumer-count" => 0,
        "dead-letter-address" => "jms.queue.DLQ",
        "delivering-count" => 0,
        "durable" => true,
        "entries" => ["java:/jboss/exported/jms/queue/TestQ"],
        "expiry-address" => "jms.queue.ExpiryQueue",
        "legacy-entries" => undefined,
        "message-count" => 20L,
        "messages-added" => 30L,
        "paused" => false,
        "queue-address" => "jms.queue.TestQ",
        "scheduled-count" => 0L,
        "selector" => undefined,
        "temporary" => false
    }
}

.
.
The Source code of this demo can be found at: (The code should remain same for WildFly 8/9/10)
https://github.com/jaysensharma/MiddlewareMagicDemos/tree/master/WildFly/JMS/WildFly_JMS_Client

.
.

Regards
Jay SenSharma


Client side Native Management API for monitoring JBossAS7.1.2

Hi,

JBossAS7 is one of the best application server which provides various options to control/manage/monitor the application resources using various options like jboss-cli.sh (CLI scripts) , jboss management console, JSON based monitoring & management using curl/wget, JBoss Native Management APIs …etc

Here in this article we will see how we can manage & monitor JBossAS 7.1.2 using JBoss Native Management APIs, this approach is best for the java developers, as in many production environments it is very convenient to manage the application respources based on java code. The developers wants to mmanage things using java style of programming, So for those develpers JBoss Native Management APIs is much convenient way of managing the JBoss.

More informations on this can be found in the following link: https://docs.jboss.org/author/display/AS7/The+native+management+API

The Source code for the following Demo is available in the github repository:
https://github.com/jaysensharma/MiddlewareMagicDemos/tree/master/NativeManagement_API_JBossAS712

Step1). First of all we will create a directory somewhere in our file system as “/home/jaysensharma/NativeManagement_API_JBossAS712” and then we will create a directory with name “src” inside “/home/jaysensharma/NativeManagement_API_JBossAS712”:

Step2). Now we will use the “org.jboss.as.controller.client.ModelControllerClient” API to establish connection to the JBoss Server/Controller, So create a program as “NativeManagementClient.java” inside “/home/jaysensharma/NativeManagement_API_JBossAS712/src” as following:

import java.net.UnknownHostException;
import javax.security.auth.callback.Callback;
import javax.security.auth.callback.CallbackHandler;
import javax.security.auth.callback.NameCallback;
import javax.security.auth.callback.PasswordCallback;
import javax.security.sasl.RealmCallback;
import javax.security.auth.callback.UnsupportedCallbackException;

import org.jboss.as.controller.client.ModelControllerClient;
import org.jboss.as.controller.client.ModelControllerClient.Factory;
import java.net.InetAddress;
import java.io.IOException;
import org.jboss.dmr.ModelNode;
import org.jboss.dmr.Property;


public class NativeManagementClient
{
    //static String host = "10.10.10.96"; // "localhost";
    static String host = "localhost";
    static int port = 9999;
    static String password = "admin";
    static String userid = "admin123";
    static String hostControllerName="master";
    static String serverName="JayServer";
    static boolean standaloneMode=true;     //  If you are running your Servers in Domain Mode then set this to false.
    static ModelControllerClient client = null;

    public static void main (String[] args)
       {
           try {
                 createAndCheckClientConnection();
                 performOperations(client);
               }

           catch (java.io.IOException ex)
               {
                 System.out.println("nn Unable to Connect to the Host: "+host+" or Port:"+port+"tt" + ex.getMessage());
                 //ex.printStackTrace();
               }
           catch (Exception ex)
               {
                 System.out.println("nnSomeThing is Wrong: "+ex.getMessage());
                 //ex.printStackTrace();
               }

           try {
                 if (client != null ) client.close();
               }
           catch (Exception e)
               {
                 System.out.println ("Exception: " + e.getMessage());
                 e.printStackTrace();
               }
        }


    public static void createAndCheckClientConnection() throws IOException
     {
                 // NOTE: For hostname as "localhost" there is no need to pass the username & password  */
                 //client = ModelControllerClient.Factory.create(host, port, null);

                 // If you are running this program remotely then you need to pass the credentials */
                 client = createClient (InetAddress.getByName(host), port, userid, password.toCharArray(), "ManagementRealm" );
                 System.out.println("Got the client: "+client);

                 // Checking whether Client is actually connected to Controller or not by executing dummy ModelNode? */
                 ModelNode op = new ModelNode();
                 op.get("operation").set("read-resource");
                 ModelNode returnVal=client.execute(op);
                 System.out.println("nnrelease-version: " + returnVal.get("result").get("release-version").asString());
                 System.out.println("release-codename: " + returnVal.get("result").get("release-codename").asString());
     }

   public static void performOperations(ModelControllerClient client)
      {
                  if(standaloneMode==true)
                     {
                        // FOR STANDALONE MODE use the "TestStandaloneModel" class as following:
                        TestStandaloneModel testStandaloneModel=new TestStandaloneModel();

                        // Getting Web Subsystem runtime Details */
                        testStandaloneModel.getWebSubsystemRuntimeDetails(client);
                        // Testing Non XA DataSource ExampleDS */
                        testStandaloneModel.testNonXADataSource(client,"ExampleDS");
                        // Monitoring Application Statistics where application name is "Log4jDemo.war" */
                        testStandaloneModel.monitorApplicationStatistics(client,"Log4jDemo.war");
                     }
                  if(standaloneMode==false)
                    {
                        TestDomainModeModel testDomainModeModel= new TestDomainModeModel();
                        // Getting Web Subsystem runtime Details */
                        testDomainModeModel.getWebSubsystemRuntimeDetails(client,hostControllerName,serverName);
                        // Testing Non XA DataSource ExampleDS */
                        testDomainModeModel.testNonXADataSource(client,hostControllerName,serverName,"ExampleDS");
                        // Monitoring Application Statistics where application name is "Log4jDemo.war" */
                        testDomainModeModel.monitorApplicationStatistics(client,hostControllerName,serverName,"Log4jDemo.war");
                    }
      }

     static ModelControllerClient createClient (final InetAddress host, final int port, final String username, final char[] password, final String securityRealmName)
      {
         final CallbackHandler callbackHandler = new CallbackHandler() {
                 public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException
                   {
                       for (Callback current : callbacks) {
                          if (current instanceof NameCallback) {
                             NameCallback ncb = (NameCallback) current;
                             System.out.println("nttncb.setName() = "+new String(password));
                             ncb.setName(new String(password));
                            } else if (current instanceof PasswordCallback) {
                             PasswordCallback pcb = (PasswordCallback) current;
                             System.out.println("nttpcb.setPassword() = "+username);
                             pcb.setPassword(username.toCharArray());
                            } else if (current instanceof RealmCallback) {
                             RealmCallback rcb = (RealmCallback) current;
                             System.out.println("nttrcb.getDefaulttest() = "+rcb.getDefaultText());
                             rcb.setText(securityRealmName);
                            } else {
                             throw new UnsupportedCallbackException(current);
                        }
                    }
               }
             };
          return ModelControllerClient.Factory.create(host, port, callbackHandler);
       }
}

Step3). This step is for accessing JBoss informations in Standalone Mode, The most important part here we will write “TestStandaloneModel.java” program inside the “/home/jaysensharma/NativeManagement_API_JBossAS712/src” using the “org.jboss.dmr.ModelNode” and “ModelControllerClient” in order to access the “web” subsystem, deployment and “DataSource statistics” related informations as following:

import org.jboss.dmr.ModelNode;
import org.jboss.dmr.Property;
import org.jboss.as.controller.client.ModelControllerClient;

public class TestStandaloneModel
  {
   public void getWebSubsystemRuntimeDetails(ModelControllerClient client)
    {
       System.out.println("nnn************************************************");
       System.out.println("Web Subsystem Runtime Details");
       System.out.println("************************************************");
       try{
             ModelNode op = new ModelNode();
             op.get("operation").set("read-resource");
             ModelNode address = op.get("address");
             address.add("subsystem", "web");
             address.add("connector", "http");
             op.get("recursive").set(true);
             op.get("include-runtime").set(true);
             op.get("operations").set(true);

             ModelNode returnVal = client.execute(op);
             String result=returnVal.get("result").toString();
             String path="/subsystem=web/connector=http";
             if(result.equals("undefined"))
                {
                   System.out.println("ntCheck ["+path+"] ** Server may not be Running");
                }
             else
                {
                   System.out.println(returnVal.get("result").toString());
                }
          }
        catch(Exception e)
          {
             e.printStackTrace();
             System.out.println("getWebSubsystemRuntimeDetails Failed: "+e);
          }
    }


   public void testNonXADataSource(ModelControllerClient client,String dataSourceName)
    {
       System.out.println("nnn************************************************");
       System.out.println("DataSource ""+dataSourceName+"" TestResults");
       System.out.println("************************************************");

       try{
             ModelNode op = new ModelNode();
             op.get("operation").set("test-connection-in-pool");
             ModelNode address = op.get("address");
             address.add("subsystem", "datasources");
             address.add("data-source", dataSourceName);
             op.get("operations").set(true);

             ModelNode returnVal = client.execute(op);
             String result=returnVal.get("result").toString();
             String path="/subsystem=datasources/data-source="+dataSourceName;
             if(result.equals("[true]"))
                {
                   System.out.println("ntNon XA DataSource ""+dataSourceName+"" is RUNNING Successfully.");
                }
             else if(result.equals("[false]"))
                {
                   System.out.println("ntNon XA DataSource ""+dataSourceName+"" is TEST FAILED Successfully. Check PATH exist or not? ["+path+"]");
                }
             else if(result.equals("undefined"))
                {
                   System.out.println("ntDataSource ""+dataSourceName+"" might not be deployed, ["+path+"]  ** Server may not be Running"+"Please Check the DataSource ""+dataSourceName+"" name, It may be INCORRECT. ntCheck PATH exist or not? ["+path+"]");
                }
          }
        catch(Exception e)
          {
             e.printStackTrace();
             System.out.println("testNonXADataSource Failed: "+e);
          }
    }


   public void monitorApplicationStatistics(ModelControllerClient client,String applicationName)
    {
       System.out.println("nnn******************************************************");
       System.out.println("Application ""+applicationName+"" RuntimeStatistics");
       System.out.println("******************************************************");
       try{
             ModelNode op = new ModelNode();
             op.get("operation").set("read-resource");
             ModelNode address = op.get("address");
             address.add("deployment", applicationName);
             op.get("recursive").set(true);
             op.get("include-runtime").set(true);
             op.get("include-defaults").set(true);
             op.get("operations").set(true);

             ModelNode returnVal = client.execute(op);
             String result=returnVal.get("result").toString();
             String path="/deployment="+applicationName;
             if(result.equals("undefined"))
                {
                   System.out.println("ntApplication ""+applicationName+ "" might not have deployed. ** Server may not be Running. Check PATH exist or not? ["+path+"]");
                }
             else
                {
                   System.out.println("ntMonitoring ""+applicationName+ """+result);
                }
          }
        catch(Exception e)
          {
             e.printStackTrace();
             System.out.println("testNonXADataSource Failed: "+e);
          }
    }
  }

Step4). This step is for accessing JBoss informations of JBoss instances running in Domain Mode, The most important part here we will write “TestDomainModeModel.java” program inside the “/home/jaysensharma/NativeManagement_API_JBossAS712/src” using the “org.jboss.dmr.ModelNode” and “ModelControllerClient” in order to access the “web” subsystem, deployment and “DataSource statistics” related informations as following:

import org.jboss.dmr.ModelNode;
import org.jboss.dmr.Property;
import org.jboss.as.controller.client.ModelControllerClient;

public class TestDomainModeModel
  {
   public void getWebSubsystemRuntimeDetails(ModelControllerClient client,String hostControllerName,String serverName)
    {
       System.out.println("nnn************************************************");
       System.out.println("Web Subsystem Runtime Details");
       System.out.println("************************************************");
       try{
             ModelNode op = new ModelNode();
             op.get("operation").set("read-resource");
             ModelNode address = op.get("address");
             address.add("host", hostControllerName);
             address.add("server", serverName);
             address.add("subsystem", "web");
             address.add("connector", "http");
             op.get("recursive").set(true);
             op.get("include-runtime").set(true);
             op.get("operations").set(true);

             ModelNode returnVal = client.execute(op);
             String result=returnVal.get("result").toString();
             String path="/host="+hostControllerName+"/server="+serverName+"/subsystem=web/connector=http";
             if(result.equals("undefined"))
                {
                   System.out.println("ntCheck ["+path+"] ** HostController HostController or Server may not be Running");
                }
             else
                {
                   System.out.println(returnVal.get("result").toString());
                }
          }
        catch(Exception e)
          {
             e.printStackTrace();
             System.out.println("getWebSubsystemRuntimeDetails Failed: "+e);
          }
    }


   public void testNonXADataSource(ModelControllerClient client,String hostControllerName,String serverName,String dataSourceName)
    {
       System.out.println("nnn************************************************");
       System.out.println("DataSource ""+dataSourceName+"" TestResults");
       System.out.println("************************************************");

       try{
             ModelNode op = new ModelNode();
             op.get("operation").set("test-connection-in-pool");
             ModelNode address = op.get("address");
             address.add("host", hostControllerName);
             address.add("server", serverName);
             address.add("subsystem", "datasources");
             address.add("data-source", dataSourceName);
             op.get("operations").set(true);

             ModelNode returnVal = client.execute(op);
             String result=returnVal.get("result").toString();
             String path="/host="+hostControllerName+"/server="+serverName+"/subsystem=datasources/data-source="+dataSourceName;
             if(result.equals("[true]"))
                {
                   System.out.println("ntNon XA DataSource ""+dataSourceName+"" is RUNNING Successfully.");
                }
             else if(result.equals("[false]"))
                {
                   System.out.println("ntNon XA DataSource ""+dataSourceName+"" is TEST FAILED Successfully. Check PATH exist or not? ["+path+"]");
                }
             else if(result.equals("undefined"))
                {
                   System.out.println("ntDataSource ""+dataSourceName+"" might not be deployed on this ["+path+"]  ** HostController or Server may not be Running"+"Please Check the DataSource ""+dataSourceName+"" name, It may be INCORRECT. ntCheck PATH exist or not? ["+path+"]");
                }
          }
        catch(Exception e)
          {
             e.printStackTrace();
             System.out.println("testNonXADataSource Failed: "+e);
          }
    }


   public void monitorApplicationStatistics(ModelControllerClient client,String hostControllerName,String serverName,String applicationName)
    {
       System.out.println("nnn******************************************************");
       System.out.println("Application ""+applicationName+"" RuntimeStatistics");
       System.out.println("******************************************************");
       try{
             ModelNode op = new ModelNode();
             op.get("operation").set("read-resource");
             ModelNode address = op.get("address");
             address.add("host", hostControllerName);
             address.add("server", serverName);
             address.add("deployment", applicationName);
             op.get("recursive").set(true);
             op.get("include-runtime").set(true);
             op.get("include-defaults").set(true);
             op.get("operations").set(true);

             ModelNode returnVal = client.execute(op);
             String result=returnVal.get("result").toString();
             String path="/host="+hostControllerName+"/server="+serverName+"/deployment="+applicationName;
             if(result.equals("undefined"))
                {
                   System.out.println("ntApplication ""+applicationName+ "" might not have deployed on this host="+hostControllerName+"/server="+serverName+"  ** HostController or Server may not be Running. Check PATH exist or not? ["+path+"]");
                }
             else
                {
                   System.out.println("ntMonitoring ""+applicationName+ """+result);
                }
          }
        catch(Exception e)
          {
             e.printStackTrace();
             System.out.println("testNonXADataSource Failed: "+e);
          }
    }
  }

Step5). Now the most important part of building & running the Native Management API client which we created, so in order to achieve that we will create a simple ant build script, So Create a “build.xml” file inside the “/home/jaysensharma/NativeManagement_API_JBossAS712” directory as following:

<project name="JBossAS712NativeManagementClient" default="all">
<property name="jboss.home" value="/home/jaysensharma/jboss-as-7.1.2.Final" />
<property name="jboss.module.dir" value="${jboss.home}/modules" />
<property name="basedir" value="." />
<property name="tmp.dir" value="tmp" />
<property name="src.dir" value="src" />
<property name="output.dir" value="build" />
<property name="client.jar.name" value="jbossModelAPIClient.jar" />

        <!-- Following 5 Jars are needed for Client. Client Needs the following Jar to be present in the CLASSPATH including -->
        <path id="jboss.client.classpath">
           <fileset dir="${jboss.module.dir}/org/jboss/as/controller-client/main">
               <include name="jboss-as-controller-client*.jar"/>
           </fileset>
           <fileset dir="${jboss.module.dir}/org/jboss/threads/main">
               <include name="jboss-threads*.jar"/>
           </fileset>
           <fileset dir="${jboss.module.dir}/org/jboss/as/protocol/main">
               <include name="jboss-as-protocol*.jar"/>
           </fileset>

           <fileset dir="${jboss.module.dir}/org/jboss/dmr/main">
               <include name="jboss-dmr*.jar"/>
           </fileset>
           <fileset dir="${jboss.home}/bin/client" >
               <include name="jboss-client.jar" />
           </fileset>
        </path>

        <target name="all" depends="run" />

        <target name="run">
           <delete dir="${tmp.dir}" />
           <mkdir dir="${tmp.dir}" />
           <delete dir="${output.dir}" />
           <mkdir dir="${output.dir}" />
           <javac srcdir="${src.dir}" destdir="${tmp.dir}"  includes="NativeManagementClient.java,TestStandaloneModel.java,TestDomainModeModel.java" classpathref="jboss.client.classpath"/>
           <jar jarfile="${output.dir}/${client.jar.name}" basedir="${tmp.dir}" compress="true" />
           <delete dir="${tmp.dir}"/>
           <java classname="NativeManagementClient" fork="true">
               <classpath>
                  <pathelement location="${output.dir}/${client.jar.name}"/>
                  <path refid="jboss.client.classpath"/>
               </classpath>
           </java>
        </target>

</project>

NOTE: The only change in the above file you need to do is to change the “jboss.home” directory path in the second line of the above script to point to your own JBoss AS7 directory. It requires 5 Jars to be present in the Client’s classpath as mentioned in the above xml file.

Step-6). Now before running your ANT script to build and deploy the above webapplication you should have the ANT as well as JAVA set in the $PATH variable of the Shell / command prompt as following:

For Unix Based OS:
export PATH=/home/jaysensharma/jdk1.6.0_21/bin:/home/jaysensharma/org.apache.ant_1.6.5/bin:$PATH

For Windows Based OS:
set PATH=C:/jdk1.6.0_21/bin;C:/org.apache.ant_1.6.5/bin;%PATH%

Step-7). Now once the PATH is set In the command/Shell prompt you can move inside the directory “/home/jaysensharma/NativeManagement_API_JBossAS712” and then run the ant to build and deploy the EJB based EAR applicationon your JBoss Standalone full profile, by running the command “ant deploy”

[jsenshar@localhost NativeManagement_API_JBossAS712]$ ant
Buildfile: build.xml

run:
    [mkdir] Created dir: /home/jaysensharma/NativeManagement_API_JBossAS712/tmp
   [delete] Deleting directory /home/jaysensharma/NativeManagement_API_JBossAS712/build
    [mkdir] Created dir: /home/jaysensharma/NativeManagement_API_JBossAS712/build
    [javac] Compiling 3 source files to /home/jaysensharma/NativeManagement_API_JBossAS712/tmp
      [jar] Building jar: /home/jaysensharma/NativeManagement_API_JBossAS712/build/jbossModelAPIClient.jar
   [delete] Deleting directory /home/jaysensharma/NativeManagement_API_JBossAS712/tmp
      Got the client: org.jboss.as.controller.client.impl.RemotingModelControllerClient@7f971afc
      Nov 27, 2012 12:06:02 AM org.xnio.Xnio <clinit>
      INFO: XNIO Version 3.0.4.GA-redhat-1
      Nov 27, 2012 12:06:02 AM org.xnio.nio.NioXnio <clinit>
      INFO: XNIO NIO Implementation Version 3.0.4.GA-redhat-1
      Nov 27, 2012 12:06:02 AM org.jboss.remoting3.EndpointImpl <clinit>
      INFO: JBoss Remoting version 3.2.8.GA-redhat-1
     
     
      release-version: 7.1.2.Final-redhat-1
      release-codename: Steropes
     
     
     
      ************************************************
      Web Subsystem Runtime Details
      ************************************************
      {
          "bytesReceived" => "0",
          "bytesSent" => "0",
          "enable-lookups" => false,
          "enabled" => true,
          "errorCount" => "0",
          "executor" => undefined,
          "max-connections" => undefined,
          "max-post-size" => 2097152,
          "max-save-post-size" => 4096,
          "maxTime" => "0",
          "name" => "http",
          "processingTime" => "0",
          "protocol" => "HTTP/1.1",
          "proxy-name" => undefined,
          "proxy-port" => undefined,
          "redirect-port" => 8433,
          "requestCount" => "0",
          "scheme" => "http",
          "secure" => false,
          "socket-binding" => "http",
          "ssl" => undefined,
          "virtual-server" => undefined
      }
     
     
     
      ************************************************
      DataSource "ExampleDS" TestResults
      ************************************************
     
      	Non XA DataSource "ExampleDS" is RUNNING Successfully.
     
     
     
      ******************************************************
      Application "Log4jDemo.war" RuntimeStatistics
      ******************************************************
     
      	Monitoring "Log4jDemo.war"{
          "content" => [{
              "path" => "deployments/Log4jDemo.war",
              "relative-to" => "jboss.server.base.dir",
              "archive" => true
          }],
          "enabled" => true,
          "name" => "Log4jDemo.war",
          "persistent" => false,
          "runtime-name" => "Log4jDemo.war",
          "status" => "OK",
          "subdeployment" => undefined,
          "subsystem" => {"web" => {
              "active-sessions" => 0,
              "context-root" => "/Log4jDemo",
              "duplicated-session-ids" => 0,
              "expired-sessions" => 0,
              "max-active-sessions" => 0,
              "rejected-sessions" => 0,
              "session-avg-alive-time" => 0,
              "session-max-alive-time" => 0,
              "sessions-created" => 0,
              "virtual-host" => "default-host",
              "servlet" => {"servlets.TestServlet" => {
                  "load-time" => 0L,
                  "maxTime" => 9223372036854775807L,
                  "min-time" => 0L,
                  "processingTime" => 0L,
                  "requestCount" => 0,
                  "servlet-class" => "servlets.TestServlet",
                  "servlet-name" => "servlets.TestServlet"
              }}
          }}
      }

all:

BUILD SUCCESSFUL
Total time: 2 seconds

Step-8). If you are running your JBoss in Domain mode then you need to just edit the “NativeManagementClient.java” file, and just change the variable “standaloneMode” value to “false” as following:

static boolean standaloneMode=false;

.
.
Thanks
MiddlewareMagic Team 🙂


Curl Based Management & Monitoring in JBossAS7 with HTTP-JSON APIs

Trust me None other Application Server provides this kind of amazing feature, except JBossAS7. JBoss AS7 is one of the bestest application available in the Middleware World, As it provides much more facilities to the Administrators in order to manage/configure and monitor various resources. As we are already familier with a utility called as “$JBOSS_HOME/bin/jboss-cli.sh” is one of the most powerful and easiest utility which can be used to manage and monitor JBossAS7.

In this demonstration we will see that JBoss AS7 provides another best feature, which allows us to easily access & monitor & management the JBoss AS7 using OS level utilities like “curl”. Yes, JBoss AS7 provides HTTP-JSON based APIs which can be used to achieve the same. So lets see some of it’s features…

So lets start JBossAS7 like following:

    ./standalone.sh -c standalone-full.xml 

NOTE: In all the following operations we will assume that you have created a ManagementRealm User with username “admin” and password as “admin123” (you can create any user name/password based on your requirement), Then change the username & password in the mentioned demo URLs like “http://admin:admin123@localhost:9990/management/”

NOTE: Curl is a free utility for non-interactive download of files from the Web.

So Open a Terminal (command prompt) and start testing the following Curl command on your JBossAS7

Checking Server State

curl --digest -L -D - http://admin:admin123@localhost:9990/management --header "Content-Type: application/json" -d '{"operation":"read-attribute","name":"server-state","json.pretty":1}'


HTTP/1.1 401 Unauthorized
Content-length: 0
Www-authenticate: Digest realm="ManagementRealm",nonce="07d65fc8e028df9ed577145c8e973c64"
Date: Sun, 23 Sep 2012 15:18:59 GMT

HTTP/1.1 200 OK
Transfer-encoding: chunked
Content-type: application/json
Date: Sun, 23 Sep 2012 15:18:59 GMT

{
    "outcome" : "success",
    "result" : "running"
}


Editing “max-pool-size” attribute of ExampleDS DataSource

curl --digest -L -D - http://admin:admin123@localhost:9990/management/ -d '{"operation":"write-attribute","address":[{"subsystem":"datasources"},{"data-source":"ExampleDS"}],"name":"max-pool-size","value":10}' -HContent-Type:application/json



HTTP/1.1 401 Unauthorized
Content-length: 0
Www-authenticate: Digest realm="ManagementRealm",nonce="57d99ff484d2b950ecfde2bcd8c7b55c"
Date: Sun, 23 Sep 2012 15:27:32 GMT

HTTP/1.1 200 OK
Transfer-encoding: chunked
Content-type: application/json
Date: Sun, 23 Sep 2012 15:27:32 GMT

Editing “min-pool-size” attribute of ExampleDS DataSource

curl --digest -L -D - http://admin:admin123@localhost:9990/management/ -d '{"operation":"write-attribute","address":[{"subsystem":"datasources"},{"data-source":"ExampleDS"}],"name":"min-pool-size","value":5}' -HContent-Type:application/json



HTTP/1.1 401 Unauthorized
Content-length: 0
Www-authenticate: Digest realm="ManagementRealm",nonce="662bd288e4949b0093b8d1c5db704a6a"
Date: Sun, 23 Sep 2012 15:33:37 GMT

HTTP/1.1 200 OK
Transfer-encoding: chunked
Content-type: application/json
Date: Sun, 23 Sep 2012 15:33:37 GMT

Changing console-handler “CONSOLE” logging level to “WARN”


curl --digest -L -D - http://admin:admin123@localhost:9990/management/ -d '{"operation":"write-attribute","address":[{"subsystem":"logging"},{"console-handler":"CONSOLE"}],"name":"level","value":"WARN", "json.pretty":1}' -HContent-Type:application/json


HTTP/1.1 401 Unauthorized
Content-length: 0
Www-authenticate: Digest realm="ManagementRealm",nonce="8ad3a0fd0b5f393c8cf9ac757d8395d3"
Date: Sun, 23 Sep 2012 20:00:07 GMT

HTTP/1.1 200 OK
Transfer-encoding: chunked
Content-type: application/json
Date: Sun, 23 Sep 2012 20:00:07 GMT

{"outcome" : "success"}

Testing ExampleDS datasource connections

curl --digest -L -D - http://admin:admin123@localhost:9990/management/ -d '{"operation":"test-connection-in-pool","address":[{"subsystem":"datasources"},{"data-source":"ExampleDS"}]}' -HContent-Type:application/json


HTTP/1.1 401 Unauthorized
Content-length: 0
Www-authenticate: Digest realm="ManagementRealm",nonce="2feecad0028c0122ed04c2bf344fdde3"
Date: Sun, 23 Sep 2012 16:47:29 GMT

HTTP/1.1 200 OK
Transfer-encoding: chunked
Content-type: application/json
Date: Sun, 23 Sep 2012 16:47:30 GMT

{"outcome" : "success", "result" : [true]}

Getting JVM Memory & Runtime Details

curl --digest -D - http://admin:admin123@localhost:9990/management/ -d '{"operation":"read-resource", "include-runtime":"true", "address":[{"core-service":"platform-mbean"},{"type":"memory"}], "json.pretty":1}' -HContent-Type:application/json


HTTP/1.1 401 Unauthorized
Content-length: 0
Www-authenticate: Digest realm="ManagementRealm",nonce="86d37639bcc651b1cea47a91bef0be14"
Date: Sun, 23 Sep 2012 19:44:19 GMT

HTTP/1.1 200 OK
Transfer-encoding: chunked
Content-type: application/json
Date: Sun, 23 Sep 2012 19:44:19 GMT

{
    "outcome" : "success",
    "result" : {
        "heap-memory-usage" : {
            "init" : 1366294528,
            "used" : 161655864,
            "committed" : 1324351488,
            "max" : 1324351488
        },
        "non-heap-memory-usage" : {
            "init" : 24313856,
            "used" : 61050320,
            "committed" : 61210624,
            "max" : 318767104
        },
        "object-name" : "java.lang:type=Memory",
        "object-pending-finalization-count" : 0,
        "verbose" : false
    }
}

Getting JBoss Runtime Details

curl --digest -D - http://admin:admin123@localhost:9990/management/ -d '{"operation":"read-resource", "include-rutime":"true", "address":[{"core-service":"platform-mbean"},{"type":"runtime"}], "json.pretty":1}' -HContent-Type:application/json


HTTP/1.1 401 Unauthorized
Content-length: 0
Www-authenticate: Digest realm="ManagementRealm",nonce="b2d05e49490da200cdd74bd7f848998e"
Date: Sun, 23 Sep 2012 19:45:22 GMT

HTTP/1.1 200 OK
Transfer-encoding: chunked
Content-type: application/json
Date: Sun, 23 Sep 2012 19:45:22 GMT

{
    "outcome" : "success",
    "result" : {
        "name" : "24028@localhost.localdomain",
        "vm-name" : "Java HotSpot(TM) 64-Bit Server VM",
        "vm-vendor" : "Oracle Corporation",
        "vm-version" : "23.1-b03",
        "spec-name" : "Java Virtual Machine Specification",
        "spec-vendor" : "Oracle Corporation",
        "spec-version" : "1.7",
        "management-spec-version" : "1.2",
        "class-path" : "/home/userone/jboss-as-7.1.2/jboss-modules.jar",
        "library-path" : "/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib",
        "boot-class-path-supported" : true,
        "boot-class-path" : "/home/userone/jdk1.7.0_05/jre/lib/resources.jar:/home/userone/jdk1.7.0_05/jre/lib/rt.jar:/home/userone/jdk1.7.0_05/jre/lib/sunrsasign.jar:/home/userone/jdk1.7.0_05/jre/lib/jsse.jar:/home/userone/jdk1.7.0_05/jre/lib/jce.jar:/home/userone/jdk1.7.0_05/jre/lib/charsets.jar:/home/userone/jdk1.7.0_05/jre/lib/jfr.jar:/home/userone/jdk1.7.0_05/jre/classes",
        "input-arguments" : [
            "-D[Standalone]",
            "-XX:+UseCompressedOops",
            "-Xms1303m",
            "-Xmx1303m",
            "-XX:MaxPermSize=256m",
            "-Djava.net.preferIPv4Stack=true",
            "-Dorg.jboss.resolver.warning=true",
            "-Dsun.rmi.dgc.client.gcInterval=3600000",
            "-Dsun.rmi.dgc.server.gcInterval=3600000",
            "-Djboss.modules.system.pkgs=org.jboss.byteman",
            "-Djava.awt.headless=true",
            "-Djboss.server.default.config=standalone.xml",
            "-Dorg.jboss.boot.log.file=/home/userone/jboss-as-7.1.2/standalone/log/boot.log",
            "-Dlogging.configuration=file:/home/userone/jboss-as-7.1.2/standalone/configuration/logging.properties"
        ],
        "start-time" : 1348315286154,
        "system-properties" : {
            "[Standalone]" : "",
            "awt.toolkit" : "sun.awt.X11.XToolkit",
            "catalina.home" : "/home/userone/jboss-as-7.1.2/standalone/tmp",
            "ddddd" : "eeeee",
            "file.encoding" : "UTF-8",
            "file.encoding.pkg" : "sun.io",
            "file.separator" : "/",
            "java.awt.graphicsenv" : "sun.awt.X11GraphicsEnvironment",
            "java.awt.headless" : "true",
            "java.awt.printerjob" : "sun.print.PSPrinterJob",
            "java.class.path" : "/home/userone/jboss-as-7.1.2/jboss-modules.jar",
            "java.class.version" : "51.0",
            "java.endorsed.dirs" : "/home/userone/jdk1.7.0_05/jre/lib/endorsed",
            "java.ext.dirs" : "/home/userone/jdk1.7.0_05/jre/lib/ext:/usr/java/packages/lib/ext",
            "java.home" : "/home/userone/jdk1.7.0_05/jre",
            "java.io.tmpdir" : "/tmp",
            "java.library.path" : "/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib",
            "java.naming.factory.url.pkgs" : "org.jboss.as.naming.interfaces:org.jboss.ejb.client.naming",
            "java.net.preferIPv4Stack" : "true",
            "java.protocol.handler.pkgs" : "org.jboss.net.protocol|org.jboss.vfs.protocol",
            "java.runtime.name" : "Java(TM) SE Runtime Environment",
            "java.runtime.version" : "1.7.0_05-b05",
            "java.specification.name" : "Java Platform API Specification",
            "java.specification.vendor" : "Oracle Corporation",
            "java.specification.version" : "1.7",
            "java.util.logging.manager" : "org.jboss.logmanager.LogManager",
            "java.vendor" : "Oracle Corporation",
            "java.vendor.url" : "http://java.oracle.com/",
            "java.vendor.url.bug" : "http://bugreport.sun.com/bugreport/",
            "java.version" : "1.7.0_05",
            "java.vm.info" : "mixed mode",
            "java.vm.name" : "Java HotSpot(TM) 64-Bit Server VM",
            "java.vm.specification.name" : "Java Virtual Machine Specification",
            "java.vm.specification.vendor" : "Oracle Corporation",
            "java.vm.specification.version" : "1.7",
            "java.vm.vendor" : "Oracle Corporation",
            "java.vm.version" : "23.1-b03",
            "javax.management.builder.initial" : "org.jboss.as.jmx.PluggableMBeanServerBuilder",
            "javax.xml.datatype.DatatypeFactory" : "__redirected.__DatatypeFactory",
            "javax.xml.parsers.DocumentBuilderFactory" : "__redirected.__DocumentBuilderFactory",
            "javax.xml.parsers.SAXParserFactory" : "__redirected.__SAXParserFactory",
            "javax.xml.stream.XMLEventFactory" : "__redirected.__XMLEventFactory",
            "javax.xml.stream.XMLInputFactory" : "__redirected.__XMLInputFactory",
            "javax.xml.stream.XMLOutputFactory" : "__redirected.__XMLOutputFactory",
            "javax.xml.transform.TransformerFactory" : "__redirected.__TransformerFactory",
            "javax.xml.validation.SchemaFactory:http://www.w3.org/2001/XMLSchema" : "__redirected.__SchemaFactory",
            "javax.xml.xpath.XPathFactory:http://java.sun.com/jaxp/xpath/dom" : "__redirected.__XPathFactory",
            "jboss.home.dir" : "/home/userone/jboss-as-7.1.2",
            "jboss.host.name" : "localhost",
            "jboss.modules.dir" : "/home/userone/jboss-as-7.1.2/modules",
            "jboss.modules.system.pkgs" : "org.jboss.byteman",
            "jboss.node.name" : "localhost",
            "jboss.qualified.host.name" : "localhost.localdomain",
            "jboss.server.base.dir" : "/home/userone/jboss-as-7.1.2/standalone",
            "jboss.server.config.dir" : "/home/userone/jboss-as-7.1.2/standalone/configuration",
            "jboss.server.data.dir" : "/home/userone/jboss-as-7.1.2/standalone/data",
            "jboss.server.default.config" : "standalone.xml",
            "jboss.server.deploy.dir" : "/home/userone/jboss-as-7.1.2/standalone/data/content",
            "jboss.server.log.dir" : "/home/userone/jboss-as-7.1.2/standalone/log",
            "jboss.server.name" : "localhost",
            "jboss.server.temp.dir" : "/home/userone/jboss-as-7.1.2/standalone/tmp",
            "line.separator" : "n",
            "logging.configuration" : "file:/home/userone/jboss-as-7.1.2/standalone/configuration/logging.properties",
            "module.path" : "/home/userone/jboss-as-7.1.2/modules",
            "org.apache.coyote.http11.Http11Protocol.COMPRESSION" : "on",
            "org.apache.coyote.http11.Http11Protocol.COMPRESSION_MIME_TYPES" : "text/javascript,text/css,text/html",
            "org.apache.coyote.http11.Http11Protocol.COMPRESSION_MIN_SIZE" : "5",
            "org.jboss.as.logging.per-deployment" : "false",
            "org.jboss.boot.log.file" : "/home/userone/jboss-as-7.1.2/standalone/log/boot.log",
            "org.jboss.com.sun.CORBA.ORBUseDynamicStub" : "true",
            "org.jboss.resolver.warning" : "true",
            "org.jboss.security.context.ThreadLocal" : "true",
            "org.omg.CORBA.ORBClass" : "org.jacorb.orb.ORB",
            "org.omg.CORBA.ORBSingletonClass" : "org.jacorb.orb.ORBSingleton",
            "org.osgi.vendor.framework" : "org.jboss.osgi.framework",
            "org.xml.sax.driver" : "__redirected.__XMLReaderFactory",
            "os.arch" : "amd64",
            "os.name" : "Linux",
            "os.version" : "3.4.9-2.fc16.x86_64",
            "path.separator" : ":",
            "sun.arch.data.model" : "64",
            "sun.boot.class.path" : "/home/userone/jdk1.7.0_05/jre/lib/resources.jar:/home/userone/jdk1.7.0_05/jre/lib/rt.jar:/home/userone/jdk1.7.0_05/jre/lib/sunrsasign.jar:/home/userone/jdk1.7.0_05/jre/lib/jsse.jar:/home/userone/jdk1.7.0_05/jre/lib/jce.jar:/home/userone/jdk1.7.0_05/jre/lib/charsets.jar:/home/userone/jdk1.7.0_05/jre/lib/jfr.jar:/home/userone/jdk1.7.0_05/jre/classes",
            "sun.boot.library.path" : "/home/userone/jdk1.7.0_05/jre/lib/amd64",
            "sun.cpu.endian" : "little",
            "sun.cpu.isalist" : "",
            "sun.desktop" : "gnome",
            "sun.io.unicode.encoding" : "UnicodeLittle",
            "sun.java.command" : "/home/userone/jboss-as-7.1.2/jboss-modules.jar -mp /home/userone/jboss-as-7.1.2/modules -jaxpmodule javax.xml.jaxp-provider org.jboss.as.standalone -Djboss.home.dir=/home/userone/jboss-as-7.1.2 -Djboss.server.base.dir=/home/userone/jboss-as-7.1.2/standalone -c standalone-full.xml -Dorg.jboss.as.logging.per-deployment=false",
            "sun.java.launcher" : "SUN_STANDARD",
            "sun.jnu.encoding" : "UTF-8",
            "sun.management.compiler" : "HotSpot 64-Bit Tiered Compilers",
            "sun.os.patch.level" : "unknown",
            "sun.rmi.dgc.client.gcInterval" : "3600000",
            "sun.rmi.dgc.server.gcInterval" : "3600000",
            "user.country" : "US",
            "user.dir" : "/home/userone/jboss-as-7.1.2/bin",
            "user.home" : "/home/jsenshar",
            "user.language" : "en",
            "user.name" : "jsenshar",
            "user.timezone" : "Asia/Calcutta"
        },
        "uptime" : 114236761,
        "object-name" : "java.lang:type=Runtime"
    }
}

Getting Server Environment Details

curl --digest -D - http://admin:admin123@localhost:9990/management/ -d '{"operation":"read-resource", "include-runtime":"true", "address":[{"core-service":"server-environment"}], "json.pretty":1}' -HContent-Type:application/json


HTTP/1.1 401 Unauthorized
Content-length: 0
Www-authenticate: Digest realm="ManagementRealm",nonce="39385b83b7b9b2abbd722a3bdb4d7173"
Date: Sun, 23 Sep 2012 19:47:56 GMT

HTTP/1.1 200 OK
Transfer-encoding: chunked
Content-type: application/json
Date: Sun, 23 Sep 2012 19:47:56 GMT

{
    "outcome" : "success",
    "result" : {
        "base-dir" : "/home/userone/jboss-as-7.1.2/standalone",
        "config-dir" : "/home/userone/jboss-as-7.1.2/standalone/configuration",
        "config-file" : "/home/userone/jboss-as-7.1.2/standalone/configuration/standalone-full.xml",
        "content-dir" : "/home/userone/jboss-as-7.1.2/standalone/data/content",
        "data-dir" : "/home/userone/jboss-as-7.1.2/standalone/data",
        "deploy-dir" : "/home/userone/jboss-as-7.1.2/standalone/data/content",
        "ext-dirs" : [
            "/home/userone/jdk1.7.0_05/jre/lib/ext",
            "/usr/java/packages/lib/ext"
        ],
        "home-dir" : "/home/userone/jboss-as-7.1.2",
        "host-name" : "localhost",
        "initial-running-mode" : "NORMAL",
        "launch-type" : "STANDALONE",
        "log-dir" : "/home/userone/jboss-as-7.1.2/standalone/log",
        "modules-dir" : "/home/userone/jboss-as-7.1.2/modules",
        "node-name" : "localhost",
        "qualified-host-name" : "localhost.localdomain",
        "server-name" : "localhost",
        "temp-dir" : "/home/userone/jboss-as-7.1.2/standalone/tmp"
    }
}

Getting Runtime Statistics of Http Connector of web subsystem

curl --digest -D - http://admin:admin123@localhost:9990/management/ -d '{"operation":"read-resource", "include-runtime":"true", "address":[{"subsystem":"web"},{"connector":"http"}], "json.pretty":1}' -HContent-Type:application/json


HTTP/1.1 401 Unauthorized
Content-length: 0
Www-authenticate: Digest realm="ManagementRealm",nonce="37b5ee0cb0dde6f3963e7660a4439862"
Date: Sun, 23 Sep 2012 19:51:16 GMT

HTTP/1.1 200 OK
Transfer-encoding: chunked
Content-type: application/json
Date: Sun, 23 Sep 2012 19:51:16 GMT

{
    "outcome" : "success",
    "result" : {
        "bytesReceived" : "0",
        "bytesSent" : "0",
        "enable-lookups" : false,
        "enabled" : true,
        "errorCount" : "0",
        "executor" : null,
        "max-connections" : 20,
        "max-post-size" : 2097152,
        "max-save-post-size" : 4096,
        "maxTime" : "0",
        "name" : "http",
        "processingTime" : "0",
        "protocol" : "HTTP/1.1",
        "proxy-name" : null,
        "proxy-port" : null,
        "redirect-port" : 8433,
        "requestCount" : "0",
        "scheme" : "http",
        "secure" : false,
        "socket-binding" : "http",
        "ssl" : null,
        "virtual-server" : null
    }
}

Shutting down JBoss Standalone Server

curl --digest -D - http://admin:admin123@localhost:9990/management/ -d '{"operation":"shutdown" , "json.pretty":1}' -HContent-Type:application/json


HTTP/1.1 401 Unauthorized
Content-length: 0
Www-authenticate: Digest realm="ManagementRealm",nonce="dd74ab565fbf5345ebb015cbd337ffea"
Date: Sun, 23 Sep 2012 20:08:02 GMT

HTTP/1.1 200 OK
Transfer-encoding: chunked
Content-type: application/json
Date: Sun, 23 Sep 2012 20:08:02 GMT

{"outcome" : "success"}

Getting Application “TestLogging.ear” Details

curl --digest -D - http://admin:admin123@localhost:9990/management --header "Content-Type: application/json" -d '{"operation":"read-resource", "address":["deployment","TestLogging.ear"], "json.pretty":1}' 


HTTP/1.1 401 Unauthorized
Content-length: 0
Www-authenticate: Digest realm="ManagementRealm",nonce="486aa728c5bd526ab1bf1b96941252e2"
Date: Sat, 22 Sep 2012 11:07:38 GMT

HTTP/1.1 200 OK
Transfer-encoding: chunked
Content-type: application/json
Date: Sat, 22 Sep 2012 11:07:38 GMT

{
    "outcome" : "success",
    "result" : {
        "content" : [{
            "path" : "deployments/TestLogging.ear",
            "relative-to" : "jboss.server.base.dir",
            "archive" : false
        }],
        "enabled" : true,
        "name" : "TestLogging.ear",
        "persistent" : false,
        "runtime-name" : "TestLogging.ear",
        "subsystem" : null,
        "subdeployment" : {
            "Log4jDemoOne.war" : null,
            "Log4jDemoTwo.war" : null
        }
    }
}

Getting Runtime Statistics of “Test_EAR.ear” application (session/request monitoring)

curl --digest -D - http://admin:admin123@localhost:9990/management --header "Content-Type: application/json" -d '{"operation":"read-resource","recursive":"true", "include-runtime":"true", "address":["deployment","Test_EAR.ear"], "json.pretty":1}'


HTTP/1.1 401 Unauthorized
Content-length: 0
Www-authenticate: Digest realm="ManagementRealm",nonce="80f9f113cda3ea0430c0a1474ac9b736"
Date: Sun, 23 Sep 2012 20:20:29 GMT

HTTP/1.1 200 OK
Transfer-encoding: chunked
Content-type: application/json
Date: Sun, 23 Sep 2012 20:20:29 GMT

{
    "outcome" : "success",
    "result" : {
        "content" : [{"hash" : {
            "BYTES_VALUE" : "mSLytFVBop/W+VqanbNUztt7DRY="
        }}],
        "enabled" : true,
        "name" : "Test_EAR.ear",
        "persistent" : true,
        "runtime-name" : "test_trn.ear",
        "status" : "no metrics available",
        "subsystem" : null,
        "subdeployment" : {"Test_WAR.war" : {"subsystem" : {"web" : {
            "active-sessions" : 1,
            "context-root" : "/Test_WAR",
            "duplicated-session-ids" : 0,
            "expired-sessions" : 0,
            "max-active-sessions" : 1,
            "rejected-sessions" : 0,
            "servlet" : null,
            "session-avg-alive-time" : 0,
            "session-max-alive-time" : 0,
            "sessions-created" : 1,
            "virtual-host" : "default-host"
        }}}}
    }
}

Getting JNDI view details (list Jndi) / (jndi-view)

curl --digest -D - http://admin:admin123@localhost:9990/management --header "Content-Type: application/json" -d '{"operation":"jndi-view", "address":["subsystem","naming"], "json.pretty":1}'



HTTP/1.1 401 Unauthorized
Content-length: 0
Www-authenticate: Digest realm="ManagementRealm",nonce="e92a46c2e34810ed0084542cc59ca38f"
Date: Sat, 22 Sep 2012 11:13:29 GMT

HTTP/1.1 200 OK
Transfer-encoding: chunked
Content-type: application/json
Date: Sat, 22 Sep 2012 11:13:29 GMT

{
    "outcome" : "success",
    "result" : {
        "java: contexts" : {
            "java:" : {
                "ConnectionFactory" : {
                    "class-name" : "org.hornetq.jms.client.HornetQJMSConnectionFactory",
                    "value" : "HornetQConnectionFactory [serverLocator=ServerLocatorImpl [initialConnectors=[org-hornetq-core-remoting-impl-invm-InVMConnectorFactory?server-id=0], discoveryGroupConfiguration=null], clientID=null, dupsOKBatchSize=1048576, transactionBatchSize=1048576, readOnly=false]"
                },
                "JmsXA" : {
                    "class-name" : "org.hornetq.ra.HornetQRAConnectionFactoryImpl",
                    "value" : "org.hornetq.ra.HornetQRAConnectionFactoryImpl@59ffb3fa"
                },
                "TransactionManager" : {
                    "class-name" : "com.arjuna.ats.jbossatx.jta.TransactionManagerDelegate",
                    "value" : "com.arjuna.ats.jbossatx.jta.TransactionManagerDelegate@13190ef8"
                },
                "ejb" : {
                    "class-name" : "javax.naming.Context",
                    "children" : {"mgmt" : {
                        "class-name" : "javax.naming.Context",
                        "children" : null
                    }}
                },
                "jboss" : {
                    "class-name" : "javax.naming.Context",
                    "value" : "org.jboss.as.naming.WritableServiceBasedNamingStore@6ab0fa3b"
                }
            },
            "java:jboss" : {
                "ORB" : {
                    "class-name" : "org.jacorb.orb.ORB",
                    "value" : "org.jacorb.orb.ORB@274fb2cf"
                },
                "TransactionManager" : {
                    "class-name" : "com.arjuna.ats.jbossatx.jta.TransactionManagerDelegate",
                    "value" : "com.arjuna.ats.jbossatx.jta.TransactionManagerDelegate@13190ef8"
                },
                "TransactionSynchronizationRegistry" : {
                    "class-name" : "com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionSynchronizationRegistryImple",
                    "value" : "com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionSynchronizationRegistryImple@61644832"
                },
                "UserTransaction" : {
                    "class-name" : "org.jboss.tm.usertx.client.ServerVMClientUserTransaction",
                    "value" : "org.jboss.tm.usertx.client.ServerVMClientUserTransaction@5e6d855c"
                },
                "corbanaming" : {
                    "class-name" : "org.omg.CosNaming._NamingContextExtStub",
                    "value" : "IOR:000000000000002B49444C3A6F6D672E6F72672F436F734E616D696E672F4E616D696E67436F6E746578744578743A312E3000000000000100000000000000B0000102000000000A3132372E302E302E31000DC8000000114A426F73732F4E616D696E672F726F6F74000000000000040000000000000008000000004A4143000000000100000020000000000501000100000001000100010001010900000002050100010001010000000014000000080000001A00000DC90000002100000030000000000000000100000000000000220000000000000000000000000000000000000000000000000000000000000000"
                },
                "irpoa" : {
                    "class-name" : "org.jacorb.poa.POA",
                    "value" : "org.jacorb.poa.POA@7ebffc91"
                },
                "jaas" : {
                    "class-name" : "$Proxy13",
                    "children" : {
                        "jboss-ejb-policy" : {
                            "class-name" : "org.jboss.as.security.plugins.SecurityDomainContext",
                            "value" : "org.jboss.security.authentication.JBossCachedAuthenticationManager@7c1e7bee"
                        },
                        "other" : {
                            "class-name" : "org.jboss.as.security.plugins.SecurityDomainContext",
                            "value" : "org.jboss.security.authentication.JBossCachedAuthenticationManager@355a85eb"
                        },
                        "jboss-web-policy" : {
                            "class-name" : "org.jboss.as.security.plugins.SecurityDomainContext",
                            "value" : "org.jboss.security.authentication.JBossCachedAuthenticationManager@4a0e22aa"
                        }
                    }
                },
                "poa" : {
                    "class-name" : "org.jacorb.poa.POA",
                    "value" : "org.jacorb.poa.POA@6605ece1"
                },
                "mail" : {
                    "class-name" : "javax.naming.Context",
                    "children" : {"Default" : {
                        "class-name" : "javax.mail.Session",
                        "value" : "javax.mail.Session@3e475bbb"
                    }}
                },
                "datasources" : {
                    "class-name" : "javax.naming.Context",
                    "children" : {"ExampleDS" : {
                        "class-name" : "org.jboss.jca.adapters.jdbc.WrapperDataSource",
                        "value" : "org.jboss.jca.adapters.jdbc.WrapperDataSource@9b534aa"
                    }}
                },
                "exported" : {
                    "class-name" : "javax.naming.Context",
                    "value" : "org.jboss.as.naming.WritableServiceBasedNamingStore@579489e0"
                }
            },
            "java:global" : null
        },
        "applications" : {"TestLogging.ear" : {
            "java:app" : {
                "AppName" : {
                    "class-name" : "java.lang.String",
                    "value" : "TestLogging"
                },
                "env" : {
                    "class-name" : "org.jboss.as.naming.NamingContext",
                    "children" : null
                }
            },
            "modules" : null
        }}
    }
}


Dumping JBoss Services which are active

curl --digest -D - http://admin:admin123@localhost:9990/management --header "Content-Type: application/json" -d '{"operation":"dump-services", "address":["core-service","service-container"], "json.pretty":1}'

.
.
Thanks 🙂
MiddlewareMagic Team


Copyright © 2010-2012 Middleware Magic. All rights reserved. |