Author: davsclaus
Date: Mon Jun 23 22:58:54 2008
New Revision: 671035
URL: http://svn.apache.org/viewvc?rev=671035&view=rev
Log:
CAMEL-627: Added JMX attributes for timestamp for failures. Enabled JMX
connector on the spring-jms tutorial. Polished javadoc.
Modified:
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/management/CamelNamingStrategy.java
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/management/InstrumentationErrorHandlerWrappingStrategy.java
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/management/InstrumentationInterceptStrategy.java
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/management/InstrumentationProcessor.java
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/management/PerformanceCounter.java
activemq/camel/trunk/examples/camel-example-spring-jms/src/main/resources/META-INF/spring/camel-server-aop.xml
activemq/camel/trunk/examples/camel-example-spring-jms/src/main/resources/META-INF/spring/camel-server.xml
activemq/camel/trunk/examples/camel-example-spring-jms/src/main/resources/camel-client-remoting.xml
activemq/camel/trunk/examples/camel-example-spring-jms/src/main/resources/camel-client.xml
Modified:
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/management/CamelNamingStrategy.java
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/management/CamelNamingStrategy.java?rev=671035&r1=671034&r2=671035&view=diff
==============================================================================
---
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/management/CamelNamingStrategy.java
(original)
+++
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/management/CamelNamingStrategy.java
Mon Jun 23 22:58:54 2008
@@ -84,10 +84,6 @@
* Implements the naming strategy for a [EMAIL PROTECTED] ManagedEndpoint}.
* The convention used for a [EMAIL PROTECTED] ManagedEndpoint} ObjectName
is:
*
<tt><domain>:context=<context-name>,type=endpoint,component=<component-name>name=<endpoint-name></tt>
- *
- * @param mbean
- * @return generated ObjectName
- * @throws MalformedObjectNameException
*/
public ObjectName getObjectName(ManagedEndpoint mbean) throws
MalformedObjectNameException {
Endpoint<? extends Exchange> ep = mbean.getEndpoint();
Modified:
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/management/InstrumentationErrorHandlerWrappingStrategy.java
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/management/InstrumentationErrorHandlerWrappingStrategy.java?rev=671035&r1=671034&r2=671035&view=diff
==============================================================================
---
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/management/InstrumentationErrorHandlerWrappingStrategy.java
(original)
+++
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/management/InstrumentationErrorHandlerWrappingStrategy.java
Mon Jun 23 22:58:54 2008
@@ -41,11 +41,9 @@
// don't wrap our instrumentation interceptors
if (counterMap.containsKey(processorType)) {
return
processorType.getErrorHandlerBuilder().createErrorHandler(target);
-
}
-
+
return target;
-
}
}
Modified:
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/management/InstrumentationInterceptStrategy.java
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/management/InstrumentationInterceptStrategy.java?rev=671035&r1=671034&r2=671035&view=diff
==============================================================================
---
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/management/InstrumentationInterceptStrategy.java
(original)
+++
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/management/InstrumentationInterceptStrategy.java
Mon Jun 23 22:58:54 2008
@@ -23,10 +23,11 @@
import org.apache.camel.spi.InterceptStrategy;
/**
- * This strategy class wraps targeted processors with
- * [EMAIL PROTECTED] InstrumentationProcessor}. Each InstrumentationProcessor
is
- * into embeds a [EMAIL PROTECTED] PerformanceCounter}. This class looks up a
map
- * to determine which PerformanceCounter should go into the
+ * This strategy class wraps targeted processors with a
+ * [EMAIL PROTECTED] InstrumentationProcessor}. Each InstrumentationProcessor
has an
+ * embedded [EMAIL PROTECTED] PerformanceCounter} for monitoring performance
metrics.
+ * <p/>
+ * This class looks up a map to determine which PerformanceCounter should go
into the
* InstrumentationProcessor for any particular target processor.
*
* @version $Revision$
Modified:
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/management/InstrumentationProcessor.java
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/management/InstrumentationProcessor.java?rev=671035&r1=671034&r2=671035&view=diff
==============================================================================
---
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/management/InstrumentationProcessor.java
(original)
+++
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/management/InstrumentationProcessor.java
Mon Jun 23 22:58:54 2008
@@ -21,16 +21,18 @@
import org.apache.camel.Exchange;
import org.apache.camel.processor.DelegateProcessor;
import org.apache.camel.util.AsyncProcessorHelper;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
/**
* JMX enabled processor that uses the [EMAIL PROTECTED] Counter} for
instrumenting
* processing of exchanges.
*
* @version $Revision$
- *
*/
public class InstrumentationProcessor extends DelegateProcessor implements
AsyncProcessor {
+ private static final transient Log LOG =
LogFactory.getLog(InstrumentationProcessor.class);
private PerformanceCounter counter;
public InstrumentationProcessor(PerformanceCounter counter) {
@@ -47,10 +49,10 @@
public void process(Exchange exchange) throws Exception {
AsyncProcessorHelper.process(this, exchange);
}
-
+
public boolean process(final Exchange exchange, final AsyncCallback
callback) {
final long startTime = System.nanoTime();
-
+
if (processor instanceof AsyncProcessor) {
return ((AsyncProcessor)processor).process(exchange, new
AsyncCallback() {
public void done(boolean doneSynchronously) {
@@ -61,8 +63,8 @@
callback.done(doneSynchronously);
}
});
- }
-
+ }
+
try {
processor.process(exchange);
} catch (Exception e) {
@@ -75,14 +77,18 @@
}
callback.done(true);
return true;
-
}
protected void recordTime(Exchange exchange, double duration) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Recording duration: " + duration + " millis for
exchange: " + exchange);
+ }
+
if (!exchange.isFailed() && exchange.getException() == null) {
counter.completedExchange(duration);
} else {
- counter.completedExchange();
+ counter.failedExchange();
}
}
+
}
Modified:
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/management/PerformanceCounter.java
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/management/PerformanceCounter.java?rev=671035&r1=671034&r2=671035&view=diff
==============================================================================
---
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/management/PerformanceCounter.java
(original)
+++
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/management/PerformanceCounter.java
Mon Jun 23 22:58:54 2008
@@ -31,7 +31,9 @@
private double maxProcessingTime;
private double totalProcessingTime;
private Date lastExchangeCompletionTime;
+ private Date lastExchangeFailureTime;
private Date firstExchangeCompletionTime;
+ private Date firstExchangeFailureTime;
@Override
@ManagedOperation(description = "Reset counters")
@@ -42,8 +44,9 @@
maxProcessingTime = 0.0;
totalProcessingTime = 0.0;
lastExchangeCompletionTime = null;
+ lastExchangeFailureTime = null;
firstExchangeCompletionTime = null;
-
+ firstExchangeFailureTime = null;
}
@ManagedAttribute(description = "Number of successful exchanges")
@@ -87,6 +90,16 @@
return firstExchangeCompletionTime;
}
+ @ManagedAttribute(description = "Last Exchange Failed Timestamp")
+ public synchronized Date getLastExchangeFailureTime() {
+ return lastExchangeFailureTime;
+ }
+
+ @ManagedAttribute(description = "First Exchange Failed Timestamp")
+ public synchronized Date getFirstExchangeFailureTime() {
+ return firstExchangeFailureTime;
+ }
+
/**
* This method is called when an exchange has been processed successfully.
*
@@ -95,6 +108,7 @@
public synchronized void completedExchange(double time) {
increment();
numCompleted.incrementAndGet();
+
totalProcessingTime += time;
if (minProcessingTime < 0 || time < minProcessingTime) {
minProcessingTime = time;
@@ -102,6 +116,7 @@
if (time > maxProcessingTime) {
maxProcessingTime = time;
}
+
Date timestamp = new Date();
if (firstExchangeCompletionTime == null) {
firstExchangeCompletionTime = timestamp;
@@ -109,7 +124,17 @@
lastExchangeCompletionTime = timestamp;
}
- public void completedExchange() {
- numExchanges.incrementAndGet();
+ /**
+ * This method is called when an exchange has been processed and failed.
+ */
+ public synchronized void failedExchange() {
+ increment();
+
+ Date timestamp = new Date();
+ if (firstExchangeFailureTime == null) {
+ firstExchangeFailureTime = timestamp;
+ }
+ lastExchangeFailureTime = timestamp;
}
+
}
Modified:
activemq/camel/trunk/examples/camel-example-spring-jms/src/main/resources/META-INF/spring/camel-server-aop.xml
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/examples/camel-example-spring-jms/src/main/resources/META-INF/spring/camel-server-aop.xml?rev=671035&r1=671034&r2=671035&view=diff
==============================================================================
---
activemq/camel/trunk/examples/camel-example-spring-jms/src/main/resources/META-INF/spring/camel-server-aop.xml
(original)
+++
activemq/camel/trunk/examples/camel-example-spring-jms/src/main/resources/META-INF/spring/camel-server-aop.xml
Mon Jun 23 22:58:54 2008
@@ -22,9 +22,9 @@
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:camel="http://activemq.apache.org/camel/schema/spring"
xsi:schemaLocation="
- http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
- http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
- http://activemq.apache.org/camel/schema/spring
http://activemq.apache.org/camel/schema/spring/camel-spring-1.3.0.xsd">
+ http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
+ http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
+ http://activemq.apache.org/camel/schema/spring
http://activemq.apache.org/camel/schema/spring/camel-spring.xsd">
<!-- END SNIPPET: e1 -->
<!-- START SNIPPET: e2 -->
Modified:
activemq/camel/trunk/examples/camel-example-spring-jms/src/main/resources/META-INF/spring/camel-server.xml
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/examples/camel-example-spring-jms/src/main/resources/META-INF/spring/camel-server.xml?rev=671035&r1=671034&r2=671035&view=diff
==============================================================================
---
activemq/camel/trunk/examples/camel-example-spring-jms/src/main/resources/META-INF/spring/camel-server.xml
(original)
+++
activemq/camel/trunk/examples/camel-example-spring-jms/src/main/resources/META-INF/spring/camel-server.xml
Mon Jun 23 22:58:54 2008
@@ -23,10 +23,10 @@
xmlns:camel="http://activemq.apache.org/camel/schema/spring"
xmlns:broker="http://activemq.apache.org/schema/core"
xsi:schemaLocation="
- http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
- http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd
- http://activemq.apache.org/camel/schema/spring
http://activemq.apache.org/camel/schema/spring/camel-spring-1.3.0.xsd
- http://activemq.apache.org/schema/core
http://activemq.apache.org/schema/core/activemq-core-5.1.0.xsd">
+ http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
+ http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd
+ http://activemq.apache.org/camel/schema/spring
http://activemq.apache.org/camel/schema/spring/camel-spring.xsd
+ http://activemq.apache.org/schema/core
http://activemq.apache.org/schema/core/activemq-core-5.1.0.xsd">
<!-- END SNIPPET: e1 -->
<!-- START SNIPPET: e2 -->
@@ -39,6 +39,9 @@
in the package org.apache.camel.example.server -->
<camel:camelContext id="camel">
<camel:package>org.apache.camel.example.server</camel:package>
+ <!-- enable JMX connector so we can connect to the server and browse
mbeans -->
+ <!-- Camel will log at INFO level the service URI to use for
connecting with jconsole -->
+ <camel:jmxAgent id="agent" createConnector="true"/>
</camel:camelContext>
<!-- END SNIPPET: e3 -->
Modified:
activemq/camel/trunk/examples/camel-example-spring-jms/src/main/resources/camel-client-remoting.xml
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/examples/camel-example-spring-jms/src/main/resources/camel-client-remoting.xml?rev=671035&r1=671034&r2=671035&view=diff
==============================================================================
---
activemq/camel/trunk/examples/camel-example-spring-jms/src/main/resources/camel-client-remoting.xml
(original)
+++
activemq/camel/trunk/examples/camel-example-spring-jms/src/main/resources/camel-client-remoting.xml
Mon Jun 23 22:58:54 2008
@@ -20,8 +20,8 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:camel="http://activemq.apache.org/camel/schema/spring"
xsi:schemaLocation="
- http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
- http://activemq.apache.org/camel/schema/spring
http://activemq.apache.org/camel/schema/spring/camel-spring-1.3.0.xsd">
+ http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
+ http://activemq.apache.org/camel/schema/spring
http://activemq.apache.org/camel/schema/spring/camel-spring.xsd">
<import resource="camel-client.xml"/>
Modified:
activemq/camel/trunk/examples/camel-example-spring-jms/src/main/resources/camel-client.xml
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/examples/camel-example-spring-jms/src/main/resources/camel-client.xml?rev=671035&r1=671034&r2=671035&view=diff
==============================================================================
---
activemq/camel/trunk/examples/camel-example-spring-jms/src/main/resources/camel-client.xml
(original)
+++
activemq/camel/trunk/examples/camel-example-spring-jms/src/main/resources/camel-client.xml
Mon Jun 23 22:58:54 2008
@@ -21,8 +21,8 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:camel="http://activemq.apache.org/camel/schema/spring"
xsi:schemaLocation="
- http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
- http://activemq.apache.org/camel/schema/spring
http://activemq.apache.org/camel/schema/spring/camel-spring-1.3.0.xsd">
+ http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
+ http://activemq.apache.org/camel/schema/spring
http://activemq.apache.org/camel/schema/spring/camel-spring.xsd">
<!-- END SNIPPET: e1 -->
<!-- START SNIPPET: e2 -->