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.이 콘텐츠는 선택한 언어로 제공되지 않습니다.
5.4. Pipes and Filters
Overview 링크 복사링크가 클립보드에 복사되었습니다!
링크 복사링크가 클립보드에 복사되었습니다!
The pipes and filters pattern, shown in Figure 5.4, “Pipes and Filters Pattern”, describes a way of constructing a route by creating a chain of filters, where the output of one filter is fed into the input of the next filter in the pipeline (analogous to the UNIX
pipe
command). The advantage of the pipeline approach is that it enables you to compose services (some of which can be external to the Apache Camel application) to create more complex forms of message processing.
Figure 5.4. Pipes and Filters Pattern
Pipeline for the InOut exchange pattern 링크 복사링크가 클립보드에 복사되었습니다!
링크 복사링크가 클립보드에 복사되었습니다!
Normally, all of the endpoints in a pipeline have an input (In message) and an output (Out message), which implies that they are compatible with the InOut message exchange pattern. A typical message flow through an InOut pipeline is shown in Figure 5.5, “Pipeline for InOut Exchanges”.
Figure 5.5. Pipeline for InOut Exchanges
Where the pipeline connects the output of each endpoint to the input of the next one. The Out message from the final endpoint gets sent back to the original caller. You can define a route for this pipeline, as follows:
from("jms:RawOrders").pipeline("cxf:bean:decrypt", "cxf:bean:authenticate", "cxf:bean:dedup", "jms:CleanOrders");
from("jms:RawOrders").pipeline("cxf:bean:decrypt", "cxf:bean:authenticate", "cxf:bean:dedup", "jms:CleanOrders");
The same route can be configured in XML, as follows:
There is no dedicated pipeline element in XML. The preceding combination of
from
and to
elements is semantically equivalent to a pipeline. See the section called “Comparison of pipeline() and to() DSL commands”.
Pipeline for the InOnly and RobustInOnly exchange patterns 링크 복사링크가 클립보드에 복사되었습니다!
링크 복사링크가 클립보드에 복사되었습니다!
When there are no Out messages available from the endpoints in the pipeline (as is the case for the
InOnly
and RobustInOnly
exchange patterns), a pipeline cannot be connected in the normal way. In this special case, the pipeline is constructed by passing a copy of the original In message to each of the endpoints in the pipeline, as shown in Figure 5.6, “Pipeline for InOnly Exchanges”. This type of pipeline is equivalent to a recipient list with fixed destinations(see Section 8.3, “Recipient List”).
Figure 5.6. Pipeline for InOnly Exchanges
The route for this pipeline is defined using the same syntax as an InOut pipeline (either in Java DSL or in XML).
Comparison of pipeline() and to() DSL commands 링크 복사링크가 클립보드에 복사되었습니다!
링크 복사링크가 클립보드에 복사되었습니다!
In the Java DSL, you can define a pipeline route using either of the following syntaxes:
- Using the pipeline() processor command — Use the pipeline processor to construct a pipeline route as follows:
from(SourceURI).pipeline(FilterA, FilterB, TargetURI);
from(SourceURI).pipeline(FilterA, FilterB, TargetURI);
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Using the to() command — Use the
to()
command to construct a pipeline route as follows:from(SourceURI).to(FilterA, FilterB, TargetURI);
from(SourceURI).to(FilterA, FilterB, TargetURI);
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Alternatively, you can use the equivalent syntax:from(SourceURI).to(FilterA).to(FilterB).to(TargetURI);
from(SourceURI).to(FilterA).to(FilterB).to(TargetURI);
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Exercise caution when using the
to()
command syntax, because it is not always equivalent to a pipeline processor. In Java DSL, the meaning of to()
can be modified by the preceding command in the route. For example, when the multicast()
command precedes the to()
command, it binds the listed endpoints into a multicast pattern, instead of a pipeline pattern(see Section 8.11, “Multicast”).