The section Build your first application shows how to build this Shopping Cart service step by step.
- An Akka account
- Java 21 installed (recommended: Eclipse Adoptium)
- Apache Maven
- Docker Engine
curlcommand-line tool- A Secure Repository Token
To understand the Akka concepts behind this example, see Development Process in the documentation.
Please follow Build your first application to understand the details of this service implementation.
Building requires a secure repository token, which is set up as part of Akka CLI's akka code init command.
If you still need to configure your system with the token there are two additional ways:
- Use the Akka CLI's
akka code tokencommand and follow the instructions. - Set up the token manually as described here.
Use Maven to build your project:
mvn compileTo start your Akka service locally, run:
mvn compile exec:javaWith your Akka service running, any defined endpoints should be available at http://localhost:9000.
- Add an item
curl -i -XPUT -H "Content-Type: application/json" localhost:9000/carts/123/item -d '
{"productId":"akka-tshirt", "name":"Akka Tshirt", "quantity": 10}'- Get cart state
curl localhost:9000/carts/123- Remove an item
curl -i -XDELETE -H "Content-Type: application/json" localhost:9000/carts/123/item/akka-tshirt- Checkout the cart
curl -i -XPOST localhost:9000/carts/123/checkoutTo get a clear view of your locally running service, install the Akka CLI. It provides a local web-based management console.
After you have installed the CLI, start the local console:
akka local console` This will start a Docker container running the local console:
───────────────────────────────────────────────────────────────────────
│ SERVICE │ STATE │ ADDRESS |
───────────────────────────────────────────────────────────────────────
│ shopping-cart-quickstart │ Running │ localhost:9000 │
───────────────────────────────────────────────────────────────────────
Local console: http://localhost:9889
(use Ctrl+C to quit)
You can open http://localhost:9889/ to see your local service in action.
You can use the Akka Console to create a project and see the status of your service.
Build container image:
mvn clean install -DskipTestsInstall the akka CLI as documented in Install Akka CLI.
Deploy the service using the image name and tag from above mvn install:
akka service deploy shopping-cart shopping-cart-quickstart:tag-name --pushRefer to Deploy and manage services for more information.
Now that you've built and deployed a shopping cart service, take your Akka skills to the next level:
- Expand the service: Explore other Akka components to enhance your application with additional features.
- Explore other Akka samples: Discover more about Akka by exploring different use cases for inspiration.