Not supported by Lightbend in any conceivable way, not open for contributions.
- Java 11 or later
- Apache Maven 3.6 or higher
- Kalix:
- Docker 20.10.8 or higher (engine and client)
- Docker Hub account (configured with Docker)
Access to thegcr.io/kalix-public
container registry
cURL
IDE / editor
mvn archetype:generate \
-DarchetypeGroupId=io.kalix \
-DarchetypeArtifactId=kalix-maven-archetype \
-DarchetypeVersion=LATEST
Define value for property 'groupId': com.example
Define value for property 'artifactId': digitaltwin
Define value for property 'version' 1.0-SNAPSHOT: :
Define value for property 'package' com.example: : com.example.digitaltwin
Delete:
src/main/proto/com/example/shoppingcart/counter_api.proto
src/main/proto/com/example/shoppingcart/domain/counter_domain.proto
Note: For code snippet insertion use command+J (MAC)
- Create file
digitaltwin_api.proto
insrc/main/proto/com/example/digitaltwin
folder. - Edit
src/main/proto/com/example/digitaltwin/digitaltwin_api.proto
in IDE - Insert header snippet:
aheader
- Insert commands snippet:
acmd
- Insert state snippet:
astate
- Insert service snippet:
asrv
- Add functions to service snippet (place cursor inside brackets
service DigitalTwinService { }
):afunc
- Create file
digitaltwin_domain.proto
insrc/main/proto/com/example/digitaltwin/domain
folder. - Edit
src/main/proto/com/example/digitaltwin/domain/digitaltwin_domain.proto
in IDE - Insert header snippet:
dheader
- Insert events snippet:
devts
- Insert state snippet:
dstate
- Edit
src/main/proto/com/example/digitaltwin/digitaltwin_api.proto
- Insert codegen annotations (place cursor under
service DigitalTwinService {
):acodegen
- Code generation (terminal):
mvn compile
- Refresh project (IDE)
- Trigger Maven sync (IDE)
- Edit
src/main/java/com/example/digitaltwin/domain/DigitalTwin
class - Delete class body
- Insert code snippet (delete everything under constructor):
eall
- Edit
src/test/java/com/example/digitaltwin/domain/DigitalTwinTest
class - Delete class body
- Insert code snippet (delete everything under constructor):
ut
mvn test
- Edit
src/it/java/com/example/digitaltwin/DigitalTwinIntegrationTest
class - Delete everything under the constructor
- Insert code snippet (delete everything under constructor):
it
mvn -Pit verify
??
- Edit
pom.xml
and updatemy-docker-repo
in<dockerImage>my-docker-repo/${project.artifactId}</dockerImage>
- Execute in terminal:
mvn deploy
kalix services expose digitaltwin
Service 'digitaltwin' was successfully exposed at: winter-bonus-0316.eu-central-1.kalix.app
Note: HOSTNAME to use for external access
- Create digital twin
curl -XPOST -d '{
"name": "DT1",
"metric_value_alert_threshold": "10"
}' https://winter-bonus-0316.eu-central-1.kalix.app/digitaltwin/1/create -H "Content-Type: application/json"
- Add OK metric
curl -XPOST -d '{
"metric_value": "5"
}' https://winter-bonus-0316.eu-central-1.kalix.app/digitaltwin/1/add-metric -H "Content-Type: application/json"
- Get cart
curl -XGET https://winter-bonus-0316.eu-central-1.kalix.app/digitaltwin/1 -H "Content-Type: application/json"
- Add ALERT metric
curl -XPOST -d '{
"metric_value": "11"
}' https://winter-bonus-0316.eu-central-1.kalix.app/digitaltwin/1/add-metric -H "Content-Type: application/json"
- Get cart
curl -XGET https://winter-bonus-0316.eu-central-1.kalix.app/digitaltwin/1 -H "Content-Type: application/json"
-
Create file
digitaltwin_topic.proto
insrc/main/proto/com/example/digitaltwin
folder. -
Edit
src/main/proto/com/example/digitaltwin/digitaltwin_topic.proto
in IDE -
Insert header snippet:
theader
-
Insert events snippet:
tevts
-
Insert service snippet:
tsrv
-
Code generation (terminal):
mvn compile
- Refresh project (IDE)
- Trigger Maven sync (IDE)
- Edit
src/main/java/com/example/digitaltwin/DigitalTwinToTopicAction
class - Delete class body
- Insert code snippet (delete everything under constructor):
tall
mvn archetype:generate \
-DarchetypeGroupId=io.kalix \
-DarchetypeArtifactId=kalix-maven-archetype \
-DarchetypeVersion=LATEST
com.example
digitaltwin
com.example.digitaltwin
digitaltwin_api.proto
digitaltwin_domain.proto
mvn compile
mvn test
mvn -Pit verify
mvn deploy
curl -XPOST -d '{
"name": "DT1",
"metric_value_alert_threshold": "10"
}' https://winter-bonus-0316.eu-central-1.kalix.app/digitaltwin/1/create -H "Content-Type: application/json"
curl -XPOST -d '{
"metric_value": "5"
}' https://winter-bonus-0316.eu-central-1.kalix.app/digitaltwin/1/add-metric -H "Content-Type: application/json"
curl -XGET https://winter-bonus-0316.eu-central-1.kalix.app/digitaltwin/1 -H "Content-Type: application/json"
curl -XPOST -d '{
"metric_value": "11"
}' https://winter-bonus-0316.eu-central-1.kalix.app/digitaltwin/1/add-metric -H "Content-Type: application/json"
digitaltwin_topic.proto