POC Implementation of a social platform feed backend, with an RESTful API.
Built with reacting programming using Kotlin, Quarkus and Mutiny, with ScyllaDB as the database (Apache Cassandra Protocol).
Code from this repository was featured on WeAreDevelopers World Congress 2024.
You can find more information on: https://thriving.dev/talks/maximising-cassandras-potential-2024
- Kotlin
- Quarkus
- SmallRye Mutiny (Reactive Programming)
- Apache Cassandra / ScyllaDB
- OpenTelemetry
- Docker Compose Stack with
- ScyllaDB 6 / Apache Cassandra 5
(incl. CQL schema + sampledata auto-loaded) - Jaeger & OpenTelemetry
- https://quarkus.io/extensions/io.quarkus/quarkus-opentelemetry/
- https://quarkus.io/guides/opentelemetry
- ScyllaDB 6 / Apache Cassandra 5
To start the docker compose stack locally, run
docker compose up -d
#docker compose -f docker-compose.cassandra.yml up -d
To tear down
docker compose down
#docker compose -f docker-compose.cassandra.yml down
When the compose stack is running, you can open a CQL shell via
docker exec -it scylla cqlsh -k poc
#docker exec -it cassandra cqlsh -k poc
You can find the schema, sampledata and all queries featured in the talk in the folder ./cql.
To run the quarkus app in dev mode, simply run
./gradlew quarkusDev
The app webserver is listening on port 8080
.
Here are a few sample curl
to get you started...
curl -X GET 'http://localhost:8080/feeds/01HPWG2T821KXLA7TECS8W74W6'
curl -X GET 'http://localhost:8080/feeds/01HPWG2T821KXLA7TECS8W74W6/posts?pageSize=20<PostId=01HZMN4H77QBW1W8PS6W04ZH9V'
curl -X GET 'http://localhost:8080/feeds/01HPWG2T821KXLA7TECS8W74W6/posts/count'
curl -X GET 'http://localhost:8080/users/01HPWGWY9C0K2YH7PZGC4XSBHZ'
To start the app with the opentelemetry-javaagent to push traces to Jaeger a script has been prepared:
./dev_otel.sh
You should be able to access Jaeger under: http://localhost:16686/search?limit=200&lookback=24h&service=social-platform-feed-poc
When the API is being used, traces shoudl start to show up (pushed every ~30s)
This project uses Quarkus, the Supersonic Subatomic Java Framework.
If you want to learn more about Quarkus, please visit its website: https://quarkus.io/ .
quarkus create app dev.thriving.poc:social-platform-feed-reactive-cassandra:0.0.1 \
--kotlin --gradle-kotlin-dsl \
--package-name=dev.thriving.poc.social.platform.feed.backend \
--extension='kotlin,com.datastax.oss.quarkus:cassandra-quarkus-client,io.quarkus:quarkus-mutiny,io.quarkus:quarkus-resteasy-reactive-kotlin-serialization'
You can run your application in dev mode that enables live coding using:
./gradlew quarkusDev
NOTE: Quarkus now ships with a Dev UI, which is available in dev mode only at http://localhost:8080/q/dev/.
The application can be packaged using:
./gradlew build
It produces the quarkus-run.jar
file in the build/quarkus-app/
directory.
Be aware that it’s not an über-jar as the dependencies are copied into the build/quarkus-app/lib/
directory.
The application is now runnable using java -jar build/quarkus-app/quarkus-run.jar
.
If you want to build an über-jar, execute the following command:
./gradlew build -Dquarkus.package.type=uber-jar
The application, packaged as an über-jar, is now runnable using java -jar build/*-runner.jar
.
You can create a native executable using:
./gradlew build -Dquarkus.package.type=native
Or, if you don't have GraalVM installed, you can run the native executable build in a container using:
./gradlew build -Dquarkus.package.type=native -Dquarkus.native.container-build=true
You can then execute your native executable with: ./build/social-platform-feed-reactive-cassandra-0.0.1-runner
If you want to learn more about building native executables, please consult https://quarkus.io/guides/gradle-tooling.
- Mutiny (guide): Write reactive applications with the modern Reactive Programming library Mutiny
- DataStax Apache Cassandra client (guide): Connect to Apache Cassandra, DataStax Enterprise and DataStax Astra databases
- RESTEasy Classic Mutiny (guide): Mutiny support for RESTEasy Classic server
- Kotlin (guide): Write your services in Kotlin
Easily start your RESTful Web Services
Easily start your Reactive RESTful Web Services