While designing your service it is useful to read designing services
This project has a bare-bones skeleton service ready to go, but in order to adapt and extend it, it may be useful to read up on developing services and in particular the Java section
You can use Maven to build your project, which will also take care of
generating code based on the .proto
definitions:
mvn compile
In order to run your application locally, you must run the Kalix proxy. The included docker-compose
file contains the configuration required to run the proxy for a locally running application.
It also contains the configuration to start a local Google Pub/Sub emulator that the Kalix proxy will connect to.
To start the proxy, run the following command from this directory:
docker-compose up
To start the application locally, the exec-maven-plugin
is used. Use the following command:
mvn compile exec:exec
With both the proxy and your application running, any defined endpoints should be available at http://localhost:9000
. In addition to the defined gRPC interface, each method has a corresponding HTTP endpoint. Unless configured otherwise (see Transcoding HTTP), this endpoint accepts POST requests at the path /[package].[entity name]/[method]
. For example, using curl
:
> curl -XPOST -H "Content-Type: application/json" localhost:9000/com.example.UserService/Create -d '{ "userId: "uesr1", "fullName": "John Doe", "email": "john@example.com", "handle: "john" }'
The command handler for `GetCurrentCounter` is not implemented, yet
For example, using grpcurl
:
grpcurl -plaintext -d '{ "fullName": "John Doe", "email": "john.doe@example.com", "handle": "john" }' localhost:9000 com.example.api.UserAction/Create
> grpcurl -plaintext -d '{ "userId": "user-1"}' localhost:9000 com.example.user.UserService/Get
> grpcurl -plaintext -d '{ "userId": "user-1", "newHandle": "john.doe" }' localhost:9000 com.example.user.UserService/ChangeHandle
To deploy your service, install the kalix
CLI as documented in
Setting up a local development environment
and configure a Docker Registry to upload your docker image to.
You will need to update the dockerImage
property in the pom.xml
and refer to
Configuring registries
for more information on how to make your docker image available to Kalix.
Finally, you use the kalix
CLI to create a project as described in Create a new Project. Once you have a project you can deploy your service into the project either
by using mvn deploy
which will also conveniently package and publish your docker image prior to deployment,
or by first packaging and publishing the docker image through mvn clean package docker:push -DskipTests
and
then deploying the image through the kalix
CLI.