I get the count of stale workflows in the system by doing the below.
private int checkStaleItems() {
try {
MBeanServer server = ManagementFactory.getPlatformMBeanServer();
ObjectName workflowMBean = getWorkflowMBean(server);
Object staleWorkflowCount = server.invoke(workflowMBean, "countStaleWorkflows", new Object[]{null}, new String[]{String.class.getName()}); #step 1
int staleCount = (Integer) staleWorkflowCount;
log.info("The Stale Workflow count is: ", staleCount);
return staleCount;
}
catch(Exception exception) {
exception.printStackTrace();
}
return -1;
}
private static ObjectName getWorkflowMBean(MBeanServerConnection server) {
try {
Set<ObjectName> names = server.queryNames(new ObjectName("com.adobe.granite.workflow:type=Maintenance,*"), null); #step 2
if (names.isEmpty()) {
return null;
}
return names.iterator().next();
}
catch(Exception exception) {
exception.printStackTrace();
}
return null;
}
Likewise, I want to retrieve the queue count in a particular replication agent. So, using the same code as above, except modification at two places
i.e, at step 1 and step 2 above (wherein I am replacing with the below), I am trying to achieve this. But I am not getting.
#step 1 NOW : Object staleWorkflowCount = server.getAttribute(workflowMBean, "QueueNumEntries");
#step 2 NOW : Set<ObjectName> names = server.queryNames(new ObjectName("com.adobe.granite.replication:type=agent,*"), null);
I also need to pass "id" of the replication agent in "#step 2 NOW".
Some related links as below :
http://stackoverflow.com/questions/16081417/jmx-read-attribute-from-server
It would be helpful if someone could provide pointers/help on this.
Solved! Go to Solution.
Views
Replies
Total Likes
This has been covered in aem monitoring maintenance [1] and recording video demonstrating at [2]. You can look at sample ReplicationJMXSampleClient at [1].
[1] https://github.com/cqsupport/webinar-aem-monitoring-maintenance
Views
Replies
Total Likes
This has been covered in aem monitoring maintenance [1] and recording video demonstrating at [2]. You can look at sample ReplicationJMXSampleClient at [1].
[1] https://github.com/cqsupport/webinar-aem-monitoring-maintenance
Views
Replies
Total Likes
What's your error message? Any stack trace? Exception?
Jörg
Views
Replies
Total Likes
Hi Jorg & Sham,
Thanks a lot for your reply.
@Jorg - I was getting Long cannot be converted to integer exception.
I now have
ObjectName replication1 = new ObjectName("com.adobe.granite.replication:type=agent,id=\"flush\"");
Object staleWorkflowCount = server.getAttribute(workflowMBean, "QueueNumEntries");
in the placeholders I have mentioned above and it seems to be working fine. I am now able to monitor one agent.
Will see if I can modify this to monitor multiple agents and post back my results.
Views
Replies
Total Likes
Views
Likes
Replies