You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2009/07/04 09:52:36 UTC
svn commit: r791077 - in /camel/trunk:
camel-core/src/main/java/org/apache/camel/
camel-core/src/main/java/org/apache/camel/processor/interceptor/
camel-core/src/test/java/org/apache/camel/processor/interceptor/
examples/camel-example-tracer/
Author: davsclaus
Date: Sat Jul 4 07:52:36 2009
New Revision: 791077
URL: http://svn.apache.org/viewvc?rev=791077&view=rev
Log:
CAMEL-1078: Removed last specialized Exchange the TraceEventExchange.
Removed:
camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/TraceEventExchange.java
Modified:
camel/trunk/camel-core/src/main/java/org/apache/camel/Exchange.java
camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/TraceInterceptor.java
camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/Tracer.java
camel/trunk/camel-core/src/test/java/org/apache/camel/processor/interceptor/TraceInterceptorDestinationTest.java
camel/trunk/examples/camel-example-tracer/pom.xml
Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/Exchange.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/Exchange.java?rev=791077&r1=791076&r2=791077&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/Exchange.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/Exchange.java Sat Jul 4 07:52:36 2009
@@ -85,10 +85,10 @@
String ON_COMPLETION = "CamelOnCompletion";
- String ROUTE_STOP = "CamelRouteStop";
-
+ String ROUTE_STOP = "CamelRouteStop";
String REDELIVERED = "CamelRedelivered";
String REDELIVERY_COUNTER = "CamelRedeliveryCounter";
+ String ROLLBACK_ONLY = "CamelRollbackOnly";
String SPLIT_INDEX = "CamelSplitIndex";
String SPLIT_SIZE = "CamelSplitSize";
@@ -98,8 +98,12 @@
String TIMER_PERIOD = "CamelTimerPeriod";
String TIMER_TIME = "CamelTimerTime";
- String TRANSACTED = "CamelTransacted";
- String ROLLBACK_ONLY = "CamelRollbackOnly";
+ String TRANSACTED = "CamelTransacted";
+
+ String TRACE_EVENT = "CamelTraceEvent";
+ String TRACE_EVENT_NODE_ID = "CamelTraceEventNodeId";
+ String TRACE_EVENT_TIMESTAMP = "CamelTraceEventTimestamp";
+ String TRACE_EVENT_EXCHANGE = "CamelTraceEventExchange";
/**
* Returns the {@link ExchangePattern} (MEP) of this exchange.
Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/TraceInterceptor.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/TraceInterceptor.java?rev=791077&r1=791076&r2=791077&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/TraceInterceptor.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/TraceInterceptor.java Sat Jul 4 07:52:36 2009
@@ -26,6 +26,7 @@
import org.apache.camel.Processor;
import org.apache.camel.Producer;
import org.apache.camel.impl.DefaultRouteNode;
+import org.apache.camel.impl.DefaultExchange;
import org.apache.camel.model.InterceptDefinition;
import org.apache.camel.model.OnCompletionDefinition;
import org.apache.camel.model.OnExceptionDefinition;
@@ -49,7 +50,6 @@
public class TraceInterceptor extends DelegateProcessor implements ExchangeFormatter {
private static final transient Log LOG = LogFactory.getLog(TraceInterceptor.class);
private static final String JPA_TRACE_EVENT_MESSAGE = "org.apache.camel.processor.interceptor.JpaTraceEventMessage";
- private static final String TRACE_EVENT = "CamelTraceEvent";
private Logger logger;
private Producer traceEventProducer;
private final ProcessorDefinition node;
@@ -93,7 +93,7 @@
public void process(final Exchange exchange) throws Exception {
// interceptor will also trace routes supposed only for TraceEvents so we need to skip
// logging TraceEvents to avoid infinite looping
- if (exchange instanceof TraceEventExchange || exchange.getProperty(TRACE_EVENT, Boolean.class) != null) {
+ if (exchange.getProperty(Exchange.TRACE_EVENT, Boolean.class) != null) {
// but we must still process to allow routing of TraceEvents to eg a JPA endpoint
super.process(exchange);
return;
@@ -285,14 +285,17 @@
protected void traceExchange(Exchange exchange) throws Exception {
// should we send a trace event to an optional destination?
if (tracer.getDestination() != null || tracer.getDestinationUri() != null) {
- // create event and add it as a property on the original exchange
- TraceEventExchange event = new TraceEventExchange(exchange);
+
+ // create event exchange and add event information
Date timestamp = new Date();
- event.setNodeId(node.getId());
- event.setTimestamp(timestamp);
- event.setTracedExchange(exchange);
+ Exchange event = new DefaultExchange(exchange);
+ event.setProperty(Exchange.TRACE_EVENT_NODE_ID, node.getId());
+ event.setProperty(Exchange.TRACE_EVENT_TIMESTAMP, timestamp);
+ // keep a reference to the original exchange in case its needed
+ event.setProperty(Exchange.TRACE_EVENT_EXCHANGE, exchange);
- // create event message to send in body
+ // create event message to sent as in body containing event information such as
+ // from node, to node, etc.
TraceEventMessage msg = new DefaultTraceEventMessage(timestamp, node, exchange);
// should we use ordinary or jpa objects
@@ -327,13 +330,13 @@
// marker property to indicate its a tracing event being routed in case
// new Exchange instances is created during trace routing so we can check
// for this marker when interceptor also kickins in during routing of trace events
- event.setProperty(TRACE_EVENT, Boolean.TRUE);
+ event.setProperty(Exchange.TRACE_EVENT, Boolean.TRUE);
try {
// process the trace route
getTraceEventProducer(exchange).process(event);
} catch (Exception e) {
// log and ignore this as the original Exchange should be allowed to continue
- LOG.error("Error processing TraceEventExchange (original Exchange will be continued): " + event, e);
+ LOG.error("Error processing trace event (original Exchange will continue): " + event, e);
}
}
}
Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/Tracer.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/Tracer.java?rev=791077&r1=791076&r2=791077&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/Tracer.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/Tracer.java Sat Jul 4 07:52:36 2009
@@ -175,7 +175,7 @@
}
/**
- * Sets an optional destination to send the traced Exchange wrapped in a {@link TraceEventExchange}.
+ * Sets an optional destination to send the traced Exchange.
* <p/>
* Can be used to store tracing as files, in a database or whatever. The routing of the Exchange
* will happen synchronously and the original route will first continue when this destination routing
Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/interceptor/TraceInterceptorDestinationTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/interceptor/TraceInterceptorDestinationTest.java?rev=791077&r1=791076&r2=791077&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/processor/interceptor/TraceInterceptorDestinationTest.java (original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/processor/interceptor/TraceInterceptorDestinationTest.java Sat Jul 4 07:52:36 2009
@@ -18,6 +18,7 @@
import java.util.ArrayList;
import java.util.List;
+import java.util.Date;
import org.apache.camel.ContextTestSupport;
import org.apache.camel.Exchange;
@@ -129,11 +130,10 @@
class MyTraveAssertProcessor implements Processor {
public void process(Exchange exchange) throws Exception {
- TraceEventExchange event = (TraceEventExchange) exchange;
- assertNotNull(event);
- assertEquals(event.getExchangeId(), exchange.getExchangeId());
- assertNotNull(event.getNodeId());
- assertNotNull(event.getTimestamp());
+ String nodeId = exchange.getProperty("CamelTraceEventNodeId", String.class);
+ Date timestamp = exchange.getProperty("CamelTraceEventTimestamp", Date.class);
+ assertNotNull(nodeId);
+ assertNotNull(timestamp);
// take a snapshot at current time for assertion later
// after mock assertions in unit test method
Modified: camel/trunk/examples/camel-example-tracer/pom.xml
URL: http://svn.apache.org/viewvc/camel/trunk/examples/camel-example-tracer/pom.xml?rev=791077&r1=791076&r2=791077&view=diff
==============================================================================
--- camel/trunk/examples/camel-example-tracer/pom.xml (original)
+++ camel/trunk/examples/camel-example-tracer/pom.xml Sat Jul 4 07:52:36 2009
@@ -69,14 +69,6 @@
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-jta_1.1_spec</artifactId>
</dependency>
- <dependency>
- <groupId>commons-dbcp</groupId>
- <artifactId>commons-dbcp</artifactId>
- </dependency>
- <dependency>
- <groupId>commons-collections</groupId>
- <artifactId>commons-collections</artifactId>
- </dependency>
<!-- testing -->
<dependency>