https://github.com/dustinsand/lagom-helloworld-java-to-kotlin
Proof of technology (POT) to evaluate Kotlin as the implementation language for Lagom microservices.
https://github.com/dustinsand/lagom-helloworld-java-to-kotlin
kotlin lagom lightbend
Last synced: 2 months ago
JSON representation
Proof of technology (POT) to evaluate Kotlin as the implementation language for Lagom microservices.
- Host: GitHub
- URL: https://github.com/dustinsand/lagom-helloworld-java-to-kotlin
- Owner: dustinsand
- Created: 2017-12-20T22:01:50.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-12-28T13:31:02.000Z (over 6 years ago)
- Last Synced: 2024-10-19T21:18:06.052Z (8 months ago)
- Topics: kotlin, lagom, lightbend
- Language: Kotlin
- Size: 49.8 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
[](https://travis-ci.org/dustinsand/lagom-helloworld-java-to-kotlin)
# lagom-helloworld-java-to-kotlin
Proof of technology (POT) to evaluate Kotlin as the implementation language for Lagom microservices. [Hello Lagom project (1.4.9) from Get Started with Lightbend Technologies](https://developer.lightbend.com/start/?group=lagom&project=lagom-java-maven) was ported from Java to Kotlin (1.3.11) with 1 to 1 matching functionality.# Goal
Show Kotlin can be used for Lagom microservices to gain the productivity and language advancements compared to Java. Why not Scala? Scala would have been the logical choice and a good one, but I've found less resistance from team members to learn Kotlin compared to Scala.# Key Changes
* Maven POMs to include Kotlin dependencies
* Kotlin equivalent classes in src/kotlin and equivalent Java classes removed from src/java# What did not port?
1. Lagom service interfaces ported to Kotlin caused this runtime error:
Caused by: java.lang.IllegalArgumentException: Service.descriptor must be implemented as a default method
Workaround explained here https://github.com/lagom/lagom/issues/1180.
# Run
```bash
mvn lagom:runAll
```1) Get the hello resource for World
```bash
curl http://localhost:9000/api/hello/World
```
Default response will be
```
Hello, World!
```2) Change the hello resource
```bash
curl -H "Content-Type: application/json" -X POST -d '{"message": "Hi"}' http://localhost:9000/api/hello/World
```
Response will be
```
Hi, World!
```3) Run the integration test with lagom running, integration-tests/src/test/kotlin/.../StreamIT, to assert streaming works.
# Summary
Lightbend's 'Hello Lagom' Java/Maven project was successfully ported to Kotlin. Unit and integration tests pass and the services are runnable. Hope this gives confidence for other developers to try Kotlin with Lagom.