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': shoppingcart
Define value for property 'version' 1.0-SNAPSHOT: :
Define value for property 'package' com.example: : com.example.shoppingcart
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
shoppingcart_api.proto
insrc/main/proto/com/example/shoppingcart
folder. - Edit
src/main/proto/com/example/shoppingcart/shoppingcart_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 ShoppingCartService { }
):afunc
- Create file
shoppingcart_domain.proto
insrc/main/proto/com/example/shoppingcart/domain
folder. - Edit
src/main/proto/com/example/shoppingcart/domain/shoppingcart_domain.proto
in IDE - Insert header snippet:
dheader
- Insert events snippet:
devts
- Insert state snippet:
dstate
- Edit
src/main/proto/com/example/shoppingcart/shoppingcart_api.proto
- Insert codegen annotations (place cursor under
service ShoppingCartService {
):acodegen
- Code generation (terminal):
mvn compile
- Refresh project (IDE)
- Trigger Maven sync (IDE)
- Edit
src/main/java/com/example/shoppingcart/domain/ShoppingCart
class - Delete class body
- Insert help methods snippet:
ehelp
- Implement
addItem
command handler method- Delete method implementation
- Insert snippet:
ecadd
- Implement
removeItem
command handler method- Delete method implementation
- Insert snippet:
ecremove
- Implement
removeItem
command handler method- Delete method implementation
- Insert snippet:
ecremove
- Implement
itemAdded
event handler method- Delete method implementation
- Insert snippet:
eeadded
- Implement
itemRemoved
event handler method- Delete method implementation
- Insert snippet:
eeremoved
- Edit
src/test/java/com/example/shoppingcart/domain/ShoppingCartTest
class - Delete class body
- Insert code snippet:
ut
mvn test
- Edit
src/it/java/com/example/shoppingcart/ShoppingCartTest
class - Delete everything under the constructor
- Insert code snippet:
it
mvn -Pit verify
??
- Edit
pom.xml
and updatemy-docker-repo
in<dockerImage>my-docker-repo/${project.artifactId}</dockerImage>
- Execute in terminal:
mvn package docker:push
- Deploy project:
kalix service deploy shoppingcart aklikic/shoppingcart:1.0-SNAPSHOT
Note: replace aklikic
as in Package
2. Expose service:
kalix services expose shoppingcart
- List routes:
kalix routes list
NAME HOSTNAME PATHS CORS ENABLED STATUS
shoppingcart black-hill-1471.us-east1.kalix.app /->shoppingcart false NotConfigured
Note: HOSTNAME is dedicated hostname for this service and is publicly accessible on Internet
- Add item to cart
curl -XPOST -d '{
"product_id": "idA",
"name": "apples",
"quantity": "1"
}' https://black-hill-1471.us-east1.kalix.app/cart/1/items/add -H "Content-Type: application/json"
Note: For dev
environment use host: black-hill-1471.us-east1.kalix.app
2. Get cart
curl -XGET https://black-hill-1471.us-east1.kalix.app/carts/1 -H "Content-Type: application/json"
-
Create file
shoppingcart_topic.proto
insrc/main/proto/com/example/shoppingcart
folder. -
Edit
src/main/proto/com/example/shoppingcart/shoppingcart_topic.proto
in IDE -
Insert header snippet:
dheader
-
Insert events snippet:
devts
-
Insert service snippet:
dsrv
-
Insert functions snippet (place cursor inside brackets
service ShoppingCartToTopic { }
):dfunc
-
Insert codegen snippet (place cursor inside brackets
service ShoppingCartToTopic { }
):dcodegen
-
Code generation (terminal):
mvn compile
- Refresh project (IDE)
- Trigger Maven sync (IDE)
- Edit
src/main/java/com/example/shoppingcart/ShoppingCartToTopicAction
class - Delete class body
- Insert code snippet:
hall
mvn archetype:generate \
-DarchetypeGroupId=io.kalix \
-DarchetypeArtifactId=kalix-maven-archetype \
-DarchetypeVersion=LATEST
com.example
shoppingcart
com.example.shoppingcart
shoppingcart_api.proto
shoppingcart_domain.proto
mvn compile
mvn test
mvn -Pit verify
mvn deploy
curl -XPOST -d '{
"product_id": "idA",
"name": "apples",
"quantity": "1"
}' https://black-hill-1471.us-east1.kalix.app/cart/1/items/add -H "Content-Type: application/json"
curl -XGET https://black-hill-1471.us-east1.kalix.app/carts/1 -H "Content-Type: application/json"
shoppingcart_topic.proto