java - JMX: Read attribute from Server -


we're using adobe cq (5.5) cms. now, our cq environment consists of 1 author server, users can create content, , 2 publish servers serve content internet.

now there's replication agent pushs content author server both publish server. unfortunately articles block queue of replication agents, no more new content beeing published. not of problem, easy fix. real problem don't notice blockage until users start complain no more changes beeing published.

i searched around , found out cq provides jmx api monitoring applications attach it. tried find open source software allow me configure alerts, can react faster, couldn't find something.

this when decided try write own java application reads attribute , sends mail if attribute should true. guess more complicated tought.

first off, i'm not java developer, since cq based on java tought i'd give try. read documentation jmx , java , able working connection cq server. realize.

i able find out class com.adobe.granite.replication has type agent stores id every replication agent (the id name of replication agent, example id=replication-publish-1). every replication-agent has different attributes, attribute relevant me "queueblocked".

this code i've got far (it's based on this example):

public static void main(string[] args) {     try {         jmxserviceurl url = new jmxserviceurl("service:jmx:rmi:///jndi/rmi://servername:9010/jmxrmi");         jmxconnector jmxc = jmxconnectorfactory.connect(url, null);          clientlistener listener = new clientlistener();          mbeanserverconnection mbsc = jmxc.getmbeanserverconnection();          // outputs domains, 1 of them com.adobee.granite.replication, 1 need use         // why i'm sure @ least connection works, don't have com.adobe.granite.replication class on eclipse installation, output has come server         string domains[] = mbsc.getdomains();         (int = 0; < domains.length; i++) {             echo("\tdomain[" + + "] = " + domains[i]);         }          objectname replication = new objectname("com.adobe.granite.replication:type=agent,id=replication-publish-1");          mbsc.getattribute(replication, "queueblocked"); // throws error } catch(exception e) {  } 

}

the error thrown following:

javax.management.instancenotfoundexception: com.adobe.granite.replication:type=agent,id=replication-publish-1 

from understand should creating kind of instance, don't have idea instance , how create it. i'd appreciate can no matter if it's documentation or code snippet :)

solved :)

this code i'm using:

import java.io.ioexception; import java.util.iterator; import java.util.set; import javax.management.attribute; import javax.management.mbeanserverconnection; import javax.management.mbeanserverinvocationhandler; import javax.management.objectname; import javax.management.remote.jmxconnector; import javax.management.remote.jmxconnectorfactory; import javax.management.remote.jmxserviceurl;  public class client {      public static void main(string[] args) {         try {             jmxserviceurl url = new jmxserviceurl("service:jmx:rmi:///jndi/rmi://servername:9010/jmxrmi");             jmxconnector jmxc = jmxconnectorfactory.connect(url, null);              mbeanserverconnection mbsc = jmxc.getmbeanserverconnection();              objectname replication1 = new objectname("com.adobe.granite.replication:type=agent,id=\"replication-publish-1\"");             objectname replication2 = new objectname("com.adobe.granite.replication:type=agent,id=\"replication-publish-2\"");              string replication1status = mbsc.getattribute(replication1, "queuepaused").tostring();             string replication2status = mbsc.getattribute(replication2, "queuepaused").tostring();            } catch (exception e) {             e.printstacktrace();         }     } } 

Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -