Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add subwayticket demo #226

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions end-to-end-applications/java/transport_fare/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Compiled class file
*.class

# Log file
*.log

# BlueJ files
*.ctxt

# Mobile Tools for Java (J2ME)
.mtj.tmp/

# Package Files #
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*

# Ignore Gradle project-specific cache directory
.gradle

# Ignore Gradle build output directory
build

.idea
*.iml

# Unignore the gradle wrapper
!gradle/wrapper/gradle-wrapper.jar
24 changes: 24 additions & 0 deletions end-to-end-applications/java/transport_fare/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Hello world - Java HTTP example


### Add Kafka subscription

```shell
curl localhost:9070/subscriptions --json '{
"source": "kafka://my-cluster/badgein",
"sink": "service://CardTracker/badgeIn",
"options": {"auto.offset.reset": "latest"}
}'

curl localhost:9070/subscriptions --json '{
"source": "kafka://my-cluster/badgeout",
"sink": "service://CardTracker/badgeOut",
"options": {"auto.offset.reset": "latest"}
}'
```

```shell
echo 'card-321:"Liverpool Street"' | kafka-console-producer --bootstrap-server localhost:9092 --topic badgein --property "parse.key=true" --property "key.separator=:"

echo 'card-31:"Baker Street"' | kafka-console-producer --bootstrap-server localhost:9092 --topic badgeout --property "parse.key=true" --property "key.separator=:"
```
30 changes: 30 additions & 0 deletions end-to-end-applications/java/transport_fare/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import java.net.URI

plugins {
java
application
}

repositories {
mavenCentral()
}

val restateVersion = "1.1.0"

dependencies {
annotationProcessor("dev.restate:sdk-api-gen:$restateVersion")

// Restate SDK
implementation("dev.restate:sdk-api:$restateVersion")
implementation("dev.restate:sdk-http-vertx:$restateVersion")
// To use Jackson to read/write state entries (optional)
implementation("dev.restate:sdk-serde-jackson:$restateVersion")

// Logging (optional)
implementation("org.apache.logging.log4j:log4j-core:2.20.0")
}

// Set main class
application {
mainClass.set("my.example.Greeter")
}
55 changes: 55 additions & 0 deletions end-to-end-applications/java/transport_fare/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
version: '3'
services:
broker:
image: confluentinc/cp-kafka:7.5.0
container_name: broker
ports:
- "9092:9092"
- "9101:9101"
environment:
KAFKA_BROKER_ID: 1
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: CONTROLLER:PLAINTEXT,PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://broker:29092,PLAINTEXT_HOST://localhost:9092
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
KAFKA_GROUP_INITIAL_REBALANCE_DELAY_MS: 0
KAFKA_TRANSACTION_STATE_LOG_MIN_ISR: 1
KAFKA_TRANSACTION_STATE_LOG_REPLICATION_FACTOR: 1
KAFKA_PROCESS_ROLES: broker,controller
KAFKA_NODE_ID: 1
KAFKA_CONTROLLER_QUORUM_VOTERS: 1@broker:29093
KAFKA_LISTENERS: PLAINTEXT://broker:29092,CONTROLLER://broker:29093,PLAINTEXT_HOST://0.0.0.0:9092
KAFKA_INTER_BROKER_LISTENER_NAME: PLAINTEXT
KAFKA_CONTROLLER_LISTENER_NAMES: CONTROLLER
KAFKA_LOG_DIRS: /tmp/kraft-combined-logs
CLUSTER_ID: MkU3OEVBNTcwNTJENDM2Qk

init-kafka:
image: confluentinc/cp-kafka:7.5.0
depends_on:
- broker
entrypoint: [ '/bin/sh', '-c' ]
command: |
"
# blocks until kafka is reachable
kafka-topics --bootstrap-server broker:29092 --list
echo -e 'Creating kafka topics'
kafka-topics --bootstrap-server broker:29092 --create --if-not-exists --topic badgein --replication-factor 1 --partitions 1
kafka-topics --bootstrap-server broker:29092 --create --if-not-exists --topic badgeout --replication-factor 1 --partitions 1

echo -e 'Successfully created the following topics:'
kafka-topics --bootstrap-server broker:29092 --list
"

# rest-proxy:
# image: confluentinc/cp-kafka-rest:7.5.0
# ports:
# - 8088:8088
# hostname: rest-proxy
# container_name: rest-proxy
# environment:
# KAFKA_REST_HOST_NAME: rest-proxy
# KAFKA_REST_LISTENERS: "http://0.0.0.0:8088"
# KAFKA_REST_BOOTSTRAP_SERVERS: "broker:29092"
# KAFKA_REST_ACCESS_CONTROL_ALLOW_ORIGIN: "*"
# KAFKA_REST_ACCESS_CONTROL_ALLOW_METHODS: "OPTIONS,GET,POST,PUT,DELETE"
# KAFKA_REST_ACCESS_CONTROL_ALLOW_HEADERS: "origin,content-type,accept,authorization"
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading
Loading