Microservices with Spring Boot, Netflix Zuul, Kotlin, Docker and MongoDB

Recently I’ve started playing with Kotlin programming language, and wanted to give it a try.

Kotlin gives us possibility to write quite concise code, such as:

@RestController
class UsersController(val userRepo: UserRepository) {

    @ResponseStatus(HttpStatus.OK)
    @GetMapping("/users/{userId}")
    fun getUser(@PathVariable userId: String): UserDTO {
        return userRepo.findOne(userId).toUserDTO()
    }
}

You can find and download source code from GitHub. Readme file there explains how to start & use services. docker-compose comes quite handy to start / shutdown all the services with simple commands and orchestrate them via docker-compose yaml configuration file.

I’ve built sample, small microservice, composed of some kind of simple api-gateway or proxy server, implemented using Spring Boot and Netflix Zuul library for proxying requests to downstream servers.

I’ve built api-gateway which is public facing proxy server implemented using Spring Boot and Netflix Zuul library. It doesn’t do anything else than forwarding request to downstream user-service microservice.

User service is implemented in Spring Boot, using Kotlin as a language of choice, having MongoDB as persistent storage. It has only two APIs – create user and retrieve user. I’m using command line to test these APIs. Idea is to call api-gateway that just downstreams request to user-service. This kind of simulates some real-life scenarios of how you might organize your service oriented architectures.

Stay tuned and, if you liked this post, don’t forget to subscribe for getting more interesting content!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s