Skip to content

Commit 1f9e8fc

Browse files
committed
update README, simplified start from cli
1 parent 3d5fa98 commit 1f9e8fc

File tree

5 files changed

+101
-8
lines changed

5 files changed

+101
-8
lines changed

README.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,19 @@ Down below is an exhaustive list of all the sample:
2121
4. [Reset Handler](reset-handler/README.md) - Sample showing how to reset a `StreamingEventProcessor`.
2222
5. [Saga - No TOAST in PostgreSQL](saga/README.md) - Sample showing a basis Saga, that's stored in a PostgreSQL
2323
without [TOAST](https://wiki.postgresql.org/wiki/TOAST).
24-
6. [Sequencing Policy](sequencing-policy/README.md) - Sample showing how to set up a custom `SequencingPolicy` to adjust
24+
6. [Serialization Avro](serialization-avro/README.md) - Sample showing usage of Apache Avro Commands/Events/Queries.
25+
7. [Sequencing Policy](sequencing-policy/README.md) - Sample showing how to set up a custom `SequencingPolicy` to adjust
2526
the event sequence for a `StreamingEventProcessor`.
26-
7. [Set-Based Validation](set-based-validation/README.md) - Sample showing several approaches to implement set-based
27+
8. [Set-Based Validation](set-based-validation/README.md) - Sample showing several approaches to implement set-based
2728
validation.
28-
8. [Set-Based Validation - Actor Model](set-based-validation-actor-model/README.md) - Sample showing how to implement
29+
9. [Set-Based Validation - Actor Model](set-based-validation-actor-model/README.md) - Sample showing how to implement
2930
set-based validation through a dedicated aggregate instance.
30-
9. [Snapshots](snapshots/README.md) - Sample showing how to configure aggregate snapshotting.
31-
10. [Stateful Event Handler](stateful-event-handler/README.md) - Sample showing a stateful event handler that can be
31+
10. [Snapshots](snapshots/README.md) - Sample showing how to configure aggregate snapshotting.
32+
11. [Stateful Event Handler](stateful-event-handler/README.md) - Sample showing a stateful event handler that can be
3233
used as a replacement for sagas.
33-
11. [Subscription Query - REST](subscription-query-rest/README.md) - Sample showing how to use Axon's subscription query
34+
12. [Subscription Query - REST](subscription-query-rest/README.md) - Sample showing how to use Axon's subscription query
3435
cleanly in a REST-based controller.
35-
12. [Subscription Query - Streaming](subscription-query-streaming/README.md) - Sample showing how to use Axon's
36+
13. [Subscription Query - Streaming](subscription-query-streaming/README.md) - Sample showing how to use Axon's
3637
subscription query cleanly in a streaming-based controller.
37-
13. [Upcasters](upcaster/README.md) - Sample showing several implementations of upcasters.
38+
14. [Upcasters](upcaster/README.md) - Sample showing several implementations of upcasters.
3839

serialization-avro/README.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# Serialization with Apache Avro
2+
3+
This sample demonstrates usage of Apache Avro for messaging and storage of events inside AxonServer.
4+
For commands, events and queries and query responses the Avro schema definitions are provided and are located
5+
in `src/main/avro` directory.
6+
7+
Here is an example for `CardIssuedEvent` event:
8+
9+
```avroschema
10+
{
11+
"type": "record",
12+
"namespace": "io.axoniq.dev.samples.serializationavro.api",
13+
"name": "CardIssuedEvent",
14+
"doc": "A new gift card is issued.",
15+
"revision": "1",
16+
"javaAnnotation": "org.axonframework.serialization.Revision(\"1\")",
17+
"fields": [
18+
{
19+
"name": "id",
20+
"type": "string"
21+
},
22+
{
23+
"name": "amount",
24+
"type": "int"
25+
}
26+
]
27+
}
28+
```
29+
30+
Using the `avro-maven-plugin`, the Java classes are generated into `target/generated-sources/avro` directory
31+
during the `generate-sources` build phase.
32+
33+
The remaining part of the application is a standard implementation of a gift card application, that uses the
34+
`AvroSerializer` by applying configuration of the serializer using application properties.
35+
36+
```yaml
37+
38+
axon:
39+
serializer:
40+
events: avro
41+
messages: avro
42+
general: jackson
43+
44+
```
45+
46+
## Running example
47+
48+
To run the example, build it using Apache Maven by running `./mvnw clean install` and then execute the following
49+
command from your command line: `./mvnw -Prun -f serialization-avro`.
50+
If you want to run it from your IDEA IntelliJ, just start the:
51+
52+
`SerializationAvroApplication`
53+
54+
Inspect the `serialization-avro/requests.http` and run the script to exchange some messages. If you want to inspect
55+
the events stored in the AxonServer, please open the AxonServer Dashboard http://localhost:8024/.
56+
57+

serialization-avro/pom.xml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@
125125
</dependencies>
126126

127127
<build>
128+
<defaultGoal>clean install</defaultGoal>
128129
<pluginManagement>
129130
<plugins>
130131
<plugin>
@@ -178,4 +179,30 @@
178179
</plugin>
179180
</plugins>
180181
</build>
182+
<profiles>
183+
<profile>
184+
<id>run</id>
185+
<build>
186+
<plugins>
187+
<plugin>
188+
<groupId>org.springframework.boot</groupId>
189+
<artifactId>spring-boot-maven-plugin</artifactId>
190+
<version>${spring-boot.version}</version>
191+
<executions>
192+
<execution>
193+
<goals>
194+
<goal>run</goal>
195+
</goals>
196+
<configuration>
197+
<environmentVariables>
198+
<SPRING_DOCKER_COMPOSE_FILE>docker-compose.yml</SPRING_DOCKER_COMPOSE_FILE>
199+
</environmentVariables>
200+
</configuration>
201+
</execution>
202+
</executions>
203+
</plugin>
204+
</plugins>
205+
</build>
206+
</profile>
207+
</profiles>
181208
</project>

serialization-avro/src/main/java/io/axoniq/dev/samples/serializationavro/SerializationAvroApplication.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import org.springframework.boot.SpringApplication;
1414
import org.springframework.boot.autoconfigure.SpringBootApplication;
1515
import org.springframework.context.annotation.Bean;
16+
import org.springframework.context.annotation.Profile;
1617

1718
@SpringBootApplication
1819
@AvroSchemaScan
@@ -23,6 +24,7 @@ public static void main(String[] args) {
2324
SpringApplication.run(SerializationAvroApplication.class, args);
2425
}
2526

27+
@Profile("manualSchemaStore")
2628
@Bean("defaultAxonSchemaStore")
2729
public SchemaStore defaultAxonSchemaStore() {
2830
var cache = new SchemaStore.Cache();
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
------------------------------------------------------------------------------------------------------------------------
2+
Gift card sample application using Apache Avro Serialization for messages and events
3+
4+
powered by SpringBoot ${spring-boot.version}
5+
running on http://localhost:${server.port}
6+
------------------------------------------------------------------------------------------------------------------------

0 commit comments

Comments
 (0)