You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: documentation/modules/advanced/pages/camel-k-cbr.adoc
+20-19Lines changed: 20 additions & 19 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,15 +4,15 @@ include::_attributes.adoc[]
4
4
5
5
At the end of this chapter you will be able to:
6
6
7
-
- How to run integrate Apache Kafka and Camel-K
8
-
- Apply Content Based Routing (CBR) Enterprise Integration Pattern(EIP)
7
+
- How to integrate Apache Kafka and Camel-K
8
+
- Apply the Content Based Routing (CBR) Enterprise Integration Pattern(EIP)
9
9
10
10
Apache Camel supports numerous Enterprise Integration Patterns (EIPs) out-of-the-box, you can find the complete list of patterns on the Apache Camel https://camel.apache.org/manual/latest/enterprise-integration-patterns.html[website].
11
11
12
12
[sidebar]
13
13
.Content Based Router
14
14
****
15
-
The Content Based Router examines the message content and routes the message to a different channel based on the data contained in the message. The routing can be based on a number of criteria such as existence of fields, specific field values etc. When implementing a Content Based Router, special caution should be taken to make the routing function easy to maintain as the router can become a point of frequent maintenance. In more sophisticated integration scenarios, the Content Based Router can take on the form of a configurable rules engine that computes the destination channel based on a set of configurable rules. footnote:[https://www.enterpriseintegrationpatterns.com/patterns/messaging/ContentBasedRouter.html]
15
+
The Content Based Router examines the message content and routes messages to a different channel based on the data contained in the message. The routing can be based on a number of criteria such as existence of fields, specific field values etc. When implementing a Content Based Router, special caution should be taken to make the routing function easy to maintain as the router can become a point of frequent maintenance. In more sophisticated integration scenarios, the Content Based Router can take on the form of a configurable rules engine that computes the destination channel based on a set of configurable rules. footnote:[https://www.enterpriseintegrationpatterns.com/patterns/messaging/ContentBasedRouter.html]
- *Data Producer*: The Camel-K integration application, that will produce data simulating the streaming data by sending the data to https://kafka.apache.org[Apache Kafka]
29
-
- *Data Processor*: The Camel-K integration application, that will process the streaming data from Kafka and send the default Knative Eventing Broker
30
-
- *Event Subscriber(Fruits UI)*: The https://quarkus.io[Quarkus] Java application, that will display the processed data from the Data Processor
31
-
- *Event Trigger*: This is xref:knative-tutorial-eventing:ROOT:eventing-trigger-broker.adoc[Knative Event Trigger] that apply a filter on the processed data, to send to the Event Subscriber
28
+
- *Data Producer*: A Camel-K integration application which will produce data simulating the streaming data by sending the data to https://kafka.apache.org[Apache Kafka]
29
+
- *Data Processor*: A Camel-K integration application which will process the streaming data from Kafka and send the default Knative Eventing Broker
30
+
- *Event Subscriber(Fruits UI)*: A https://quarkus.io[Quarkus] Java application, that will display the processed data from the Data Processor
31
+
- *Event Trigger*: A xref:knative-tutorial-eventing:ROOT:eventing-trigger-broker.adoc[Knative Event Trigger] that applies a filter on the processed data to send to the Event Subscriber
32
32
33
-
The upcoming samples will deploy these individual components and finally we test the integration by wiring them all together.
33
+
The upcoming samples will deploy these individual components and after that we will test the integration by wiring them all together.
34
34
35
35
Just make sure:
36
36
37
-
* Review xref:eventing/eventing.adoc[Knative Eventing] module to refresh the concepts
37
+
* To review the xref:eventing/eventing.adoc[Knative Eventing] module to refresh the concepts
38
38
* Apache Kafka xref:deploy-apache-kafka.adoc[my-cluster] is running
39
39
40
40
:service-file: default-broker.yaml
@@ -78,33 +78,34 @@ cd $TUTORIAL_HOME/{camelk-repo}
78
78
[#camel-k-cbr-data-producer]
79
79
== Deploy Data Producer
80
80
81
-
Knative Camel-K integration called `fruits-producer` which will use a public http://fruityvice.com[fruits API] to retrieve the information about fruits and stream the data to Apache Kafka. The `fruits-producer` service retrieves the data from the fruits API, splits it using the https://camel.apache.org/manual/latest/split-eip.html[Split EIP] and then sends the data to a Kafka topic called `fruits`.
81
+
This is a Knative Camel-K integration called `fruits-producer` which will use a public http://fruityvice.com[fruits API] to retrieve the information about fruits and stream the data to Apache Kafka. The `fruits-producer` service retrieves the data from the fruits API, splits it using the https://camel.apache.org/manual/latest/split-eip.html[Split EIP] and then sends the data to a Kafka topic called `fruits`.
82
82
83
83
.Fruits producer
84
84
[source,yaml]
85
85
----
86
86
- from:
87
87
uri: timer:tick
88
88
parameters:
89
-
period: 5000
89
+
period: 5000#<1>
90
90
steps:
91
91
- set-header:
92
92
name: CamelHttpMethod
93
93
constant: GET
94
-
- to: "https://fruityvice.com/api/fruit/all"#<1>
94
+
- to: "https://fruityvice.com/api/fruit/all"#<2>
95
95
- split:
96
-
jsonpath: "$.[*]"#<2>
96
+
jsonpath: "$.[*]"#<3>
97
97
- marshal:
98
98
json: {}
99
99
- log:
100
100
message: "${body}"
101
-
- to: "kafka:fruits?brokers=my-cluster-kafka-bootstrap.kafka:9092"#<3>
101
+
- to: "kafka:fruits?brokers=my-cluster-kafka-bootstrap.kafka:9092"#<4>
102
102
103
103
----
104
104
105
105
<1> Poll every 5 seconds from the REST API http://fruityvice.com.
106
106
<2> Call the external REST API http://fruityvice.com to get the list of fruits to simulate the data streaming
107
-
<3> Send the processed data i.e. the individual fruit record as JSON to Apache Kafka Topic
107
+
<3> Split the message
108
+
<4> Send the processed data i.e. the individual fruit record as JSON to Apache Kafka Topic
108
109
109
110
Run the following command to deploy the `fruit-producer` integration:
Let us now deploy a https://en.wikipedia.org/wiki/Reactive_programming[Reactive] Web application called `fruit-events-display`. It is a https://quarkus.io[Quarkus] Java application, that will update UI(reactively) as and when it receives the processed data from the Knative Eventing backend.
366
+
Now deploy a https://en.wikipedia.org/wiki/Reactive_programming[Reactive] Web application called `fruit-events-display`. It is a https://quarkus.io[Quarkus] Java application, that will update UI(reactively) as and when it receives the processed data from the Knative Eventing backend.
366
367
367
368
You can deploy the `fruit-events-display` application using the command:
As a last step let us now deploy a Knative Event Trigger called `fruits-trigger`. The trigger consumes the events from the Knative Event Broker named `default`, when the fruit event is received it will dispatch the events to the subscriber -- that is `fruit-events-display` service --.
438
+
As a last step we need to deploy a Knative Event Trigger called `fruits-trigger`. The trigger consumes the events from the Knative Event Broker named `default`, when the fruit event is received it will dispatch the events to the subscriber which is the `fruit-events-display` service.
438
439
439
440
[source,yaml]
440
441
----
@@ -476,7 +477,7 @@ Let us check the status of the Trigger using the command `kubectl -n {tutorial-n
476
477
kubectl -n {tutorial-namespace} get triggers
477
478
----
478
479
479
-
As the trigger will dispatch its filtered event to `fruit-events-display` , the subscriber URI of the Trigger will be that of `fruit-events-display` service.
480
+
As the trigger will dispatch its filtered event to `fruit-events-display` , the subscriber URI of the Trigger will the `fruit-events-display` service.
Now that we have all the components for the <<cbr-app-overview>>, let us verify the end to end flow:
492
+
Now that we have all the components for the <<cbr-app-overview>>, let's verify the end to end flow:
492
493
493
494
To verify the data flow and processing call the `fruits-producer` service using the script `$TUTORIAL_HOME/bin/call.sh` with parameters `fruits-producer` and ''.
0 commit comments