├── .gitignore
├── 3scale.md
├── README.md
├── Stream Processing and Change Data Capture - A Story with Kafka and Debezium.pdf
├── assets
├── 3scale-config.png
├── apicast-template.png
├── architecture-overview.png
├── cdc-in-brownfield.png
├── chuck-demo.mp4
├── chuck-demo.png
├── chuck-norris-facts-funko.jpg
├── process-chuck-rentals-sf-mapping.png
└── rental-event-to-telegram-mapping.png
├── camel-k-routes
├── route-local.xml
├── route.xml
├── telegram-route.xml
└── test.xml
├── camel-k.md
├── cdc-config.md
├── chuck-norris-facts-api-swagger.yaml
├── chuck-norris-facts-api.yaml
├── chuck-norris-facts-api
├── .gitignore
├── ReadMe.md
├── pom.xml
└── src
│ └── main
│ ├── java
│ └── nexgen
│ │ ├── Application.java
│ │ ├── MyTransformer.java
│ │ └── RestConfigurator.java
│ └── resources
│ ├── api-definitions
│ └── basic-api.yaml
│ ├── application-dev.properties
│ ├── application.properties
│ ├── data
│ └── facts.json
│ ├── logback.xml
│ ├── spring
│ └── camel-context.xml
│ └── static
│ └── index.html
├── chuck-norris-filter-camel
├── .gitignore
├── ReadMe.md
├── pom.xml
└── src
│ ├── main
│ ├── java
│ │ └── nexgen
│ │ │ ├── Application.java
│ │ │ ├── MyTransformer.java
│ │ │ └── RestConfigurator.java
│ └── resources
│ │ ├── api-definitions
│ │ └── basic-api.yaml
│ │ ├── application-dev.properties
│ │ ├── application.properties
│ │ ├── logback.xml
│ │ ├── spring
│ │ └── camel-context.xml
│ │ └── static
│ │ └── index.html
│ └── test
│ └── resources
│ └── test.json
├── chuck-norris-filter-kstreams-quarkus
├── .gitignore
├── .mvn
│ └── wrapper
│ │ ├── MavenWrapperDownloader.java
│ │ ├── maven-wrapper.jar
│ │ └── maven-wrapper.properties
├── README.md
├── deployment.yaml
├── mvnw
├── mvnw.cmd
├── pom.xml
├── src
│ ├── main
│ │ ├── docker
│ │ │ ├── Dockerfile.jvm
│ │ │ ├── Dockerfile.multistage
│ │ │ └── Dockerfile.native
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── github
│ │ │ │ └── lbroudoux
│ │ │ │ └── chucknorris
│ │ │ │ └── filter
│ │ │ │ ├── FilterConfig.java
│ │ │ │ ├── JNIRegistrationFeature.java
│ │ │ │ ├── TopologyProducer.java
│ │ │ │ ├── model
│ │ │ │ ├── Customer.java
│ │ │ │ ├── CustomerRentalMovieAggregate.java
│ │ │ │ ├── DefaultId.java
│ │ │ │ ├── EventType.java
│ │ │ │ ├── Movie.java
│ │ │ │ └── Rental.java
│ │ │ │ └── serdes
│ │ │ │ ├── JsonHybridDeserializer.java
│ │ │ │ ├── JsonPojoSerializer.java
│ │ │ │ └── SerdeFactory.java
│ │ └── resources
│ │ │ ├── META-INF
│ │ │ └── resources
│ │ │ │ └── index.html
│ │ │ └── application.properties
│ └── test
│ │ └── java
│ │ └── com
│ │ └── github
│ │ └── lbroudoux
│ │ └── chucknorris
│ │ └── filter
│ │ └── serdes
│ │ └── JsonPojoSerializerTest.java
└── topic.yaml
├── chuck-norris-filter-kstreams
├── .classpath
├── .project
├── .settings
│ ├── org.eclipse.core.resources.prefs
│ ├── org.eclipse.jdt.apt.core.prefs
│ ├── org.eclipse.jdt.core.prefs
│ └── org.eclipse.m2e.core.prefs
├── Dockerfile
├── data.json
├── data.md
├── deployment.yaml
├── pom.xml
├── scripts
│ ├── dynamic_resources.sh
│ └── launch_java.sh
├── src
│ ├── main
│ │ └── java
│ │ │ └── com
│ │ │ └── github
│ │ │ └── lbroudoux
│ │ │ └── chucknorris
│ │ │ └── filter
│ │ │ ├── Example.java
│ │ │ ├── FilterConfig.java
│ │ │ ├── Main.java
│ │ │ ├── model
│ │ │ ├── Customer.java
│ │ │ ├── CustomerRentalMovieAggregate.java
│ │ │ ├── DefaultId.java
│ │ │ ├── EventType.java
│ │ │ ├── Movie.java
│ │ │ └── Rental.java
│ │ │ └── serdes
│ │ │ ├── JsonHybridDeserializer.java
│ │ │ ├── JsonPojoSerializer.java
│ │ │ └── SerdeFactory.java
│ └── test
│ │ └── java
│ │ └── com
│ │ └── github
│ │ └── lbroudoux
│ │ └── chucknorris
│ │ └── filter
│ │ └── FilterTest.java
└── topic.yaml
├── debezium-connect.yml
├── debezium-connector.yml
├── fuse-online-routes
├── process-chuck-rentals-sf-lbr-export
│ ├── model-info.json
│ └── model.json
└── rental-event-to-telegram-lbr-export
│ ├── model-info.json
│ └── model.json
├── fuse-online.md
├── kamelets
├── rentals-topic-to-s3.yml
└── telegram-to-s3.yml
├── kstream-config.md
└── rental-service
├── .gitignore
├── ReadMe.md
├── pom.xml
├── src
└── main
│ ├── java
│ ├── META-INF
│ │ └── MANIFEST.MF
│ └── nextgen
│ │ ├── Application.java
│ │ ├── MyTransformer.java
│ │ ├── RestConfigurator.java
│ │ ├── apimodel
│ │ └── RentalEdit.java
│ │ ├── controller
│ │ └── AppController.java
│ │ ├── model
│ │ ├── AbstractBaseEntity.java
│ │ ├── Customer.java
│ │ ├── Movie.java
│ │ └── Rental.java
│ │ ├── processor
│ │ ├── AbstractCRUD.java
│ │ ├── RentalCRUD.java
│ │ └── RentalPost.java
│ │ └── repo
│ │ ├── CustomerRepo.java
│ │ ├── MovieRepo.java
│ │ └── RentalRepo.java
│ └── resources
│ ├── api-definitions
│ └── basic-api.yaml
│ ├── application-dev.properties
│ ├── application.properties
│ ├── logback.xml
│ ├── spring
│ └── camel-context.xml
│ ├── sql
│ └── examples.sql
│ ├── static
│ ├── An Eye for an Eye.jpg
│ ├── Charly Chaplin in Wien.jpg
│ ├── Delta Force.jpg
│ ├── Invasion U.S.A..jpg
│ ├── King Kong.jpg
│ ├── Robin Hood.jpg
│ ├── The Elephant Man.jpg
│ ├── The Octagon.jpg
│ ├── Vertigo.jpg
│ ├── chuck.png
│ ├── test.html
│ └── video.png
│ └── templates
│ ├── fragments
│ └── header.html
│ ├── index.html
│ ├── login.html
│ ├── logout.html
│ └── rented.html
└── test
├── test.json
└── test2.json
/.gitignore:
--------------------------------------------------------------------------------
1 | # IntelliJ IDEA specific
2 | .idea/
3 | *.iml
4 | */target/
5 |
--------------------------------------------------------------------------------
/3scale.md:
--------------------------------------------------------------------------------
1 |
2 | # Apicast setup
3 |
4 | 
5 |
6 | # 3scale backend setup
7 |
8 | 
9 |
--------------------------------------------------------------------------------
/Stream Processing and Change Data Capture - A Story with Kafka and Debezium.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lbroudoux/chuck-norris-streams/cd0b44020521365f21b6173d4168fa1e332d2703/Stream Processing and Change Data Capture - A Story with Kafka and Debezium.pdf
--------------------------------------------------------------------------------
/assets/3scale-config.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lbroudoux/chuck-norris-streams/cd0b44020521365f21b6173d4168fa1e332d2703/assets/3scale-config.png
--------------------------------------------------------------------------------
/assets/apicast-template.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lbroudoux/chuck-norris-streams/cd0b44020521365f21b6173d4168fa1e332d2703/assets/apicast-template.png
--------------------------------------------------------------------------------
/assets/architecture-overview.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lbroudoux/chuck-norris-streams/cd0b44020521365f21b6173d4168fa1e332d2703/assets/architecture-overview.png
--------------------------------------------------------------------------------
/assets/cdc-in-brownfield.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lbroudoux/chuck-norris-streams/cd0b44020521365f21b6173d4168fa1e332d2703/assets/cdc-in-brownfield.png
--------------------------------------------------------------------------------
/assets/chuck-demo.mp4:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lbroudoux/chuck-norris-streams/cd0b44020521365f21b6173d4168fa1e332d2703/assets/chuck-demo.mp4
--------------------------------------------------------------------------------
/assets/chuck-demo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lbroudoux/chuck-norris-streams/cd0b44020521365f21b6173d4168fa1e332d2703/assets/chuck-demo.png
--------------------------------------------------------------------------------
/assets/chuck-norris-facts-funko.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lbroudoux/chuck-norris-streams/cd0b44020521365f21b6173d4168fa1e332d2703/assets/chuck-norris-facts-funko.jpg
--------------------------------------------------------------------------------
/assets/process-chuck-rentals-sf-mapping.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lbroudoux/chuck-norris-streams/cd0b44020521365f21b6173d4168fa1e332d2703/assets/process-chuck-rentals-sf-mapping.png
--------------------------------------------------------------------------------
/assets/rental-event-to-telegram-mapping.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lbroudoux/chuck-norris-streams/cd0b44020521365f21b6173d4168fa1e332d2703/assets/rental-event-to-telegram-mapping.png
--------------------------------------------------------------------------------
/camel-k-routes/route-local.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | * Red Hat licenses this file to you under the Apache License, version 5 | * 2.0 (the "License"); you may not use this file except in compliance 6 | * with the License. You may obtain a copy of the License at 7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
13 | * implied. See the License for the specific language governing
14 | * permissions and limitations under the License.
15 | *
16 | */
17 | package nexgen;
18 |
19 | import java.io.IOException;
20 | import java.io.InputStream;
21 | import java.io.StringWriter;
22 | import java.net.URL;
23 |
24 | import com.google.common.io.Resources;
25 |
26 | import org.apache.commons.io.IOUtils;
27 | import org.springframework.stereotype.Component;
28 |
29 | /**
30 | * A sample transform
31 | */
32 | @Component(value = "myTransformer")
33 | public class MyTransformer {
34 |
35 |
36 | public String content() throws IOException {
37 | InputStream inputStream = getClass()
38 | .getClassLoader().getResourceAsStream("data/facts.json");
39 |
40 | StringWriter writer = new StringWriter();
41 |
42 | IOUtils.copy(inputStream, writer,"UTF-8");
43 |
44 | return writer.toString();
45 | }
46 |
47 | public String transform() {
48 | // let's return a random string
49 | StringBuffer buffer = new StringBuffer();
50 | for (int i = 0; i < 3; i++) {
51 | int number = (int) (Math.round(Math.random() * 1000) % 10);
52 | char letter = (char) ('0' + number);
53 | buffer.append(letter);
54 | }
55 | return buffer.toString();
56 | }
57 |
58 | }
59 |
--------------------------------------------------------------------------------
/chuck-norris-facts-api/src/main/java/nexgen/RestConfigurator.java:
--------------------------------------------------------------------------------
1 | package nexgen;
2 |
3 | import org.apache.camel.builder.RouteBuilder;
4 | import org.apache.camel.model.rest.RestBindingMode;
5 | import org.springframework.beans.factory.annotation.Autowired;
6 | import org.springframework.core.env.Environment;
7 | import org.springframework.stereotype.Component;
8 |
9 | @Component
10 | public class RestConfigurator extends RouteBuilder {
11 |
12 | @Autowired
13 | Environment environment;
14 |
15 | @Override
16 | public void configure() throws Exception {
17 | restConfiguration()
18 | .component("servlet")
19 | .bindingMode(RestBindingMode.json)
20 | .contextPath(environment.getProperty("camelrest.contextPath"))
21 | .port(environment.getProperty("camelrest.port"))
22 | .apiContextPath("/api-docs")
23 | .apiProperty("cors", "true")
24 | .apiProperty("api.title", environment.getProperty("camel.springboot.name"))
25 | .apiProperty("api.version", environment.getProperty("camelrest.apiversion"))
26 | .host(environment.getProperty("camelrest.host"))
27 | .dataFormatProperty("prettyPrint", "true");
28 | }
29 |
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/chuck-norris-facts-api/src/main/resources/api-definitions/basic-api.yaml:
--------------------------------------------------------------------------------
1 | ---
2 | swagger: "2.0"
3 | info:
4 | title: basic-api
5 | version: 1.0.0
6 | paths:
7 | /person:
8 | get:
9 | operationId: getPerson
10 | parameters:
11 | - name: email
12 | in: query
13 | required: true
14 | type: string
15 | responses:
16 | 200:
17 | description: Response ok
18 | schema:
19 | $ref: '#/definitions/Person'
20 | definitions:
21 | Person:
22 | title: Root Type for Person
23 | description: The root of the Person type's schema.
24 | type: object
25 | properties:
26 | firstName:
27 | type: string
28 | lastName:
29 | type: string
30 | email:
31 | type: string
32 | age:
33 | format: int32
34 | type: integer
35 | example: |-
36 | {
37 | "firstName": "John",
38 | "lastName": "Doe",
39 | "email": "john@mail.com",
40 | "age": 21
41 | }
--------------------------------------------------------------------------------
/chuck-norris-facts-api/src/main/resources/application-dev.properties:
--------------------------------------------------------------------------------
1 | logging.config=classpath:logback.xml
2 |
3 | # the options from org.apache.camel.spring.boot.CamelConfigurationProperties can be configured here
4 | camel.springboot.name=chuck-norris-facts-api
5 |
6 | # lets listen on all ports to ensure we can be invoked from the pod IP
7 | server.address=0.0.0.0
8 | management.address=0.0.0.0
9 | # lets use a different management port in case you need to listen to HTTP requests on 8080
10 | server.port=8090
11 | management.port=8190
12 |
13 | # disable all management enpoints except health
14 | endpoints.enabled = false
15 | endpoints.health.enabled = true
16 |
17 | cxf.path=/services
18 |
19 | camel.component.servlet.mapping.contextPath=/camel/*
20 |
21 | camelrest.host=localhost
22 | camelrest.port=8090
23 | camelrest.contextPath=/camel
24 | camelrest.apiversion=1.0-SNAPSHOT
--------------------------------------------------------------------------------
/chuck-norris-facts-api/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | logging.config=classpath:logback.xml
2 |
3 | # the options from org.apache.camel.spring.boot.CamelConfigurationProperties can be configured here
4 | camel.springboot.name=chuck-norris-facts-api
5 |
6 | # lets listen on all ports to ensure we can be invoked from the pod IP
7 | server.address=0.0.0.0
8 | management.address=0.0.0.0
9 | # lets use a different management port in case you need to listen to HTTP requests on 8080
10 | server.port=8080
11 | management.port=8081
12 |
13 | # disable all management enpoints except health
14 | endpoints.enabled = false
15 | endpoints.health.enabled = true
16 |
17 | cxf.path=/services
18 |
19 | camel.component.servlet.mapping.contextPath=/camel/*
20 |
21 | camelrest.host=localhost
22 | camelrest.port=80
23 | camelrest.contextPath=/camel
24 | camelrest.apiversion=1.0-SNAPSHOT
--------------------------------------------------------------------------------
/chuck-norris-facts-api/src/main/resources/data/facts.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "id": "1",
4 | "fact": "Chuck Norris a déjà compté jusqu'à l'infini. Deux fois.",
5 | "date": "1373297343",
6 | "vote": "189404",
7 | "points": "866902"
8 | },
9 | {
10 | "id": "9355",
11 | "fact": "Google, c'est le seul endroit où tu peux taper Chuck Norris...",
12 | "date": "1373297340",
13 | "vote": "136456",
14 | "points": "607433"
15 | },
16 | {
17 | "id": "10705",
18 | "fact": "Chuck Norris et Superman ont fait un bras de fer, le perdant devait mettre son slip par dessus son pantalon.",
19 | "date": "1373297355",
20 | "vote": "113973",
21 | "points": "501197"
22 | },
23 | {
24 | "id": "106",
25 | "fact": "Chuck Norris peut gagner une partie de puissance 4 en trois coups.",
26 | "date": "1373297368",
27 | "vote": "107246",
28 | "points": "461431"
29 | },
30 | {
31 | "id": "73",
32 | "fact": "Jesus Christ est né en 1940 avant Chuck Norris.",
33 | "date": "1373297391",
34 | "vote": "105222",
35 | "points": "445848"
36 | },
37 | {
38 | "id": "10",
39 | "fact": "Chuck Norris ne porte pas de montre. Il décide de l'heure qu'il est.",
40 | "date": "1373297395",
41 | "vote": "104807",
42 | "points": "435723"
43 | },
44 | {
45 | "id": "180",
46 | "fact": "La seule chose qui arrive à la cheville de Chuck Norris... c'est sa chaussette.",
47 | "date": "1373297400",
48 | "vote": "102280",
49 | "points": "429332"
50 | },
51 | {
52 | "id": "246",
53 | "fact": "Chuck Norris fait pleurer les oignons.",
54 | "date": "1373297406",
55 | "vote": "99968",
56 | "points": "418228"
57 | },
58 | {
59 | "id": "4",
60 | "fact": "Chuck Norris peut diviser par zéro.",
61 | "date": "1373297425",
62 | "vote": "98323",
63 | "points": "405137"
64 | },
65 | {
66 | "id": "398",
67 | "fact": "Chuck Norris comprend Jean-Claude Van Damme.",
68 | "date": "1373297429",
69 | "vote": "97176",
70 | "points": "403247"
71 | },
72 | {
73 | "id": "5",
74 | "fact": "Chuck Norris joue à la roulette russe avec un chargeur plein.",
75 | "date": "1373297440",
76 | "vote": "92975",
77 | "points": "397412"
78 | },
79 | {
80 | "id": "3",
81 | "fact": "Chuck Norris sait parler le braille.",
82 | "date": "1373297434",
83 | "vote": "94132",
84 | "points": "397266"
85 | },
86 | {
87 | "id": "152",
88 | "fact": "Chuck Norris a un jour avalé un paquet entier de somnifères. Il a cligné des yeux.",
89 | "date": "1373297451",
90 | "vote": "94448",
91 | "points": "394266"
92 | },
93 | {
94 | "id": "267",
95 | "fact": "Quand Google ne trouve pas quelque chose, il demande à Chuck Norris.",
96 | "date": "1373297445",
97 | "vote": "93800",
98 | "points": "393451"
99 | },
100 | {
101 | "id": "20",
102 | "fact": "Les suisses ne sont pas neutres, ils attendent de savoir de quel coté Chuck Norris se situe.",
103 | "date": "1373297455",
104 | "vote": "93741",
105 | "points": "390347"
106 | },
107 | {
108 | "id": "12",
109 | "fact": "Il n'y a pas de théorie de l'évolution. Juste une liste d'espèces que Chuck Norris autorise à survivre.",
110 | "date": "1373297465",
111 | "vote": "88531",
112 | "points": "368188"
113 | },
114 | {
115 | "id": "3693",
116 | "fact": "Chuck Norris peut encercler ses ennemis. Tout seul.",
117 | "date": "1373297495",
118 | "vote": "83160",
119 | "points": "367329"
120 | },
121 | {
122 | "id": "127",
123 | "fact": "Chuck Norris a déjà été sur Mars, c'est pour cela qu'il n'y a pas de signes de vie là bas.",
124 | "date": "1373297480",
125 | "vote": "87236",
126 | "points": "364383"
127 | },
128 | {
129 | "id": "28",
130 | "fact": "Chuck Norris mesure son pouls sur l'échelle de Richter.",
131 | "date": "1373297505",
132 | "vote": "87023",
133 | "points": "359969"
134 | },
135 | {
136 | "id": "13638",
137 | "fact": "Quand Chuck Norris s\u0092est mis au judo, David Douillet s\u0092est mis aux pièces jaunes.",
138 | "date": "1373297489",
139 | "vote": "82967",
140 | "points": "357421"
141 | },
142 | {
143 | "id": "35",
144 | "fact": "Chuck Norris connait la dernière décimale de Pi.",
145 | "date": "1373297506",
146 | "vote": "84453",
147 | "points": "350437"
148 | },
149 | {
150 | "id": "57",
151 | "fact": "Dans une pièce normale, il y a en moyenne 1242 objets avec lesquels Chuck Norris peut vous tuer, en incluant la pièce elle même.",
152 | "date": "1373297535",
153 | "vote": "83529",
154 | "points": "350410"
155 | },
156 | {
157 | "id": "142",
158 | "fact": "Si Chuck Norris avait été pris dans le film 300 il l'aurait renommé en 1.",
159 | "date": "1373297546",
160 | "vote": "83877",
161 | "points": "349393"
162 | },
163 | {
164 | "id": "84",
165 | "fact": "Un jour, au restaurant, Chuck Norris a commandé un steak. Et le steak a obéi.",
166 | "date": "1373297555",
167 | "vote": "85209",
168 | "points": "349209"
169 | }
170 | ]
--------------------------------------------------------------------------------
/chuck-norris-facts-api/src/main/resources/logback.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | * Red Hat licenses this file to you under the Apache License, version 5 | * 2.0 (the "License"); you may not use this file except in compliance 6 | * with the License. You may obtain a copy of the License at 7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
13 | * implied. See the License for the specific language governing
14 | * permissions and limitations under the License.
15 | *
16 | */
17 | package nexgen;
18 |
19 | import org.springframework.stereotype.Component;
20 |
21 | /**
22 | * A sample transform
23 | */
24 | @Component(value = "myTransformer")
25 | public class MyTransformer {
26 |
27 | public String transform() {
28 | // let's return a random string
29 | StringBuffer buffer = new StringBuffer();
30 | for (int i = 0; i < 3; i++) {
31 | int number = (int) (Math.round(Math.random() * 1000) % 10);
32 | char letter = (char) ('0' + number);
33 | buffer.append(letter);
34 | }
35 | return buffer.toString();
36 | }
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/chuck-norris-filter-camel/src/main/java/nexgen/RestConfigurator.java:
--------------------------------------------------------------------------------
1 | package nexgen;
2 |
3 | import org.apache.camel.builder.RouteBuilder;
4 | import org.apache.camel.model.rest.RestBindingMode;
5 | import org.springframework.beans.factory.annotation.Autowired;
6 | import org.springframework.core.env.Environment;
7 | import org.springframework.stereotype.Component;
8 |
9 | @Component
10 | public class RestConfigurator extends RouteBuilder {
11 |
12 | @Autowired
13 | Environment environment;
14 |
15 | @Override
16 | public void configure() throws Exception {
17 | restConfiguration()
18 | .component("servlet")
19 | .bindingMode(RestBindingMode.json)
20 | .contextPath(environment.getProperty("camelrest.contextPath"))
21 | .port(environment.getProperty("camelrest.port"))
22 | .apiContextPath("/api-docs")
23 | .apiProperty("cors", "true")
24 | .apiProperty("api.title", environment.getProperty("camel.springboot.name"))
25 | .apiProperty("api.version", environment.getProperty("camelrest.apiversion"))
26 | .host(environment.getProperty("camelrest.host"))
27 | .dataFormatProperty("prettyPrint", "true");
28 | }
29 |
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/chuck-norris-filter-camel/src/main/resources/api-definitions/basic-api.yaml:
--------------------------------------------------------------------------------
1 | ---
2 | swagger: "2.0"
3 | info:
4 | title: basic-api
5 | version: 1.0.0
6 | paths:
7 | /person:
8 | get:
9 | operationId: getPerson
10 | parameters:
11 | - name: email
12 | in: query
13 | required: true
14 | type: string
15 | responses:
16 | 200:
17 | description: Response ok
18 | schema:
19 | $ref: '#/definitions/Person'
20 | definitions:
21 | Person:
22 | title: Root Type for Person
23 | description: The root of the Person type's schema.
24 | type: object
25 | properties:
26 | firstName:
27 | type: string
28 | lastName:
29 | type: string
30 | email:
31 | type: string
32 | age:
33 | format: int32
34 | type: integer
35 | example: |-
36 | {
37 | "firstName": "John",
38 | "lastName": "Doe",
39 | "email": "john@mail.com",
40 | "age": 21
41 | }
--------------------------------------------------------------------------------
/chuck-norris-filter-camel/src/main/resources/application-dev.properties:
--------------------------------------------------------------------------------
1 | logging.config=classpath:logback.xml
2 |
3 | # the options from org.apache.camel.spring.boot.CamelConfigurationProperties can be configured here
4 | camel.springboot.name=chuck-norris-filter-camel
5 |
6 | # lets listen on all ports to ensure we can be invoked from the pod IP
7 | server.address=0.0.0.0
8 | management.address=0.0.0.0
9 | # lets use a different management port in case you need to listen to HTTP requests on 8080
10 | server.port=8090
11 | management.port=8190
12 |
13 | # disable all management enpoints except health
14 | endpoints.enabled = false
15 | endpoints.health.enabled = true
16 |
17 | cxf.path=/services
18 |
19 | camel.component.servlet.mapping.contextPath=/camel/*
20 |
21 | camelrest.host=localhost
22 | camelrest.port=8090
23 | camelrest.contextPath=/camel
24 | camelrest.apiversion=1.0-SNAPSHOT
25 |
26 | spring.datasource.driver-class-name = com.mysql.jdbc.Driver
27 | spring.datasource.url = jdbc:mysql://172.17.0.2:3306/mysqldb
28 | spring.datasource.username = chuck
29 | spring.datasource.password = password
30 |
31 |
32 | kafka.topic=dbserver1.inventory.rental
33 | kafka.outtopic=events.rentals
34 |
35 | kafka.broker=localhost:9092
36 | kafka.endpoint.standard = kafka:${kafka.topic}?brokers=${kafka.broker}
37 | kafka.endpoint.outstandard = kafka:${kafka.outtopic}?brokers=${kafka.broker}
38 |
--------------------------------------------------------------------------------
/chuck-norris-filter-camel/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | logging.config=classpath:logback.xml
2 |
3 | # the options from org.apache.camel.spring.boot.CamelConfigurationProperties can be configured here
4 | camel.springboot.name=chuck-norris-filter-camel
5 |
6 | # lets listen on all ports to ensure we can be invoked from the pod IP
7 | server.address=0.0.0.0
8 | management.address=0.0.0.0
9 | # lets use a different management port in case you need to listen to HTTP requests on 8080
10 | server.port=8080
11 | management.port=8081
12 |
13 | # disable all management enpoints except health
14 | endpoints.enabled = false
15 | endpoints.health.enabled = true
16 |
17 | cxf.path=/services
18 |
19 | camel.component.servlet.mapping.contextPath=/camel/*
20 |
21 | camelrest.host=localhost
22 | camelrest.port=80
23 | camelrest.contextPath=/camel
24 | camelrest.apiversion=1.0-SNAPSHOT
25 |
26 | spring.datasource.driver-class-name = com.mysql.jdbc.Driver
27 | spring.datasource.url = jdbc:mysql://mysqldebezium.chuck-movie-rental.svc.cluster.local:3306/inventory
28 | spring.datasource.username = root
29 | spring.datasource.password = password
30 |
31 | kafka.topic=dbserver1.inventory.rental
32 | kafka.outtopic=events.rentals
33 |
34 | kafka.broker=my-cluster-kafka-bootstrap.amq-streams.svc.cluster.local:9092
35 | kafka.endpoint.standard = kafka:${kafka.topic}?brokers=${kafka.broker}
36 | kafka.endpoint.outstandard = kafka:${kafka.outtopic}?brokers=${kafka.broker}
37 |
--------------------------------------------------------------------------------
/chuck-norris-filter-camel/src/main/resources/logback.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
Congratulations, you have created a new Quarkus application.
109 | 110 |This page is served by Quarkus. The source is in
113 | src/main/resources/META-INF/resources/index.html
.
If not already done, run the application in dev mode using: mvn compile quarkus:dev
.
118 |
src/main/java
.src/main/resources/META-INF/resources
.src/main/resources/application.properties
.
123 | Just delete the src/main/resources/META-INF/resources/index.html
file.
4 | * Red Hat licenses this file to you under the Apache License, version 5 | * 2.0 (the "License"); you may not use this file except in compliance 6 | * with the License. You may obtain a copy of the License at 7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
13 | * implied. See the License for the specific language governing
14 | * permissions and limitations under the License.
15 | *
16 | */
17 | package nextgen;
18 |
19 | import org.springframework.stereotype.Component;
20 |
21 | /**
22 | * A sample transform
23 | */
24 | @Component(value = "myTransformer")
25 | public class MyTransformer {
26 |
27 | public String transform() {
28 | // let's return a random string
29 | StringBuffer buffer = new StringBuffer();
30 | for (int i = 0; i < 3; i++) {
31 | int number = (int) (Math.round(Math.random() * 1000) % 10);
32 | char letter = (char) ('0' + number);
33 | buffer.append(letter);
34 | }
35 | return buffer.toString();
36 | }
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/rental-service/src/main/java/nextgen/RestConfigurator.java:
--------------------------------------------------------------------------------
1 | package nextgen;
2 |
3 | import org.apache.camel.builder.RouteBuilder;
4 | import org.apache.camel.model.rest.RestBindingMode;
5 | import org.springframework.beans.factory.annotation.Autowired;
6 | import org.springframework.core.env.Environment;
7 | import org.springframework.stereotype.Component;
8 |
9 | @Component
10 | public class RestConfigurator extends RouteBuilder {
11 |
12 | @Autowired
13 | Environment environment;
14 |
15 | @Override
16 | public void configure() throws Exception {
17 | restConfiguration()
18 | .component("servlet")
19 | .bindingMode(RestBindingMode.json)
20 | .contextPath(environment.getProperty("camelrest.contextPath"))
21 | .port(environment.getProperty("camelrest.port"))
22 | .apiContextPath("/api-docs")
23 | .apiProperty("cors", "true")
24 | .apiProperty("api.title", environment.getProperty("camel.springboot.name"))
25 | .apiProperty("api.version", environment.getProperty("camelrest.apiversion"))
26 | .host(environment.getProperty("camelrest.host"))
27 | .dataFormatProperty("prettyPrint", "true");
28 |
29 | }
30 |
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/rental-service/src/main/java/nextgen/apimodel/RentalEdit.java:
--------------------------------------------------------------------------------
1 | package nextgen.apimodel;
2 |
3 | import java.util.Date;
4 |
5 | import javax.persistence.ManyToOne;
6 |
7 | import nextgen.model.Customer;
8 | import nextgen.model.Movie;
9 |
10 | public class RentalEdit {
11 |
12 | private Date startDate;
13 | private Integer rentalDuration;
14 |
15 | private Long movieId;
16 |
17 | private Long customerId;
18 |
19 | public Date getStartDate() {
20 | return startDate;
21 | }
22 |
23 | public void setStartDate(Date startDate) {
24 | this.startDate = startDate;
25 | }
26 |
27 | public Integer getRentalDuration() {
28 | return rentalDuration;
29 | }
30 |
31 | public void setRentalDuration(Integer rentalDuration) {
32 | this.rentalDuration = rentalDuration;
33 | }
34 |
35 | public Long getMovieId() {
36 | return movieId;
37 | }
38 |
39 | public void setMovieId(Long movieId) {
40 | this.movieId = movieId;
41 | }
42 |
43 | public Long getCustomerId() {
44 | return customerId;
45 | }
46 |
47 | public void setCustomerId(Long customerId) {
48 | this.customerId = customerId;
49 | }
50 |
51 |
52 | }
53 |
--------------------------------------------------------------------------------
/rental-service/src/main/java/nextgen/controller/AppController.java:
--------------------------------------------------------------------------------
1 | package nextgen.controller;
2 |
3 | import java.util.Date;
4 | import java.util.List;
5 |
6 | import javax.servlet.http.HttpSession;
7 |
8 | import org.springframework.beans.factory.annotation.Autowired;
9 | import org.springframework.stereotype.Controller;
10 | import org.springframework.ui.Model;
11 | import org.springframework.web.bind.annotation.GetMapping;
12 | import org.springframework.web.bind.annotation.ModelAttribute;
13 | import org.springframework.web.bind.annotation.PathVariable;
14 | import org.springframework.web.bind.annotation.PostMapping;
15 |
16 | import nextgen.model.Customer;
17 | import nextgen.model.Movie;
18 | import nextgen.model.Rental;
19 | import nextgen.repo.CustomerRepo;
20 | import nextgen.repo.MovieRepo;
21 | import nextgen.repo.RentalRepo;
22 |
23 | @Controller
24 | public class AppController {
25 |
26 | @Autowired
27 | CustomerRepo customerRepo;
28 |
29 | @Autowired
30 | MovieRepo movieRepo;
31 |
32 | @Autowired
33 | RentalRepo rentalRepo;
34 |
35 |
36 | @GetMapping("/")
37 | public String main(Model model) {
38 | model.addAttribute("movies",movieRepo.findAll());
39 | return "index";
40 | }
41 |
42 | @GetMapping("/rent/{id}")
43 | public String rent(HttpSession session,Model model,@PathVariable("id") Long id) {
44 | Rental rental = new Rental();
45 | Customer customer = (Customer) session.getAttribute("customer");
46 |
47 | rental.setStartDate(new Date());
48 | rental.setRentalDuration(7);
49 | Movie movie = movieRepo.findById(id).get();
50 | rental.setCustomer(customer);
51 | rental.setMovie(movie);
52 | rentalRepo.save(rental);
53 | model.addAttribute("rentals", rentalRepo.findByCustomerId(customer.getId()));
54 | return "rented";
55 |
56 | }
57 |
58 | @GetMapping("/rent")
59 | public String rentHistory(HttpSession session,Model model) {
60 |
61 | Customer customer = (Customer) session.getAttribute("customer");
62 |
63 |
64 | model.addAttribute("rentals", rentalRepo.findByCustomerId(customer.getId()));
65 |
66 |
67 | return "rented";
68 |
69 | }
70 |
71 | @GetMapping("/login")
72 | public String login(HttpSession session,Model model) {
73 | if (session.getAttribute("customer") == null) {
74 | System.out.println("not logged in");
75 | model.addAttribute("customer",new Customer());
76 | }
77 | else
78 | {
79 | System.out.println("logged in as " + session.getAttribute("customer"));
80 | }
81 | return "login";
82 | }
83 |
84 | @PostMapping("/login")
85 | public String loginSubmit(HttpSession session,@ModelAttribute(value="customer")Customer customerInput) {
86 |
87 | Customer c = customerRepo.findByFirstName(customerInput.getFirstName());
88 | if (c != null) {
89 | session.setAttribute("customer", c);
90 | }
91 |
92 | return "login";
93 | }
94 |
95 | @GetMapping("/logout")
96 | private String logout(HttpSession session) {
97 |
98 | session.invalidate();
99 |
100 | return "logout";
101 | }
102 |
103 | }
104 |
--------------------------------------------------------------------------------
/rental-service/src/main/java/nextgen/model/AbstractBaseEntity.java:
--------------------------------------------------------------------------------
1 | package nextgen.model;
2 |
3 | import java.io.Serializable;
4 |
5 | import javax.persistence.GeneratedValue;
6 | import javax.persistence.GenerationType;
7 | import javax.persistence.Id;
8 | import javax.persistence.MappedSuperclass;
9 |
10 | @MappedSuperclass
11 | public abstract class AbstractBaseEntity implements Serializable {
12 |
13 | /**
14 | *
15 | */
16 | private static final long serialVersionUID = 1L;
17 |
18 | @Id @GeneratedValue(strategy=GenerationType.IDENTITY)
19 | protected Long id;
20 |
21 |
22 |
23 |
24 | public Long getId() {
25 | return id;
26 | }
27 |
28 |
29 | public void setId(Long id) {
30 | this.id = id;
31 | }
32 |
33 |
34 |
35 |
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/rental-service/src/main/java/nextgen/model/Customer.java:
--------------------------------------------------------------------------------
1 | package nextgen.model;
2 |
3 | import java.util.Set;
4 |
5 | import javax.persistence.Entity;
6 | import javax.persistence.ManyToOne;
7 | import javax.persistence.OneToMany;
8 |
9 | import com.fasterxml.jackson.annotation.JsonBackReference;
10 | import com.fasterxml.jackson.annotation.JsonManagedReference;
11 |
12 | @Entity
13 | public class Customer extends AbstractBaseEntity {
14 |
15 | /**
16 | *
17 | */
18 | private static final long serialVersionUID = 1L;
19 |
20 | private String firstName;
21 | private String lastName;
22 | private String twitterHandle;
23 |
24 | @OneToMany(mappedBy="customer")
25 | @JsonBackReference
26 | private Set Rent any movie, especially Chuck Norris movies
23 |
24 |
28 |
29 |
30 | Welcome to the rental-service interface
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/rental-service/src/main/resources/static/video.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lbroudoux/chuck-norris-streams/cd0b44020521365f21b6173d4168fa1e332d2703/rental-service/src/main/resources/static/video.png
--------------------------------------------------------------------------------
/rental-service/src/main/resources/templates/fragments/header.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
18 |
19 |
--------------------------------------------------------------------------------
/rental-service/src/main/resources/templates/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
22 |
Chuck Movie Rentals
26 | Movie library
32 | Login using your name
22 | You have been logged out
20 | Rented movies
20 |
26 |