BT

WSO2 MSF4J Adds Support for Spring and Swagger

| by Abel Avram Follow 9 Followers on Jul 22, 2016. Estimated reading time: 1 minute |

WSO2 MSF4J 2.0 has added support for Spring, Swagger definition generation, ExceptionMapper and StreamingOutput.

WSO2 MSF4J is an open source framework for building microservices in Java. The framework has a small memory footprint at 25MB and starts up in less than 400ms, according to WSO2. The recently released v. 2.0 comes with a number of improvements, including:

  • Support for Spring annotations and runtime. Microservices, interceptors and exception mappers can now be written as Spring beans
  • Generate Swagger definitions and support for Swagger annotations
  • Support for ExceptionMapper which connects an exception thrown by a microservice with an HTTP response
  • Support for StreamingOutput which enables the developer to control how the response is streamed back to the caller

Some of the WSO2 MSF4J main features are:

  • Uses Java annotations for defining microservice APIs
  • Supports JAX-RS and JSR 250 (annotations)
  • Integrated with other WSO2 development, deployment, monitoring and scaling tools
  • Integrated with WSO2 Data Analytics Server
  • Integrated with WSO2 Identity Server
  • It comes with an API Interceptor that catches messages for various reasons such as logging
  • Development through WSO2 DevStudio which can generate a microservices project from a Swagger API definition
  • Message transport is done via Netty
  • Requests can be traced through a unique message ID

To create a microservice with MSF4J, one needs to annotate a Java class to define the API endpoints and deploy it with a runner. A basic HelloWorld example looks like this:

@Path("/hello")
public class HelloService {

    @GET
    @Path("/{name}")
    public String hello(@PathParam("name") String name) {
        return "Hello " + name;
    }
}

and it is deployed with

public class Application {
    public static void main(String[] args) {
        new MicroservicesRunner()
                .deploy(new HelloService())
                .start();
    }
}

As a result, the URL

curl http://localhost:8080/hello/world

will get the response “Hello world”.

Microservices created with WSO2 MSF4J can be built with Maven and deployed in Docker containers.

Rate this Article

Adoption Stage
Style

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Tell us what you think

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread
Community comments

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Discuss

Login to InfoQ to interact with what matters most to you.


Recover your password...

Follow

Follow your favorite topics and editors

Quick overview of most important highlights in the industry and on the site.

Like

More signal, less noise

Build your own feed by choosing topics you want to read about and editors you want to hear from.

Notifications

Stay up-to-date

Set up your notifications and don't miss out on content that matters to you

BT