Skip to content

Commit

Permalink
yaml-loader: add language doc
Browse files Browse the repository at this point in the history
  • Loading branch information
lburgazzoli committed May 7, 2020
1 parent a237bc5 commit ec05e8f
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 68 deletions.
1 change: 1 addition & 0 deletions docs/modules/languages/nav-languages.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
** xref:languages:javascript.adoc[JavaScript]
** xref:languages:java.adoc[Java]
** xref:languages:xml.adoc[XML]
** xref:languages:yaml.adoc[YAML]
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
= YAML DSL

This artifact provides a YAML based DSL for Apache Camel and Apache Camel K.
= Writing Integrations in YAML

[WARNING]
====
The YAML DSL is current in preview support level.
====

== Defining a route

A route is a sequence of elements, or `steps`, defined as follow:

[source, yaml]
[source,yaml]
----
from: #<1>
uri: "direct:start"
Expand Down Expand Up @@ -36,7 +37,7 @@ As general rule each step provide all the parameters the related definition decl
+
Some steps such as `filter` and `split` have their own pipeline when an exchange matches the filter expression or for the items generated by the split expression, such pipeline can be defined by the `steps` field:
+
[source, yaml]
[source,yaml]
----
filter:
expression:
Expand All @@ -55,7 +56,7 @@ if the `steps` field is omitted, then each subsequent step is considered part of
+
Some EIP such as `filter` and `split` supports the definition of an expression through the `expression` field:
+
[source, yaml]
[source,yaml]
.Explicit Expression field
----
filter:
Expand All @@ -65,7 +66,7 @@ filter:
+
To make the DSL less verbose, the `expression` field can be omitted:
+
[source, yaml]
[source,yaml]
.Implicit Expression field
----
filter:
Expand All @@ -74,7 +75,7 @@ filter:
+
In general expression can be defined inline like in the examples above but in case you need provide more information, you can 'unroll' the expression definition and configure any single parameter the expression defines.
+
[source, yaml]
[source,yaml]
.Full Expression definition
----
filter:
Expand All @@ -87,7 +88,7 @@ filter:
+
Some EIP such as `set-body` and `marshal` supports the definition of data formats through the `data-format` field:
+
[source, yaml]
[source,yaml]
.Explicit Data Format field
----
set-body:
Expand All @@ -98,7 +99,7 @@ set-body:
+
To make the DSL less verbose, the `data-format` field can be omitted:
+
[source, yaml]
[source,yaml]
.Implicit Data Format field
----
set-body:
Expand All @@ -111,60 +112,6 @@ set-body:
In case you want to use the data-format's default settings, you need to place an empty block as data format parameters, like `json: {}`
====


== Supported EIP

- Aggregate
- Bean
- Choice
- Claim Check
- Convert Body
- Delay
- Dynamic Router
- Enrich
- Filter
- From
- Idempotent Consumer
- Load Balance
- Log
- Loop
- Marshal
- Multicast
- Pipeline
- PollEnrich
- Process
- Recipient List
- Remove Header
- Remove Headers
- Remove Property
- Remove Properties
- Resequence
- Rest DSL
- Rollback
- Routing Slip
- Sample
- Script
- Set Body
- Set Exchange Pattern
- Set Header
- Set Property
- Sort
- Split
- Step
- Stop
- Threads
- Throttle
- Throw Exception
- To
- To Dynamic
- Transform
- Try Catch Finally
- Unmarshal
- Validate
- Wire Tap

The Try Catch Finally EIP currently only support specifying one `do-catch` clause.

== Extending the DSL

The DSL is designed to be easily extended so you can provide your own step handler which is discovered at runtime using Camel's factory finder.
Expand All @@ -181,11 +128,13 @@ class=com.acme.converter.MyConverter
- create the step handler extending `org.apache.camel.k.loader.yaml.parser.ProcessorStepParser`
+

[source, java]
[source,java]
----
package com.acme.converter.AcmeConverter
import org.apache.camel.k.loader.yaml.parser.ProcessorStepParser;public class AcmeConverter
import org.apache.camel.k.loader.yaml.parser.ProcessorStepParser;
public class AcmeConverter
implements ProcessorStepParser {
/**
* @param context contains a references to the camel context and the current node as raw JsonNode
Expand Down Expand Up @@ -216,8 +165,7 @@ import org.apache.camel.k.loader.yaml.parser.ProcessorStepParser;public class Ac

Assuming the entry in the `META-INF/services/org/apache/camel/k/yaml` is named `acme` then you can use it from the YAML DSL like:


[source, yaml]
[source,yaml]
----
from:
uri: "direct:start"
Expand All @@ -227,3 +175,59 @@ from:
port: 8081
----

== Supported EIP

- Aggregate
- Bean
- Choice
- Circuit Breaker
- Claim Check
- Convert Body
- Delay
- Dynamic Router
- Enrich
- Filter
- From
- Idempotent Consumer
- Load Balance
- Log
- Loop
- Marshal
- Multicast
- Pipeline
- PollEnrich
- Process
- Recipient List
- Remove Header
- Remove Headers
- Remove Property
- Remove Properties
- Resequence
- Rest DSL
- Rollback
- Routing Slip
- Saga
- Sample
- Script
- ServiceCall
- Set Body
- Set Exchange Pattern
- Set Header
- Set Property
- Sort
- Split
- Step
- Stop
- Threads
- Throttle
- Throw Exception
- To
- To Dynamic
- Transacted
- Transform
- Try Catch Finally
- Unmarshal
- Validate
- Wire Tap

The Try Catch Finally EIP currently only support specifying one `do-catch` clause.

0 comments on commit ec05e8f

Please sign in to comment.