Skip to content

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). This POC was featured on #WeAreDevelopers World Congress 2024.

Notifications You must be signed in to change notification settings

thriving-dev/social-platform-feed-reactive-cassandra

Repository files navigation

social-platform-feed-reactive-cassandra

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

Perf Sneak Peak - OTEL Trace

Screenshot of an OpenTelemetry Trace of the main GET feeds/{feedId}/posts endpoint, showing parallel queries to Cassandra and a total response time of 3.72ms

Tech Stack

Quick Start

Docker Compose

Start/Stop

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

Open CQLSH (shell)

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.

Running the app

To run the quarkus app in dev mode, simply run

./gradlew quarkusDev

Accessing the API

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&ltPostId=01HZMN4H77QBW1W8PS6W04ZH9V'
curl -X GET 'http://localhost:8080/feeds/01HPWG2T821KXLA7TECS8W74W6/posts/count'
curl -X GET 'http://localhost:8080/users/01HPWGWY9C0K2YH7PZGC4XSBHZ'

Run with the OpenTelemetry javaagent

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)

Quarkus Project

Created with

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'

Running the application in dev mode

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/.

Packaging and running the application

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.

Creating a native executable

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.

Related Guides

  • 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

Provided Code

RESTEasy JAX-RS

Easily start your RESTful Web Services

Related guide section...

RESTEasy Reactive

Easily start your Reactive RESTful Web Services

Related guide section...

About

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). This POC was featured on #WeAreDevelopers World Congress 2024.

Topics

Resources

Stars

Watchers

Forks