简体   繁体   中英

How should I name Apache Camel DSL elements? Are they "functions"? "Methods"? "Verbs"?

When I want to refer to the elements used in creating a route in Apache Camel (like from , setBody , to , etc), what name should I use? Just call it a "function"? Can I call "method"? Or does it have a more specific and appropriate name?

I've seen people calling it "verb". Would that be an appropriate nomination too?

An example of route definition is:

from("rest:post:bin")
.removeHeader(Exchange.HTTP_URI)
.setHeader("CamelHttpMethod", constant("POST"))
.to("http://httpbin.org/anything")
.unmarshal().json(JsonLibrary.Gson)
.setBody(simple("${body[data]}"))

In this example we use the from , removeHeader , setHeader , to , unmarshal and setBody elements of the Java DSL.

I know that, programmatically, they are function and methods. But using code is not the only way to define a route. We can use these same elements to define a route using the XML or Yaml DSL , for example. So I imagine that simply calling "function" might not be the most appropriate option for naming these DSL elements.

Thanks!

Generally you should use terms defined in the Enterprise integration patterns book and website . This is what Camel documentation uses, what Camel in Action book uses and what are generally considered to be most universal terms when using camel whether you use xml-dsl, yaml-dsl or Java-dsl.

Camel Java-DSL uses something like Builder design pattern that uses method-chaining technique to define routes.

In Java-DSL when you call from("direct:example") method in your route-builder Camel creates new RouteDefition with direct:example Consumer-endpoint. The Method returns you the RouteDefinition object which you can then use to add Producer-endpoints and processors to that RouteDefinition generally using a pipeline .

Examples:

  • from() -> Consumer endpoint
  • to() -> Producer endpoint / Enricher
  • removeHeader, setHeader, unmarshal and setBody -> Processors
  • split() -> Spillter
  • aggregate() -> Aggregator

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM