4. o Java 8
o Maven
o See the MSS’s releases page:
o https://github.com/wso2/product-mss/releases
o Let’s work direct from the source:
o Git pull
o https://github.com/wso2/product-mss
o Or simply download from this url: (easier)
https://github.com/wso2/product-mss/archive/master.zip
4
6. o So, cd <MSS_HOME>/
samples
o Make you sure you
could import the
project hello_world
6
7. o Go to the dir:
o <MSS_HOME>/samples/hello_world
o Type:
mvn package
7
8. o After Maven process
o ( be pacient with downloading J )
o What is happening:
o The pom.xml inside the sample, inherits the
dependencies from the root’s pom.xml, that’s why you
don’t need to worry with this process
o In a few (seconds) you will have a hello_service....jar into
your target folder.
8
9. 9
• WSO2 Microservices Server booting in my case less than 300ms
• In the previous maven process, every dependency from other jars
were included into your helloworld-1.0.0-SNAPSHOT.jar, including the
reference to the Main Java Class.
• Everything you need is ready J
10. 10
package org.wso2.carbon.mss.example;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
/**
* Hello service resource class.
*/
@Path("/hello")
public class HelloService {
@GET
@Path("/{name}")
public String hello(@PathParam("name") String name) {
return "Hello " + name;
}
}
}
JAX-RS
Simple class (REST Endpoint
REST Java Method
11. o The simplest Java Class startup
o See the main method:
11
public class Application {
public static void main(String[] args) {
new MicroservicesRunner()
.deploy(new HelloService())
.start();
}
13. o Take a look on this:
o http://www.confusedbycode.com/curl/
13
14. 14
public class Application {
public static void main(String[] args) {
new MicroservicesRunner(7888, 8888)
.deploy(new HelloService())
.start();
}
Services exposed through different ports(*)
(*) Default port is 8080 when no ports are specified
16. 1. Enter in the <mss_home>/samples/
stockquote-service
2. mvn package
3. java -jar target/stockquote-service-1.0.0-
SNAPSHOT.jar
16
17. o In the console type: (Windows Users
o curl -v http://localhost:8080/stockquote/GOOG
17
18. o Now we will send a POST message to our Service:
o Please type (or copy and paste) the following command:
o curl -v -X POST -H "Content-Type:application/json" -d
'{"symbol":"BVMF","name": "Bovespa","last":149.62,"low":150.78,"high":
149.18,"createdByHost":"localhost"}' http://localhost:8080/stockquote
o This command will save a new Symbol into our Stock Quote Service
18
19. o You had used:
o Java 8 + maven for building our samples and
exercises
o Executed Microservices with basic jar –jar
approach
o You saw how easy you can build REST Services
and deploy them into your Mic’service Server
(powered by WSO2)
19
21. o Several approaches for a “decoupled SOA”
o In this tutorial we will use the “Container-
based approach”
o Microservices are about:
o Lighter
o Business Need Oriented
o Composable
21
26. o Quick deployments
o You are deploying a loosely-coupled, modular
component only J
o Not a huge EAR with dozens of Jars as you used to do in
a monolithic enterprise App
26
28. 28
Paulo Merson https://insights.sei.cmu.edu/saturn/2015/11/defining-microservices.html
Great definition, written by another Brazilian J
From an architecture perspective, the microservice style belongs
primarily to the deployment view.
It dictates that the deployment unit should contain only one service or
just a few cohesive services.
The deployment constraint is the distinguishing factor. As a result,
microservices are easier to deploy, become more scalable, and can be
developed more independently by different teams using different
technologies.
“
29. o Benefits of using microservices:
o Deployability
o Availability
o Scalability
o Modifiability
o Management
29
Paulo Merson https://insights.sei.cmu.edu/saturn/2015/11/microservices-beyond-the-hype-what-you-gain-and-what-you-lose.html
( Great post )
30. o I would add:
o Deployability
o Availability (Auto-Scaling via Containers)
o Analytics
o Scalability
o Modifiability
o Management
30
Paulo Merson https://insights.sei.cmu.edu/saturn/2015/11/microservices-beyond-the-hype-what-you-gain-and-what-you-lose.html
31. o Part 2: (Soon)
o Analytics
o Auto-Scaling with Kubernetes and Docker
31