Skip to content

Commit

Permalink
Add Quarkus sample demo
Browse files Browse the repository at this point in the history
  • Loading branch information
christophd committed Nov 3, 2023
1 parent cb18802 commit 2eb7d86
Show file tree
Hide file tree
Showing 27 changed files with 2,263 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ jobs:
./mvnw --no-transfer-progress -pl :citrus-sample-todo install
- name: Run Demos
run: |
./mvnw --no-transfer-progress install -Dsystem.under.test.mode=embedded -f demo/sample-quarkus
./mvnw --no-transfer-progress install -Dsystem.under.test.mode=embedded -f demo/sample-bakery
./mvnw --no-transfer-progress install -Dsystem.under.test.mode=embedded -f demo/sample-bookstore
./mvnw --no-transfer-progress install -Dsystem.under.test.mode=embedded -f demo/sample-flightbooking
Expand Down
1 change: 1 addition & 0 deletions demo/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<packaging>pom</packaging>

<modules>
<module>sample-quarkus</module>
<module>sample-bakery</module>
<module>sample-flightbooking</module>
<module>sample-greeting</module>
Expand Down
97 changes: 97 additions & 0 deletions demo/sample-quarkus/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
# Citrus Quarkus Demo

This project uses Quarkus to implement a sample event-driven application.
The project uses the Quarkus test framework to set up a dev services environment with JUnit Jupiter where the application is running on the localhost.
The Quarkus dev services capabilities include starting Testcontainers automatically during the test in order to simulate the surrounding infrastructure
(PostgreSQL database and the Kafka message broker).

If you want to learn more about Quarkus, please visit its website: https://quarkus.io/ .

The Quarkus demo application is a food market event-driven application that listens for incoming events of type `booking` and `supply`.

![Food Market App](food-market-app-demo.png)

Users are able to place a booking event that references a product and gives an amount as well as an accepted price.
At the same time suppliers may add their individual supply events again referencing a product with an amount and a selling price.

As soon as bookings and supplies do match in all criteria the food market application will produce booking-completed and shipping events.

All events are produced and consumed with Kafka event streams.
Bookings and supplies with their individual status are stored in a PostgreSQL database.

## Running the application in dev mode

You can run your application in dev mode that enables live coding using:
```shell script
./mvnw compile quarkus:dev
```

> **_NOTE:_** Quarkus now ships with a Dev UI, which is available in dev mode only at http://localhost:8080/q/dev/.
## Running the Citrus tests

Quarkus test is using JUnit Jupiter as a test driver.
This means you can run the tests just like any other JUnit test (e.g. from your Java IDE, with Maven).

The Citrus tst capabilities are added on top of `@QuarkusTest` so you will not need any other commands to run the tests.

## Packaging and running the application

The application can be packaged using:
```shell script
./mvnw package
```
It produces the `quarkus-run.jar` file in the `target/quarkus-app/` directory.
Be aware that it’s not an _über-jar_ as the dependencies are copied into the `target/quarkus-app/lib/` directory.

The application is now runnable using `java -jar target/quarkus-app/quarkus-run.jar`.

If you want to build an _über-jar_, execute the following command:
```shell script
./mvnw package -Dquarkus.package.type=uber-jar
```

The application, packaged as an _über-jar_, is now runnable using `java -jar target/*-runner.jar`.

## Creating a native executable

You can create a native executable using:
```shell script
./mvnw package -Dnative
```

Or, if you don't have GraalVM installed, you can run the native executable build in a container using:
```shell script
./mvnw package -Dnative -Dquarkus.native.container-build=true
```

You can then execute your native executable with: `./target/kamelets-quarkus-demo-1.0.0-runner`

If you want to learn more about building native executables, please consult https://quarkus.io/guides/maven-tooling.

## Building an image

This is meant to produce a Knative image, to be pushed to quay.io. Update the application.properties to use your own repository.

To build your image, run:
```shell script
./mvnw package -Dquarkus.container-image.build=true
```

You can push your image using:
```shell script
docker push quay.io/{YOUR_USERNAME}/food-market-demo:1.0.0
```

## Related Guides

- SmallRye Reactive Messaging - Kafka Connector ([guide](https://quarkus.io/guides/kafka-reactive-getting-started)): Connect to Kafka with Reactive Messaging
- Apache Kafka Streams ([guide](https://quarkus.io/guides/kafka-streams)): Implement stream processing applications based on Apache Kafka

## Provided Code

### Reactive Messaging codestart

Use SmallRye Reactive Messaging

[Related Apache Kafka guide section...](https://quarkus.io/guides/kafka-reactive-getting-started)
Binary file added demo/sample-quarkus/food-market-app-demo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 2eb7d86

Please sign in to comment.