MSF4J: WSO2 Microservices Framework for Java to be Unleashed

DZone 's Guide to

MSF4J: WSO2 Microservices Framework for Java to be Unleashed

WSO2 recently debuted a Microservices Server, and it's will be available as a Microservices framework for Java.

· Integration Zone ·
Free Resource

WSO2 MSF4J Quick Start Guide

WSO2 recently started implementing a Microservices Server and finally it will be available as a Microservices framework 4 Java. In this post, we are going to learn and understand how fast you can write a microservice in a couple of steps.

So let's get started then.


1. JDK 1.8

2. Maven 3.2.0 or above

  1. Clone the git repository and you have to build it since it's not still released (you can skip this step after it's released).
git clone https://github.com/wso2/msf4j.git
cd msf4j
mvn clean install

    2. Create the project using the archetype

mvn archetype:generate 
-DgroupId=org.wso2.carbon -DartifactId=Hello-Service 

    3. Open the project using your IDE. and change the HelloService.java as follows.  (We only implement the GET here).

package org.wso2.carbon;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;

 * This is the Microservice resource class.
 * See <a href="https://github.com/wso2/msf4j#getting-started">https://github.com/wso2/msf4j#getting-started</a>
 * for the usage of annotations.
 * @since 1.0-SNAPSHOT
public class HelloService {

    @Produces({"application/json", "text/xml"})
    public String get(@PathParam("name")String name) {
        return "Hello " + name;

    4. Run the program from your IDE. if it's successfully started you'll get a similar log.

2016-02-10 21:52:01 INFO  MicroservicesRegistry:76 - Added microservice: org.wso2.carbon.HelloService@6aa8ceb6
2016-02-10 21:52:01 INFO  NettyListener:56 - Starting Netty Http Transport Listener
2016-02-10 21:52:01 INFO  NettyListener:80 - Netty Listener starting on port 8080
2016-02-10 21:52:01 INFO  MicroservicesRunner:122 - Microservices server started in 197ms

    5. Now let's invoke the service using curl command to test it.

curl -v -X GET http://localhost:8080/service/Aruna
* Hostname was NOT found in DNS cache
*   Trying
* Connected to localhost ( port 8080 (#0)
> GET /service/aruna HTTP/1.1
> User-Agent: curl/7.35.0
> Host: localhost:8080
> Accept: */*
< HTTP/1.1 200 OK
< Content-Type: application/json
< Content-Length: 13
< Connection: keep-alive
* Connection #0 to host localhost left intact
"Hello Aruna"

So that's it, folks, you have implemented your first micro service and just invoked it!!!

So if you are interested, please check out our git documentation for more features, performance comparisons. And if you have any questions don't forget to drop a mail to dev@wso2.org or architecture@wso2.org

See you soon with another interesting blog post...

java, micro services, rest

Published at DZone with permission of Aruna Karunarathna , DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}