本文整理汇总了Java中org.apache.camel.processor.interceptor.Tracer类的典型用法代码示例。如果您正苦于以下问题:Java Tracer类的具体用法?Java Tracer怎么用?Java Tracer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Tracer类属于org.apache.camel.processor.interceptor包,在下文中一共展示了Tracer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: start
import org.apache.camel.processor.interceptor.Tracer; //导入依赖的package包/类
@Override
public void start() throws Exception {
ObjectHelper.notNull(camelContext, "CamelContext", this);
// register our event notifier
ServiceHelper.startService(debugEventNotifier);
camelContext.getManagementStrategy().addEventNotifier(debugEventNotifier);
if (isUseTracer()) {
Tracer tracer = Tracer.getTracer(camelContext);
if (tracer == null) {
// tracer is disabled so enable it silently so we can leverage it to trace the Exchanges for us
tracer = Tracer.createTracer(camelContext);
tracer.setLogLevel(LoggingLevel.OFF);
camelContext.addService(tracer);
camelContext.addInterceptStrategy(tracer);
}
// make sure tracer is enabled so the debugger can leverage the tracer for debugging purposes
tracer.setEnabled(true);
}
}
示例2: createRouteBuilder
import org.apache.camel.processor.interceptor.Tracer; //导入依赖的package包/类
protected RouteBuilder createRouteBuilder() throws Exception {
return new RouteBuilder() {
public void configure() throws Exception {
// START SNIPPET: tracingOutExchanges
Tracer tracer = new Tracer();
tracer.setTraceOutExchanges(true);
// we configure the default trace formatter where we can
// specify which fields we want in the output
DefaultTraceFormatter formatter = new DefaultTraceFormatter();
formatter.setShowOutBody(true);
formatter.setShowOutBodyType(true);
// set to use our formatter
tracer.setFormatter(formatter);
getContext().addInterceptStrategy(tracer);
// END SNIPPET: tracingOutExchanges
from("direct:start").
transform().body().
to("mock:a").
to("mock:b");
}
};
}
示例3: createRouteBuilder
import org.apache.camel.processor.interceptor.Tracer; //导入依赖的package包/类
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
return new RouteBuilder() {
@Override
public void configure() throws Exception {
Tracer tracer = new Tracer();
tracer.setDestinationUri("mock:trace");
context.addInterceptStrategy(tracer);
// START SNIPPET: e1
// define a global on completion that is invoked when the exchange is complete
onCompletion().to("log:global").to("mock:sync");
from("direct:start")
.process("myProcessor")
.to("mock:result");
// END SNIPPET: e1
}
};
}
示例4: createRouteBuilder
import org.apache.camel.processor.interceptor.Tracer; //导入依赖的package包/类
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
return new RouteBuilder() {
@Override
public void configure() throws Exception {
Tracer tracer = new Tracer();
tracer.setDestinationUri("mock:trace");
context.addInterceptStrategy(tracer);
intercept().to("mock:intercepted");
from("direct:start")
.to("mock:foo").to("mock:bar").to("mock:result");
}
};
}
示例5: createRouteBuilder
import org.apache.camel.processor.interceptor.Tracer; //导入依赖的package包/类
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
return new RouteBuilder() {
@Override
public void configure() throws Exception {
Tracer tracer = new Tracer();
tracer.setDestinationUri("mock:traced");
tracer.setLogName("foo");
context.addInterceptStrategy(tracer);
from("direct:a").to("mock:a");
from("direct:b").noTracing().to("mock:b");
from("direct:c").tracing().to("mock:c");
}
};
}
示例6: createRouteBuilder
import org.apache.camel.processor.interceptor.Tracer; //导入依赖的package包/类
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
return new RouteBuilder() {
@Override
public void configure() throws Exception {
Tracer tracer = new Tracer();
tracer.setDestinationUri("mock:traced");
tracer.setLogLevel(LoggingLevel.OFF);
context.addInterceptStrategy(tracer);
from("direct:start").to("log:foo").to("mock:result");
from("direct:foo").noTracing().to("mock:foo");
}
};
}
示例7: createRouteBuilder
import org.apache.camel.processor.interceptor.Tracer; //导入依赖的package包/类
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
return new RouteBuilder() {
@Override
public void configure() throws Exception {
Tracer tracer = new Tracer();
getContext().addInterceptStrategy(tracer);
from("file:target/split").routeId("foo").noAutoStartup()
.split(body().tokenize(comma))
.parallelProcessing()
.streaming()
.setProperty("split", new SimpleExpression("${property.CamelSplitIndex}"))
.split(body().tokenize(LS))
.parallelProcessing()
.streaming()
.setBody(body().append(":Status=OK").append(LS))
.to("file:target/split/outbox?fileExist=Append&fileName=result${property.split}.txt")
.end()
.setBody(new SimpleExpression("${property.split} complete"))
.to("file:target/split/outbox?fileExist=Append&fileName=result${property.split}.txt")
.end().to("mock:result");
}
};
}
示例8: createRouteBuilder
import org.apache.camel.processor.interceptor.Tracer; //导入依赖的package包/类
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
return new RouteBuilder() {
@Override
public void configure() throws Exception {
getContext().addInterceptStrategy(new Tracer());
from(getFtpUrl()).process(new Processor() {
public void process(Exchange exchange) throws Exception {
assertNotNull(exchange.getIn().getHeader(Exchange.FILE_NAME));
assertEquals("hello.txt", exchange.getIn().getHeader(Exchange.FILE_NAME_ONLY));
assertEquals("Hello World", exchange.getIn().getBody(String.class));
}
}).to("mock:result");
}
};
}
示例9: configure
import org.apache.camel.processor.interceptor.Tracer; //导入依赖的package包/类
public void configure() {
Tracer tracer = new Tracer();
tracer.setLogLevel(LoggingLevel.ERROR);
tracer.setLogName("org.apache.camel.bindy");
getContext().addInterceptStrategy(tracer);
// default should errors go to mock:error
errorHandler(deadLetterChannel(URI_MOCK_ERROR).redeliveryDelay(0));
onException(Exception.class).maximumRedeliveries(0).handled(true);
BindyDataFormat bindy = new BindyDataFormat();
bindy.setLocale("en");
bindy.setClassType(Order.class);
bindy.setType(BindyType.Fixed);
from(URI_DIRECT_START)
.marshal(bindy)
.to(URI_MOCK_RESULT);
}
示例10: route
import org.apache.camel.processor.interceptor.Tracer; //导入依赖的package包/类
@Bean
@Override
public RouteBuilder route() {
return new RouteBuilder() {
public void configure() {
Tracer tracer = new Tracer();
tracer.setLogLevel(LoggingLevel.ERROR);
tracer.setLogName("org.apache.camel.bindy");
getContext().addInterceptStrategy(tracer);
// default should errors go to mock:error
errorHandler(deadLetterChannel(URI_MOCK_ERROR).redeliveryDelay(0));
onException(Exception.class).maximumRedeliveries(0).handled(true);
BindyDataFormat bindy = new BindyDataFormat();
bindy.setLocale("en");
bindy.setClassType(Order.class);
bindy.setType(BindyType.Fixed);
from(URI_DIRECT_START)
.marshal(bindy)
.to(URI_MOCK_RESULT);
}
};
}
示例11: configure
import org.apache.camel.processor.interceptor.Tracer; //导入依赖的package包/类
public void configure() {
Tracer tracer = new Tracer();
tracer.setLogLevel(LoggingLevel.ERROR);
tracer.setLogName("org.apache.camel.bindy");
tracer.setLogStackTrace(true);
tracer.setTraceExceptions(true);
getContext().addInterceptStrategy(tracer);
// default should errors go to mock:error
errorHandler(deadLetterChannel(URI_MOCK_ERROR));
onException(IllegalArgumentException.class).maximumRedeliveries(0).handled(true);
from(URI_DIRECT_START).marshal(orderBindyDataFormat).to(URI_MOCK_RESULT);
}
示例12: configure
import org.apache.camel.processor.interceptor.Tracer; //导入依赖的package包/类
public void configure() {
BindyCsvDataFormat camelDataFormat =
new BindyCsvDataFormat(org.apache.camel.dataformat.bindy.model.simple.oneclass.Order.class);
camelDataFormat.setLocale("en");
Tracer tracer = new Tracer();
tracer.setLogLevel(LoggingLevel.ERROR);
tracer.setLogName("org.apache.camel.bindy");
getContext().addInterceptStrategy(tracer);
// default should errors go to mock:error
errorHandler(deadLetterChannel(URI_MOCK_ERROR).redeliveryDelay(0));
onException(Exception.class).maximumRedeliveries(0).handled(true);
from(URI_DIRECT_START).marshal(camelDataFormat).to(URI_MOCK_RESULT);
}
示例13: testTracerExceptionInOut
import org.apache.camel.processor.interceptor.Tracer; //导入依赖的package包/类
public void testTracerExceptionInOut() throws Exception {
MockEndpoint result = getMockEndpoint("mock:result");
((Tracer) context.getDefaultTracer()).setTraceOutExchanges(true);
result.expectedMessageCount(3);
prepareTestTracerExceptionInOut();
template.sendBody("direct:start", "Hello World");
template.sendBody("direct:start", "Bye World");
try {
template.sendBody("direct:start", "Kaboom");
fail("Should have thrown exception");
} catch (Exception e) {
// expected
}
template.sendBody("direct:start", "Hello Camel");
assertMockEndpointsSatisfied();
validateTestTracerExceptionInOut();
}
示例14: createContextWithGivenRoute
import org.apache.camel.processor.interceptor.Tracer; //导入依赖的package包/类
protected void createContextWithGivenRoute(RouteBuilder route, int timeWork) throws Exception, InterruptedException {
SimpleRegistry registry = new SimpleRegistry();
ModelCamelContext context = new DefaultCamelContext(registry);
Tracer tracer = new Tracer();
tracer.setLogName("MyTracerLog");
tracer.getDefaultTraceFormatter().setShowProperties(false);
tracer.getDefaultTraceFormatter().setShowHeaders(false);
tracer.getDefaultTraceFormatter().setShowBody(true);
context.addInterceptStrategy(tracer);
context.addRoutes(route);
context.addComponent("activeMq", activeMq);
this.camelContext = context;
this.ct = context.createConsumerTemplate();
this.pt = context.createProducerTemplate();
context.start();
context.setTracing(false);
Thread.sleep(timeWork);
context.stop();
}
示例15: configure
import org.apache.camel.processor.interceptor.Tracer; //导入依赖的package包/类
@Override
public void configure() throws Exception {
getContext().setTracing(true);
Tracer tracer = new Tracer();
tracer.setLogName("MyTracerLog");
tracer.getDefaultTraceFormatter().setShowProperties(true);
tracer.getDefaultTraceFormatter().setShowHeaders(false);
getContext().addInterceptStrategy(tracer);
from("direct:start")
.setBody(simple("Tracing ${body}"))
.to("mock:result");
}