Skip to content

Commit

Permalink
Merge pull request #87 from assimbly/feature/issue-86/include-timeout…
Browse files Browse the repository at this point in the history
…-on-flowstats

Include timeout on flowStats
  • Loading branch information
skin27 committed Feb 8, 2023
2 parents 1d1dc84 + 6b09d8b commit 4bf56a5
Showing 1 changed file with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,13 @@
import org.springframework.core.type.filter.RegexPatternTypeFilter;
import org.w3c.dom.Document;

import javax.management.JMX;
import javax.management.MalformedObjectNameException;
import javax.management.ObjectName;
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathFactory;
import java.io.File;
import java.lang.management.ManagementFactory;
import java.lang.reflect.Method;
import java.nio.charset.Charset;
import java.nio.file.Files;
Expand Down Expand Up @@ -1626,14 +1630,13 @@ public String getFlowStats(String flowId, boolean fullStats, boolean includeStep
flow.put("failed",failedMessages);
flow.put("pending",pendingMessages);
if(fullStats){
flow.put("timeout",getTimeout(context));
flow.put("uptime",uptime);
flow.put("uptimeMillis",uptimeMillis);
flow.put("status",status);
flow.put("tracing",tracing);
flow.put("lastFailed",lastFailed);
flow.put("lastCompleted",lastCompleted);
flow.put("failed",failedMessages);
flow.put("pending",pendingMessages);
}
if(includeSteps){
flow.put("steps",steps);
Expand All @@ -1649,6 +1652,14 @@ public String getFlowStats(String flowId, boolean fullStats, boolean includeStep

}

private long getTimeout(CamelContext context) throws MalformedObjectNameException {
String managementName = context.getManagementNameStrategy().getName();
ObjectName objectName = context.getManagementStrategy().getManagementObjectNameStrategy().getObjectNameForCamelContext(managementName, context.getName());

ManagedCamelContextMBean managedCamelContextMBean = JMX.newMBeanProxy(ManagementFactory.getPlatformMBeanServer(), objectName, ManagedCamelContextMBean.class);
return managedCamelContextMBean.getTimeout();
}

/*
public String getFlowStats(String id, boolean fullStats, String mediaType) throws Exception {
Expand Down

0 comments on commit 4bf56a5

Please sign in to comment.