Fuse 6 is no longer supported
As of February 2025, Red Hat Fuse 6 is no longer supported. If you are using Fuse 6, please upgrade to Red Hat build of Apache Camel.Dieser Inhalt ist in der von Ihnen ausgewählten Sprache nicht verfügbar.
Chapter 2. Basic Principles of Route Building
Abstract
2.1. Pipeline Processing Link kopierenLink in die Zwischenablage kopiert!
Overview Link kopierenLink in die Zwischenablage kopiert!
ls | more
is an example of a command that pipes a directory listing, ls
, to the page-scrolling utility, more
. The basic idea of a pipeline is that the output of one command is fed into the input of the next. The natural analogy in the case of a route is for the Out message from one processor to be copied to the In message of the next processor.
Processor nodes Link kopierenLink in die Zwischenablage kopiert!
org.apache.camel.Processor
interface. In other words, processors make up the basic building blocks of a DSL route. For example, DSL commands such as filter()
, delayer()
, setBody()
, setHeader()
, and to()
all represent processors. When considering how processors connect together to build up a route, it is important to distinguish two different processing approaches.
null
in this case.
Figure 2.1. Processor Modifying an In Message
setHeader()
command that modifies the current In message by adding (or modifying) the BillingSystem
heading:
from("activemq:orderQueue") .setHeader("BillingSystem", xpath("/order/billingSystem")) .to("activemq:billingQueue");
from("activemq:orderQueue")
.setHeader("BillingSystem", xpath("/order/billingSystem"))
.to("activemq:billingQueue");
Figure 2.2. Processor Creating an Out Message
transform()
command that creates an Out message with a message body containing the string, DummyBody
:
from("activemq:orderQueue") .transform(constant("DummyBody")) .to("activemq:billingQueue");
from("activemq:orderQueue")
.transform(constant("DummyBody"))
.to("activemq:billingQueue");
constant("DummyBody")
represents a constant expression. You cannot pass the string, DummyBody
, directly, because the argument to transform()
must be an expression type.
Pipeline for InOnly exchanges Link kopierenLink in die Zwischenablage kopiert!
Figure 2.3. Sample Pipeline for InOnly Exchanges
userdataQueue
queue, pipes the message through a Velocity template (to produce a customer address in text format), and then sends the resulting text address to the queue, envelopeAddressQueue
:
from("activemq:userdataQueue") .to(ExchangePattern.InOut, "velocity:file:AdressTemplate.vm") .to("activemq:envelopeAddresses");
from("activemq:userdataQueue")
.to(ExchangePattern.InOut, "velocity:file:AdressTemplate.vm")
.to("activemq:envelopeAddresses");
velocity:file:AdressTemplate.vm
, specifies the location of a Velocity template file, file:AdressTemplate.vm
, in the file system. The to()
command changes the exchange pattern to InOut before sending the exchange to the Velocity endpoint and then changes it back to InOnly afterwards. For more details of the Velocity endpoint, see chapter "Velocity" in "EIP Component Reference".
Pipeline for InOut exchanges Link kopierenLink in die Zwischenablage kopiert!
Figure 2.4. Sample Pipeline for InOut Exchanges
from("jetty:http://localhost:8080/foo") .to("cxf:bean:addAccountDetails") .to("cxf:bean:getCreditRating") .to("cxf:bean:processTransaction");
from("jetty:http://localhost:8080/foo")
.to("cxf:bean:addAccountDetails")
.to("cxf:bean:getCreditRating")
.to("cxf:bean:processTransaction");
cxf:bean:addAccountDetails
, cxf:bean:getCreditRating
, and cxf:bean:processTransaction
. The final Web service, processTransaction
, generates a response (Out message) that is sent back through the JETTY endpoint.
from("jetty:http://localhost:8080/foo") .pipeline("cxf:bean:addAccountDetails", "cxf:bean:getCreditRating", "cxf:bean:processTransaction");
from("jetty:http://localhost:8080/foo")
.pipeline("cxf:bean:addAccountDetails", "cxf:bean:getCreditRating", "cxf:bean:processTransaction");
Pipeline for InOptionalOut exchanges Link kopierenLink in die Zwischenablage kopiert!
null
Out message is copied to the In message of the next node in the pipeline. By contrast, in the case of an InOut exchange, a null
Out message is discarded and the original In message from the current node would be copied to the In message of the next node instead.