Repository: camel Updated Branches: refs/heads/master b76a55f6e -> a5d3b7507
http://git-wip-us.apache.org/repos/asf/camel/blob/a5d3b750/camel-core/src/main/docs/language-component.adoc ---------------------------------------------------------------------- diff --git a/camel-core/src/main/docs/language-component.adoc b/camel-core/src/main/docs/language-component.adoc index 6150fe3..09f8446 100644 --- a/camel-core/src/main/docs/language-component.adoc +++ b/camel-core/src/main/docs/language-component.adoc @@ -18,19 +18,19 @@ link:groovy.html[Groovy] or link:javascript.html[JavaScript] languages. === URI format -[source,java] ------------------------------------------- +[source] +---- language://languageName[:script][?options] ------------------------------------------- +---- And from Camel 2.11 onwards you can refer to an external resource for the script using same notation as supported by the other link:language.html[Language]s in Camel -[source,java] ------------------------------------------------------------ +[source] +---- language://languageName:resource:scheme:location][?options] ------------------------------------------------------------ +---- === URI Options @@ -80,12 +80,12 @@ The following message headers can be used to affect the behavior of the component [width="100%",cols="10%,90%",options="header",] -|======================================================================= +|=== |Header |Description |`CamelLanguageScript` |The script to execute provided in the header. Takes precedence over script configured on the endpoint. -|======================================================================= +|=== === Examples @@ -103,10 +103,10 @@ link:xpath.html[XPath] language to extract the text from the `<foo>` tag. [source,java] --------------------------------------------------------------------------------------------------------------------------------- +---- Object out = producer.requestBodyAndHeader("language:xpath", "<foo>Hello World</foo>", Exchange.LANGUAGE_SCRIPT, "/foo/text()"); assertEquals("Hello World", out); --------------------------------------------------------------------------------------------------------------------------------- +---- === Loading scripts from resources @@ -129,13 +129,3 @@ From *Camel 2.11* onwards you can refer to the resource similar to the other link:language.html[Language]s in Camel by prefixing with `"resource:"` as shown below: -=== See Also - -* link:configuring-camel.html[Configuring Camel] -* link:component.html[Component] -* link:endpoint.html[Endpoint] -* link:getting-started.html[Getting Started] -* link:languages.html[Languages] -* link:routing-slip.html[Routing Slip] -* link:dynamic-router.html[Dynamic Router] -* link:script.html[Script] http://git-wip-us.apache.org/repos/asf/camel/blob/a5d3b750/camel-core/src/main/docs/log-component.adoc ---------------------------------------------------------------------- diff --git a/camel-core/src/main/docs/log-component.adoc b/camel-core/src/main/docs/log-component.adoc index 7edeb90..8d046e3 100644 --- a/camel-core/src/main/docs/log-component.adoc +++ b/camel-core/src/main/docs/log-component.adoc @@ -16,10 +16,10 @@ Util Logging logging] === URI format -[source,java] ------------------------------ +[source] +---- log:loggingCategory[?options] ------------------------------ +---- Where *loggingCategory* is the name of the logging category to use. You can append query options to the URI in the following format, @@ -37,10 +37,10 @@ using *loggingCategory*. For example, a log endpoint typically specifies the logging level using the `level` option, as follows: -[source,java] ----------------------------------------- +[source] +---- log:org.apache.camel.example?level=DEBUG ----------------------------------------- +---- The default logger logs every exchange (_regular logging_). But Camel also ships with the `Throughput` logger, which is used whenever the @@ -129,20 +129,20 @@ In the route below we log the incoming orders at `DEBUG` level before the order is processed: [source,java] ------------------------------------------------------------------------------------------- +---- from("activemq:orders").to("log:com.mycompany.order?level=DEBUG").to("bean:processOrder"); ------------------------------------------------------------------------------------------- +---- Or using Spring XML to define the route: [source,xml] ---------------------------------------------------- - <route> - <from uri="activemq:orders"/> - <to uri="log:com.mycompany.order?level=DEBUG"/> - <to uri="bean:processOrder"/> - </route> ---------------------------------------------------- +---- +<route> + <from uri="activemq:orders"/> + <to uri="log:com.mycompany.order?level=DEBUG"/> + <to uri="bean:processOrder"/> +</route> +---- === Regular logger with formatter sample @@ -150,10 +150,10 @@ In the route below we log the incoming orders at `INFO` level before the order is processed. [source,java] --------------------------------------------------------------------------------------- +---- from("activemq:orders"). to("log:com.mycompany.order?showAll=true&multiline=true").to("bean:processOrder"); --------------------------------------------------------------------------------------- +---- === Throughput logger with groupSize sample @@ -161,10 +161,10 @@ In the route below we log the throughput of the incoming orders at `DEBUG` level grouped by 10 messages. [source,java] ------------------------------------------------------------------------------------ +---- from("activemq:orders"). to("log:com.mycompany.order?level=DEBUG&groupSize=10").to("bean:processOrder"); ------------------------------------------------------------------------------------ +---- === Throughput logger with groupInterval sample @@ -173,17 +173,17 @@ initial 60s delay and stats should be displayed even if there isn't any message traffic. [source,java] ------------------------------------------------------------------------------------------------------------------------------ +---- from("activemq:orders"). -to("log:com.mycompany.order?level=DEBUG&groupInterval=10000&groupDelay=60000&groupActiveOnly=false").to("bean:processOrder"); ------------------------------------------------------------------------------------------------------------------------------ + to("log:com.mycompany.order?level=DEBUG&groupInterval=10000&groupDelay=60000&groupActiveOnly=false").to("bean:processOrder"); +---- The following will be logged: -[source,java] ------------------------------------------------------------------------------------------------------------------------------------- +[source] +---- "Received: 1000 new messages, with total 2000 so far. Last group took: 10000 millis which is: 100 messages per second. average: 100" ------------------------------------------------------------------------------------------------------------------------------------- +---- === Masking sensitive information like password *Available as of Camel 2.19* @@ -193,40 +193,37 @@ Note that this option also affects link:logeip.html[Log EIP]. To enable mask in Java DSL at CamelContext level: [source,java] --------------------------------------------------------- -CamelContext context = ... -context.setLogMask(true); --------------------------------------------------------- +---- +camelContext.setLogMask(true); +---- And in XML: -[source,java] --------------------------------------------------------- +[source,xml] +---- <camelContext logMask="true"> -... --------------------------------------------------------- - +---- You can also turn it on|off at endpoint level. To enable mask in Java DSL at endpoint level, add logMask=true option in the URI for the log endpoint: + [source,java] --------------------------------------------------------- +---- from("direct:start").to("log:foo?logMask=true"); --------------------------------------------------------- +---- And in XML: -[source,java] --------------------------------------------------------- +[source,xml] +---- <route> <from uri="direct:foo"/> <to uri="log:foo?logMask=true"/> -... --------------------------------------------------------- +</route> +---- `org.apache.camel.processor.DefaultMaskingFormatter` is used for the masking by default. If you want to use a custom masking formatter, put it into registry with the name `CamelCustomLogMask`. Note that the masking formatter must implement `org.apache.camel.spi.MaskingFormatter`. - === Full customization of the logging output *Available as of Camel 2.11* @@ -235,13 +232,13 @@ With the options outlined in the link:log.html[#Formatting] section, you can control much of the output of the logger. However, log lines will always follow this structure: -[source,java] --------------------------------------------------------------------------------------------------------------- +[source] +---- Exchange[Id:ID-machine-local-50656-1234567901234-1-2, ExchangePattern:InOut, Properties:{CamelToEndpoint=log://org.apache.camel.component.log.TEST?showAll=true, CamelCreatedTimestamp=Thu Mar 28 00:00:00 WET 2013}, Headers:{breadcrumbId=ID-machine-local-50656-1234567901234-1-1}, BodyType:String, Body:Hello World, Out: null] --------------------------------------------------------------------------------------------------------------- +---- This format is unsuitable in some cases, perhaps because you need to... @@ -267,21 +264,21 @@ in either of two ways: *Explicitly instantiating the LogComponent in your Registry:* [source,java] ---------------------------------------------------------------------- +---- <bean name="log" class="org.apache.camel.component.log.LogComponent"> <property name="exchangeFormatter" ref="myCustomFormatter" /> </bean> ---------------------------------------------------------------------- +---- -*Convention over configuration:* +#### Convention over configuration:* Simply by registering a bean with the name `logFormatter`; the Log Component is intelligent enough to pick it up automatically. -[source,java] ----------------------------------------------------------------------- +[source,xml] +----- <bean name="logFormatter" class="com.xyz.MyCustomExchangeFormatter" /> ----------------------------------------------------------------------- +----- NOTE: the `ExchangeFormatter` gets applied to *all Log endpoints within that Camel Context*. If you need different ExchangeFormatters for @@ -294,22 +291,22 @@ custom log formatter. Though when you do that you should define the "logFormatter" as prototype scoped so its not shared if you have different parameters, eg: -[source,java] ---------------------------------------------------------------------------------------- +[source,xml] +---- <bean name="logFormatter" class="com.xyz.MyCustomExchangeFormatter" scope="prototype"/> ---------------------------------------------------------------------------------------- +---- And then we can have Camel routes using the log uri with different options: -[source,java] +[source,xml] --------------------------------------------- <to uri="log:foo?param1=foo&param2=100"/> -... + <to uri="log:bar?param1=bar&param2=200"/> --------------------------------------------- -#=== Using Log component in OSGi +=== Using Log component in OSGi *Improvement as of Camel 2.12.4/2.13.1* @@ -327,11 +324,6 @@ reference it using `logger` URI parameter. === See Also -* link:configuring-camel.html[Configuring Camel] -* link:component.html[Component] -* link:endpoint.html[Endpoint] -* link:getting-started.html[Getting Started] - * link:tracer.html[Tracer] * link:how-do-i-use-log4j.html[How do I use log4j] * link:how-do-i-use-java-14-logging.html[How do I use Java 1.4 logging] http://git-wip-us.apache.org/repos/asf/camel/blob/a5d3b750/camel-core/src/main/docs/mock-component.adoc ---------------------------------------------------------------------- diff --git a/camel-core/src/main/docs/mock-component.adoc b/camel-core/src/main/docs/mock-component.adoc index 56d80a7..66f3936 100644 --- a/camel-core/src/main/docs/mock-component.adoc +++ b/camel-core/src/main/docs/mock-component.adoc @@ -1,16 +1,6 @@ == Mock Component -ifdef::env-github[] *Available as of Camel version 1.0.0* -:caution-caption: :boom: -:important-caption: :exclamation: -:note-caption: :information_source: -:tip-caption: :bulb: -:warning-caption: :warning: -endif::[] - -=== Mock Component - link:testing.html[Testing] of distributed and asynchronous processing is notoriously difficult. The link:mock.html[Mock], link:test.html[Test] and link:dataset.html[DataSet] endpoints work great with the http://git-wip-us.apache.org/repos/asf/camel/blob/a5d3b750/camel-core/src/test/java/org/apache/camel/processor/TrySetFaultTest.java ---------------------------------------------------------------------- diff --git a/camel-core/src/test/java/org/apache/camel/processor/TrySetFaultTest.java b/camel-core/src/test/java/org/apache/camel/processor/TrySetFaultTest.java index 637b779..157acb4 100644 --- a/camel-core/src/test/java/org/apache/camel/processor/TrySetFaultTest.java +++ b/camel-core/src/test/java/org/apache/camel/processor/TrySetFaultTest.java @@ -22,8 +22,12 @@ import org.apache.camel.builder.RouteBuilder; public class TrySetFaultTest extends ContextTestSupport { public void testSetFault() throws Exception { + // only mock:start gets the message as a fault body stops routing + getMockEndpoint("mock:start").expectedMessageCount(1); getMockEndpoint("mock:a").expectedMessageCount(0); + getMockEndpoint("mock:catch-a").expectedMessageCount(0); getMockEndpoint("mock:b").expectedMessageCount(0); + getMockEndpoint("mock:catch-b").expectedMessageCount(0); template.requestBody("direct:start", "Hello World"); @@ -36,6 +40,7 @@ public class TrySetFaultTest extends ContextTestSupport { @Override public void configure() throws Exception { from("direct:start") + .to("mock:start") .to("direct:a") .to("mock:a") .to("direct:b") @@ -45,6 +50,7 @@ public class TrySetFaultTest extends ContextTestSupport { .doTry() .setFaultBody(constant("Failed at A")) .doCatch(Exception.class) + // fault will not throw an exception .to("mock:catch-a") .end(); @@ -52,7 +58,8 @@ public class TrySetFaultTest extends ContextTestSupport { .doTry() .setFaultBody(constant("Failed at B")) .doCatch(Exception.class) - .to("mock:catch-a") + // fault will not throw an exception + .to("mock:catch-b") .end() .to("log:b"); }