Skip to content
Branch: master
Find file History
Latest commit 25d2a30 Mar 5, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information.
comments Start applications locally on a random port but in 8080 in docker-com… Jan 29, 2019
frontend/react Add new lock file Mar 5, 2019
mail Start applications locally on a random port but in 8080 in docker-com… Jan 29, 2019
offers Start applications locally on a random port but in 8080 in docker-com… Jan 29, 2019
pets Start applications locally on a random port but in 8080 in docker-com… Jan 29, 2019
storefront Add message when all dependencies are available Jan 29, 2019
vendors Start applications locally on a random port but in 8080 in docker-com… Jan 29, 2019
.gitignore Add examples May 18, 2018 Update README Jan 29, 2019
build.gradle Upgrade to RC3 Oct 17, 2018
docker-compose.yml Start applications locally on a random port but in 8080 in docker-com… Jan 29, 2019 Upgrade Petstore to 1.0.4 Jan 31, 2019
gradlew Add examples May 18, 2018
gradlew.bat Update 'petstore' to M2 Jul 4, 2018
petstore.png Add examples May 18, 2018
settings.gradle Add examples May 18, 2018

Micronaut Petstore


The petstore is an example application built on Micronaut in the form of Microservices architecture. The features of the application will be familiar to the Java community where pet profiles are displayed. Users can see a list of pets and enter a comment about the pets. Vendors are selling pets for a price and also notifications by email are included.

The purpose of the petstore application is to demonstrate how Micronaut can be utilized in a Microservice architecture. Each application has its own database, project structure, build cycle and resulting artifact. In order to demonstrate the ability of Micronaut to integrate with different technologies, the example is wired to various database implementations and developed with various programming languages.


The architecture of the pet store begins with the frontend project, which is the UI to the application. The frontend will communicate with the storefront project, which acts s a gateway to the rest of the Microservice applications. The Microservice applications are broken up by cohesive functionality. For example pets will focus on the displaying and storing pets, where vendors will do the same for vendors. Consul is used for service discovery of each Microservice provider. Each Microservice can subsequently communicate with each other through consul using HTTP.

See the diagram below:

Petstore Architecture

Micronaut Installation

In the case you want Micronaut installed locally, go the Micronaut root folder and use gradle to install the Micronaut framework dependencies into local maven.

./gradlew pTML

Use Docker

Using docker can help get the application up and running quite quickly.

Running Consul and Databases

consul needs to be running on port 8500.

mongo needs to be running on port 27017.

neo4j needs to be running on port 7687.

redis needs to be running on port 6379.

With docker you can start them all up in a container:

docker-compose up consul mongodb neo4j redis

Running Application with Gradle

The applications depend on one another so gradle builds need to be run in order:

./gradlew pets:run
./gradlew vendors:run

Once those are running start the following individually or as a group.

./gradlew comments:run mail:run offers:run --parallel

Then start:

./gradlew storefront:run

Finally run the frontend, which is written with React

./gradlew frontend:react:start

Running Application with Docker

The application is easily built and run in a docker container with the command below. However, note you will not be able to debug with breakpoints etc (a really handy way to learn Micronaut).

./gradlew build -x test
docker-compose build
docker-compose up

Wait till all the applications register with consul.
You may seen some errors during applications startup like ERROR i.m.d.registration.AutoRegistration - Error reporting passing state to Consul: Internal Server Error. They happen some time and they depend on the computer you're running docker-compose. They are due to the high CPU usage because a lot of containers are starting at the same time. The applications will try to register itself in Consul automatically after a moment and everything will work as expected.

Open Petstore

Access the app at http://localhost:3000/.

Windows Users

Note that if using a windows version of docker (specifically pre Windows 10 Pro) that localhost will be referred to as

Most Windows users will need to set up Docker Toolbox for Windows in order to use Docker. As a result, the default ip becomes This adds the complication that for any application, consul, or database created in a docker container, localhost needs to be replaced with the docker-machine ip.

The recommended setup to demo the petstore application on Windows is to do the following operations in order, while in the /petstore directory:

  • Replace petstore configuration that references localhost with (or the result of running docker-machine ip). Search for configurations that are referring to systems created in a docker container (those generated by the next step below).
  • docker-compose up consul mongodb neo4j redis
  • gradlew pets:run
  • gradlew vendors:run
  • gradlew comments:run mail:run offers:run --parallel
  • gradlew storefront:run
  • gradlew frontend:react:start
You can’t perform that action at this time.