The auction service (first try)

This post describes how I set up a first version of the auction service that serves as the basis for all my docker swarm examples.

The first version will be very basic. In alter iterations I plan to enhance the API so that it more and more resembles the behavior of the auction in M.U.L.E.

The git repository for the service can be found on gitlab: IRATA repository on Gitlab

The basis

The basis for the service is Spring Boot and Gradle.
There is a very simple and precise tutorial for building a restful service using spring boot here.

The auction-service is based on that example. The initial gradle build file looks like this:

At this point there is actually nothing fancy to this file. It will be refined in later iterations.
Building and testing the gradle project is quiet straight forward as well:

The java implementation

The actual java implementation is in the class AuctionService.
The first implementation will for the time being only allow participants in an auction to register and bid on items of an auction.

I don’t bother about the details right now. The key point is, that for the time being all auctions are stored as an instance variable of the service. No data is persistent. This will become interesting once we scale the auction service using docker swarm.

Therefore I added one spring profile called memory in which all data is stored in a hsahmap. Later on I will introduce Redis for actually storing data.

The rest controller

The rest controller acts as a facade in front of the service and exposes its function via REST. The method for creating an auction for example looks like this:

The full implementation can be found here.

Accessing the rest service

Later on it will be pretty easy for example to create and bid on an auction with simple http POST and GET operations. For example:

There is a Spring Boot Integration Test, that tests the currently available functions here. Which tests most of the services functions

Next Steps

So the auction-service in it’s first draft serves is finished and it will serve as the microservice for the upcoming docker swarm tests.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">