An example Spring Boot service written in Ceylon, demonstrating the use of discovery, gateway, feign client, JPA, dependency injection, etc.
This project is experimental and is being done for fun in my spare time. So don't worry if the microservices don't make sense or look like a overengineering for just a few CRUDs.
The project is divided into the following services:
- Gateway
- Discovery
Foo
Bar
FooBar
(tests feign client, ribbon, etc)
You'll need the following prerequisites to get started:
- Ceylon 1.3.3
- Ceylon IDE 1.3.3 for IntelliJ or Eclipse
To compile the example, you'll need to type ceylon compile
in each service subdirectory. For example, to compile the
Gateway service, type:
cd gateway
ceylon compile
Alternatively, you can simply import this project into Eclipse or IntelliJ.
To start a service, go to the service subdirectory, and
type ceylon run <name>
. For example, to start the
Discovery service, type:
cd discovery
ceylon run discovery
To start a service from within the IDE, go to it's run()
function, and Run it.
The services must be started in the following order:
- First, the
discovery
service. - Next,
foo
,bar
, and/orfoobar
. - Finally, the
gateway
service.
An important detail is that the services are not available at the same time that services are UP, this is due to the strategy used by the discovery that consist basically wait 3 beats. So do not be surprised if at first seem that the service was not available. The default standby time is 30 seconds per beat.
-
Discovery
-
Bar
-
GET http://localhost:8080/bar/{ID HERE}
{
"name" : "Any Name Here"
}
- Foo
- GET http://localhost:8080/foo/{ID HERE}
- POST http://localhost:8080/foo/
{
"maximumPlaces" : 3
}
- FooBar
- POST http://localhost:8080/foobar/
{
"bar" : 1,
"foo" : 1
}
Enjoy and please open issues if you have problems with configuration.