-
Notifications
You must be signed in to change notification settings - Fork 0
/
pom.xml
180 lines (177 loc) · 9.53 KB
/
pom.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>demo</artifactId>
<groupId>edu.hsh.favs.project.escqrs</groupId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>edu.hsh.favs.project.escqrs.events</groupId>
<artifactId>events</artifactId>
<dependencies>
<dependency>
<groupId>edu.hsh.favs.project.escqrs.domains</groupId>
<artifactId>customers</artifactId>
<version>0.0.1-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>edu.hsh.favs.project.escqrs.domains</groupId>
<artifactId>orders</artifactId>
<version>0.0.1-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.avro</groupId>
<artifactId>avro</artifactId>
<version>${avro.version}</version>
</dependency>
<dependency>
<groupId>org.apache.avro</groupId>
<artifactId>avro-compiler</artifactId>
<version>${avro.version}</version>
</dependency>
<dependency>
<groupId>org.apache.avro</groupId>
<artifactId>avro-maven-plugin</artifactId>
<version>${avro.version}</version>
</dependency>
<dependency>
<groupId>org.apache.avro</groupId>
<artifactId>avro-ipc</artifactId>
<version>${avro.version}</version>
</dependency>
<dependency>
<groupId>io.confluent</groupId>
<artifactId>kafka-schema-registry-maven-plugin</artifactId>
<version>${confluent.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.avro</groupId>
<artifactId>avro-maven-plugin</artifactId>
<version>${avro.version}</version>
<executions>
<execution>
<id>schemas</id>
<phase>generate-sources</phase>
<goals>
<goal>schema</goal>
<goal>protocol</goal>
<goal>idl-protocol</goal>
</goals>
<configuration>
<!-- These need to be excluded as they are union types that are only registered -->
<!-- in order to permit only valid entity events on the Kakfa topics. -->
<!-- The compiler would else try to create classes for these union types. -->
<sourceDirectory>${project.basedir}/src/main/resources/avro</sourceDirectory>
<excludes>
<exclude>CustomerEvents.avsc</exclude>
<exclude>OrderEvents.avsc</exclude>
<exclude>ProductEvents.avsc</exclude>
</excludes>
<outputDirectory>${project.basedir}/src/main/java/</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>io.confluent</groupId>
<artifactId>kafka-schema-registry-maven-plugin</artifactId>
<version>${confluent.version}</version>
<configuration>
<schemaRegistryUrls>
<param>http://schema-registry:8081</param>
</schemaRegistryUrls>
<subjects>
<!-- This defines the possible event types on each Kafka topic -->
<!-- How this works: -->
<!-- There are multiple ways for constraining the event types on a Kafka topic.-->
<!-- Schema-message constraints, Subject-schema constraints, or -->
<!-- Subject-topic constraints. We are going to use the Subject-topic constraint -->
<!-- When using Confluent's (de)serializer for the events on a kafka topic-->
<!-- the default strategy to figure out, which schema is used, is called -->
<!-- `TopicNameStrategy`. This means, that producer/consumer can ask the -->
<!-- schema-registry and based on the Kafka topic's name, they will get -->
<!-- the appropriate schema to use. -->
<!-- The convention here is, that the message value schema, i.e. the payload -->
<!-- in which our event is stored, is registered on the schema-registry as -->
<!-- {topicName}-value. -->
<!-- Therefore, we are going to define Avro union types are schemas for all -->
<!-- our Kafka topics to ensure that only these events can be produced/consumed. -->
<customer-value>src/main/resources/avro/CustomerEvents.avsc</customer-value>
<order-value>src/main/resources/avro/OrderEvents.avsc</order-value>
<product-value>src/main/resources/avro/ProductEvents.avsc</product-value>
<CustomerCreated>src/main/resources/avro/CustomerCreatedEvent.avsc</CustomerCreated>
<CustomerUpdated>src/main/resources/avro/CustomerUpdatedEvent.avsc</CustomerUpdated>
<CustomerDeleted>src/main/resources/avro/CustomerDeletedEvent.avsc</CustomerDeleted>
<OrderPlaced>src/main/resources/avro/OrderPlacedEvent.avsc</OrderPlaced>
<OrderDeleted>src/main/resources/avro/OrderDeletedEvent.avsc</OrderDeleted>
<OrderUpdated>src/main/resources/avro/OrderUpdatedEvent.avsc</OrderUpdated>
<ProductAdded>src/main/resources/avro/ProductAddedEvent.avsc</ProductAdded>
<ProductUpdated>src/main/resources/avro/ProductUpdatedEvent.avsc</ProductUpdated>
</subjects>
<schemaTypes>
<customer-value>AVRO</customer-value>
<order-value>AVRO</order-value>
<CustomerCreated>AVRO</CustomerCreated>
<CustomerDeleted>AVRO</CustomerDeleted>
<CustomerUpdated>AVRO</CustomerUpdated>
<OrderPlaced>AVRO</OrderPlaced>
<OrderDeleted>AVRO</OrderDeleted>
<OrderUpdated>AVRO</OrderUpdated>
<ProductAdded>AVRO</ProductAdded>
<ProductUpdated>AVRO</ProductUpdated>
</schemaTypes>
<references>
<customer-value>
<reference>
<name>edu.hsh.favs.project.escqrs.events.customer.CustomerCreatedEvent</name>
<subject>CustomerCreated</subject>
</reference>
<reference>
<name>edu.hsh.favs.project.escqrs.events.customer.CustomerDeletedEvent</name>
<subject>CustomerDeleted</subject>
</reference>
<reference>
<name>edu.hsh.favs.project.escqrs.events.customer.CustomerUpdatedEvent</name>
<subject>CustomerUpdated</subject>
</reference>
</customer-value>
<order-value>
<reference>
<name>edu.hsh.favs.project.escqrs.events.order.OrderPlacedEvent</name>
<subject>OrderPlaced</subject>
</reference>
<reference>
<name>edu.hsh.favs.project.escqrs.events.order.OrderDeletedEvent</name>
<subject>OrderDeleted</subject>
</reference>
<reference>
<name>edu.hsh.favs.project.escqrs.events.order.OrderUpdatedEvent</name>
<subject>OrderUpdated</subject>
</reference>
</order-value>
<product-value>
<reference>
<name>edu.hsh.favs.project.escqrs.events.product.ProductAddedEvent</name>
<subject>ProductAdded</subject>
</reference>
<reference>
<name>edu.hsh.favs.project.escqrs.events.product.ProductUpdatedEvent</name>
<subject>ProductUpdated</subject>
</reference>
</product-value>
</references>
</configuration>
<goals>
<goal>register</goal>
</goals>
</plugin>
</plugins>
</build>
</project>