Coder Social home page Coder Social logo

wso2 / msf4j Goto Github PK

View Code? Open in Web Editor NEW
400.0 291.0 351.0 33 MB

WSO2 Microservices Framework for Java (MSF4J)

Home Page: http://wso2.com/products/microservices-framework-for-java/

License: Apache License 2.0

Java 95.65% Shell 1.50% CSS 0.29% JavaScript 1.80% Mustache 0.76%

msf4j's Introduction

Build status: Build Status

WSO2 Microservices Framework for Java (MSF4J)

WSO2 Microservices Framework for Java (MSF4J) is a lightweight high performance framework for developing & running microservices.

WSO2 MSF4J is one of the highest performing lightweight Java microservices frameworks. The following graphs show the throughput, memory consumption & latency characteristics of MSF4J against other microservices frameworks.

EchoThroughput

An echo service which accepts a 1KB request & echoes it back directly and using a temp file was developed for the respective frameworks, and requests were sent for different concurrency values. The test was repeated for each concurrency value for each framework and the average throughput was calculated. Tests were run out of the box without any tuning on 32 core 64GB server in JVM v1.8.0_60 with default configuration.

EchoMemory

Memory usage for each framework was observed after running the 1KB payload echo microservice on each framework & sending a number of requests at different concurrency levels to each service. The graph above shows the averaged out values after several runs for each framework.

Latency results was observed using the Apache bench provided percentile values. Results were plotted for various concurrency levels the simple echo test.

MeanLatency

Tests were run out of the box without any tuning on 32 core 64GB server in JVM v1.8.0_60 with default configuration.

More details about the performance test can found here.

Hello world with MSF4J

It is really easy to define & deploy a Java microservice using WSO2 MSF4J. You simply need to annotate your service and deploy it using a single line of code.

Let's get started by writing a hello world MSF4J microservice.

You can use the msf4j-microservice Maven archetype to create your first MSF4J project. Make sure you have JDK 1.8 and Maven 3.x installed, & run the following command.

mvn archetype:generate -DarchetypeGroupId=org.wso2.msf4j \
-DarchetypeArtifactId=msf4j-microservice -DarchetypeVersion=2.6.2 \
-DgroupId=org.example -DartifactId=Hello-Service -Dversion=0.1-SNAPSHOT \
-Dpackage=org.example.service -DserviceClass=HelloService

This will generate a project structure for you to quickly get started. Next navigate to the Hello-Service directory. You will find a pom.xml file and also an src directory.

pom.xml

This pom file inherits from the msf4j-service/pom.xml. It provides a way of setting things up quickly with minimum amount of configuration. Click here for more information.

<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

    <parent>
        <groupId>org.wso2.msf4j</groupId>
        <artifactId>msf4j-service</artifactId>
        <version>2.6.2</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>

    <groupId>org.example</groupId>
    <artifactId>Hello-Service</artifactId>
    <version>0.1-SNAPSHOT</version>
    <name>WSO2 MSF4J Microservice</name>

    <properties>
        <microservice.mainClass>org.example.service.Application</microservice.mainClass>
    </properties>

</project>

You don't need to change anything in this pom.xml file.

HelloService.java

Change the org.example.service.HelloService class as follows to echo back the name input parameter. You can remove the auto generated code and replace it with the following code segment:

package org.example.service; 

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

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

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

}

Application.java

This is the one-liner to deploy your service using WSO2 MSF4J.

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

You can also pass in the port(s) as an argument to the MicroservicesRunner class constructor. When passing the port(s) as an argument, by default it binds to 0.0.0.0 host. Use "msf4j.host" environment variable to override the host value.

Build the Service

Run the following Maven command. This will create the fat jar Hello-Service-0.1-SNAPSHOT.jar in the target directory.

mvn package

This fat jar is a jar file that contains your microservice as well as all its dependencies.

Run the Service

You just have to run the following command to get your service up and running.

java -jar target/Hello-Service-*.jar

Test the Service with cURL

Run the following command or simply go to [http://localhost:8080/hello/wso2] (http://localhost:8080/hello/wso2) from your browser.

curl http://localhost:8080/hello/wso2

You should see a response that prints "Hello wso2"

Supported Annotations

In this section, we will look at the annotations used in MSF4J microservices. As you may have already noticed, we support a subset of the JAXRS annotations.

Class level annotations

@Path

Root path for resource methods. All the paths specified in the resource methods will be sub paths of this.

@Consumes

Default consume media type(s) for resource methods. The resource methods that do not specify @Consume annotation will inherit this consume media type(s).

@Produces

Default produce media type(s) for resource methods. The resource methods that do not specify @Produce annotation will inherit this produce media type(s).

Method level annotations

@Path

Endpoint of the resource method relative to @Path of the container resource class.

@Consumes

Media type(s) that the method can consume. This overrides the class level @Consumes media types.

@Produces

Media type(s) that is produced by the method. This overrides the class level @Produces media types.

@GET

HTTP GET method. Specify that the resource method supports HTTP GET method.

@PUT

HTTP PUT method. Specify that the resource method supports HTTP PUT method.

@POST

HTTP POST method. Specify that the resource method supports HTTP POST method.

@DELETE

HTTP DELETE method. Specify that the resource method supports HTTP DELETE method.

@HEAD

HTTP HEAD method. Specify that the resource method supports HTTP HEAD method.

@OPTIONS

HTTP OPTIONS method. Specify that the resource method supports HTTP OPTIONS method.

Parameter level annotations

@DefaultValue

Specify a default value for a resource method parameter. The value will be automatically converted to the corresponding parameter's type.

@Context

Inject additional objects to a resource method. Currently supports injection of the following objects.

  • org.wso2.msf4j.Request - This object can be used to access properties of the HTTP request. The transport session (org.wso2.msf4j.Session) can also be accessed via org.wso2.msf4j.Request#getSession(). See the Session-aware service sample.
  • org.wso2.msf4j.Response - This object can be used to send HTTP responses. You can make responses more clean way by returning an instance of javax.ws.rs.core.Response or a POJO. See the [StockQuote-Service] (samples/stockquote/fatjar) sample.
  • org.wso2.msf4j.HttpStreamer - This object can be used to stream a chunked request body and process it while the request is streaming. See the FileServer sample.
  • org.wso2.msf4j.formparam.FormParamIterator - This object can be used to stream a HTML form submission request body and process it while the request is streaming. See the FormParam sample.
@PathParam

/StockQuote/{symbol} to get value of symbol. The value will be automatically converted to the corresponding parameter type and assigned to that parameter.

@QueryParam

/Students?age=18 to get value of age. The value will be automatically converted to the corresponding parameter type and assigned to that parameter.

@HeaderParam

To read HTTP request header values. The value will be automatically converted to the corresponding parameter type and assigned to that parameter.

@CookieParam

Extracts the value from the specified cookie, converts to the corresponding parameter type and assigns the value to that parameter.

@FormParam

To support HTML form submission with application/x-www-form-urlencoded and multipart/form-data The value will be automatically converted to the corresponding parameter type and assigned to that parameter

@FormDataParam

To support complex form submission with multipart/form-data content type. E.g file uploads and beans. The values will be automatically converted to the corresponding parameter type and assigned to that parameter

Lifecycle Callback Methods

Support following Java lifecycle callback method annotations.

@PostConstruct

Invoke by the container on newly constructed service instances after all dependency injection has completed and before transport starts.

@PreDestroy

Invoke by the container during server shutdown before the container removes the service instance.

For a detailed example, check out the lifecycle sample here.

MSF4J Interceptors

Please do refer the following for complete instructions.

Develop and configure MSF4J services using Spring framework

Spring is a popular Java application development framework which supports concepts like Dependency Injection(DI) and Convention over Configuration. Spring support for MSF4J provides following features.

  1. Develop MSF4J services as Spring beans
  2. Develop and configure MSF4J components such as Interceptors and ExceptionMappers using Spring.
  3. Use Annotation or XML based Spring configuration to configure internals of MSF4J framework such as ports, SSL etc.

Following example illustrates how to use Spring annotations together with MSF4J annotations to build a RESTful service. The main advantage here is service developers can consume Spring features such as dependency injection , Spring AOP etc. in the Spring way.

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

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

@Component
@Path("/greeting")
public class Hello {

    @Autowired
    private HelloService helloService;

    @GET
    public String message() {
        return helloService.hello(" World");
    }
}

For further details refer Spring Helloworld sample.

Annotations for Analytics

In this section, we will look at the annotations available for analytics purposes MSF4J microservices. There are annotations for Metrics and HTTP Monitoring.

You will need to configure analytics when you want to publish Metrics and HTTP Monitoring events to WSO2 Data Analytics Server (DAS).

The Metrics data will be published to WSO2 DAS periodically. However the HTTP Monitoring events are published on each request.

For a detailed example, check out the Metrics and HTTP Monitoring sample.

Metrics Annotations

You can use the Metrics annnotations in your MSF4J microservices to understand how your microservices work in production.

There are three metrics annotations supported. Those are @Counted, @Metered and @Timed.

Each metric must have a unique name and the MSF4J will use the fully qualified method name as the metric name by default. You can give a custom name by using the "name" parameter. This custom name will be appended to the fully qualified method name with a dot character. You can set the "absolute" parameter to "true" if you want use only the given name as the metric name.

For example, see following table to understand how the final metric name is built by the Metrics runtime. Let's asssume that the annotation is added to the "hello" method of "HelloService" shown above.

Metrics Annotation Metric Name
@Counted org.example.service.HelloService.hello
@Counted(name = "helloCounter") org.example.service.HelloService.hello.helloCounter
@Counted(name = "helloCounter", absolute = true) helloCounter

The Metrics annotations can be used at the Method level and Class level.

You can also configure a level in Metrics Annotations. For more information about Metric Levels, see WSO2 Carbon Metrics. In MSF4J, you can load the metrics level configuration via the System Property named metrics.level.conf.

@Counted

Count the method invocations. There is a parameter named "monotonic" and it is set to false by default. This means that the counter is decremented when the method returns. This is useful to count the current invocations of the annotated method.

Use @Counted(monotonic = true) when you want the counter to increase monotonically. This is useful to count the total invocations of the annotated method

@Metered

Measure the rate of method invocations. This also keeps a count of the total invocations of the annotated method.

@Timed

Maintain a histogram of durations of each method invocation. This also measures the rate of method invocations and keeps a count of the total invocations of the annotated method.

HTTP Monitoring Annotation

You can use the annotation provided for HTTP Monitoring when you want to monitor each HTTP request and see the summary in "HTTP Monitoring Dashboard".

@HTTPMonitored

Monitor each HTTP request. This annotation can be used at the Class level and the Method level.

HTTP Message Tracing

MSF4J supports visual message tracing through user friendly dashboards in WSO2 DAS or Zipkin. MSF4J message tracing provides a detailed insight to the complex microservices interactions in a system making monitoring, trouble shooting and optimization of microservices very easy. Please check WSO2 DAS Tracing and Zipkin Tracing samples for more details.

Swagger Annotations

Swagger is a standard, language-agnostic interface to REST APIs which allows both humans and computers to discover and understand the capabilities of the service without access to source code, documentation, or through network traffic inspection.

MSF4J supports all Swagger annotations out of the box.

To enable swagger support you need to add the following dependency to your project

<dependency>
     <groupId>org.wso2.msf4j</groupId>
     <artifactId>msf4j-swagger</artifactId>
     <version>2.6.2</version>
</dependency>

In order to retrieve Swagger definitions of your microservice, go to
http://<host>:<port>/swagger?path=<service_base_path>.

e.g. http://localhost:8080/swagger?path=/hello

To retrieve Swagger definitions of all microservices in your runtime, go to http://<host>:<port>/swagger.

e.g. http://localhost:8080/swagger

NOTE: Even without any Swagger annotation, default Swagger definitions will be generated using the JAXRS annotation in your MSF4J microservice.

The StockQuote sample demonstrates Swagger annotations in action.

ExceptionMapper

MSF4J supports JAXRS ExceptionMapper which allows creation of custom responses when exceptions are thrown from MSF4J services.

The StockQuote sample demonstrates ExceptionMapper in action.

The following code segment shows how ExceptionMappers are registered with the MSF4J runtime.

new MicroservicesRunner().addExceptionMapper(new SymbolNotFoundMapper(), new DuplicateSymbolMapper());

Circuit Breaker

Nygard's circuit breaker pattern is supported in MSF4J using the Netflix Hystrix library. For more details see the circuit breaker sample

Complete Feature List

  • Annotation based definition of microservices
  • High performance Netty based transport
  • WSO2 Developer Studio based tooling for microservices development starting from a Swagger API definition
  • Generate Swagger definition using Swagger annotations
  • Ability to develop and Configure MSF4J services using Spring framework
  • HTTP request & response streaming including support for javax.ws.rs.core.StreamingOutput.
  • ExceptionMapper
  • Support for metrics & visualization of metrics using WSO2 Data Analytics Server (DAS) dashboards
  • Message tracing with WSO2 DAS or Zipkin to get a detailed visual insight to the microservices interactions
  • Supports circuit breaker using Netflix Hystrix.
  • Support for securing microservices
  • Integration with rendering engines such as Mustache
  • Comprehensive samples demonstrating how to develop microservices based solutions

msf4j's People

Contributors

afkham avatar anugayan avatar arunasujith avatar callkalpa avatar chrishantha avatar cnapagoda avatar dakshika avatar daneshk avatar dinusha-dilrukshi avatar irunika avatar janakamarasena avatar kasunbg avatar kishanthan avatar lakwarus avatar lasanthas avatar maheshakya avatar manuri avatar nanduni-nin avatar niranjan-k avatar niveathika avatar rakhitharr avatar sagara-gunathunga avatar sameerajayasoma avatar samiyuru avatar senthuran16 avatar susinda avatar taniamahanama avatar thusithathilina avatar vidurananayakkara avatar wso2-jenkins-bot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

msf4j's Issues

Request Feature: Session Storage using RDBMS and Redis

Hi Team!

Congratulation for the new Session Feature! ^_^

btw, could you please add "Session Store Mechanism" by using RDBMS and Redis?

I think it would help developer to make scalable microservice application. Personally, we need it for scaling our microservice application in a high availability environment.

...................................................|-----> Microservice (IP 192.168.1.2) -----|.....................................
...................................................|.................................................................|.....................................
Client ----> Load Balancer -----|.................................................................|-----> Session Storage
...................................................|.................................................................|...........(RBDMS, Redis)..
...................................................|-----> Microservice (IP 192.168.1.3) -----|.....................................

Thanks ^_^

Performance Benchmark

I tried to add msf4j into my microservices performance benchmarks but got the following error under load. I think it must be some tuning parameters that I missed. I am wondering if someone here can help. MSF4J looks pretty good and it has potential out perform most of the microservies frameworks as it is netty based.

Here is the repo with source code.

https://github.com/networknt/light-java-example/tree/master/performance/msf4j

And the error.

2016-12-03 11:56:10 INFO  MicroservicesRegistryImpl:79 - Added microservice: HelloService@26f0a63f
2016-12-03 11:56:10 INFO  NettyListener:68 - Starting Netty Http Transport Listener
2016-12-03 11:56:10 INFO  NettyListener:110 - Netty Listener starting on port 8080
2016-12-03 11:56:10 INFO  MicroservicesRunner:193 - Microservices server started in 166ms
2016-12-03 11:56:27 ERROR WorkerPoolDispatchingSourceHandler:127 - Error occurred inside the messaging engine
java.lang.NullPointerException
	at org.wso2.msf4j.internal.MSF4JMessageProcessor.receive(MSF4JMessageProcessor.java:69)
	at org.wso2.carbon.transport.http.netty.listener.WorkerPoolDispatchingSourceHandler.lambda$publishToWorkerPool$12(WorkerPoolDispatchingSourceHandler.java:125)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:745)
2016-12-03 11:56:27 ERROR WorkerPoolDispatchingSourceHandler:127 - Error occurred inside the messaging engine
java.lang.NullPointerException
	at org.wso2.msf4j.internal.MSF4JMessageProcessor.receive(MSF4JMessageProcessor.java:69)
	at org.wso2.carbon.transport.http.netty.listener.WorkerPoolDispatchingSourceHandler.lambda$publishToWorkerPool$12(WorkerPoolDispatchingSourceHandler.java:125)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:745)
2016-12-03 11:56:27 ERROR WorkerPoolDispatchingSourceHandler:127 - Error occurred inside the messaging engine
java.lang.NullPointerException
	at org.wso2.msf4j.internal.MSF4JMessageProcessor.receive(MSF4JMessageProcessor.java:69)
	at org.wso2.carbon.transport.http.netty.listener.WorkerPoolDispatchingSourceHandler.lambda$publishToWorkerPool$12(WorkerPoolDispatchingSourceHandler.java:125)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:745)
2016-12-03 11:56:28 ERROR WorkerPoolDispatchingSourceHandler:127 - Error occurred inside the messaging engine
java.lang.NullPointerException
	at org.wso2.msf4j.internal.MSF4JMessageProcessor.receive(MSF4JMessageProcessor.java:69)
	at org.wso2.carbon.transport.http.netty.listener.WorkerPoolDispatchingSourceHandler.lambda$publishToWorkerPool$12(WorkerPoolDispatchingSourceHandler.java:125)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:745)
2016-12-03 11:56:28 ERROR WorkerPoolDispatchingSourceHandler:127 - Error occurred inside the messaging engine
java.lang.NullPointerException
	at org.wso2.msf4j.internal.MSF4JMessageProcessor.receive(MSF4JMessageProcessor.java:69)
	at org.wso2.carbon.transport.http.netty.listener.WorkerPoolDispatchingSourceHandler.lambda$publishToWorkerPool$12(WorkerPoolDispatchingSourceHandler.java:125)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:745)
2016-12-03 11:56:28 ERROR WorkerPoolDispatchingSourceHandler:127 - Error occurred inside the messaging engine
java.lang.NullPointerException
	at org.wso2.msf4j.internal.MSF4JMessageProcessor.receive(MSF4JMessageProcessor.java:69)
	at org.wso2.carbon.transport.http.netty.listener.WorkerPoolDispatchingSourceHandler.lambda$publishToWorkerPool$12(WorkerPoolDispatchingSourceHandler.java:125)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:745)
2016-12-03 11:56:28 ERROR WorkerPoolDispatchingSourceHandler:127 - Error occurred inside the messaging engine
java.lang.NullPointerException
	at org.wso2.msf4j.internal.MSF4JMessageProcessor.receive(MSF4JMessageProcessor.java:69)
	at org.wso2.carbon.transport.http.netty.listener.WorkerPoolDispatchingSourceHandler.lambda$publishToWorkerPool$12(WorkerPoolDispatchingSourceHandler.java:125)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:745)
2016-12-03 11:56:28 ERROR WorkerPoolDispatchingSourceHandler:127 - Error occurred inside the messaging engine
java.lang.NullPointerException
	at org.wso2.msf4j.internal.MSF4JMessageProcessor.receive(MSF4JMessageProcessor.java:69)
	at org.wso2.carbon.transport.http.netty.listener.WorkerPoolDispatchingSourceHandler.lambda$publishToWorkerPool$12(WorkerPoolDispatchingSourceHandler.java:125)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:745)
2016-12-03 11:56:28 ERROR WorkerPoolDispatchingSourceHandler:127 - Error occurred inside the messaging engine
java.lang.NullPointerException
	at org.wso2.msf4j.internal.MSF4JMessageProcessor.receive(MSF4JMessageProcessor.java:69)
	at org.wso2.carbon.transport.http.netty.listener.WorkerPoolDispatchingSourceHandler.lambda$publishToWorkerPool$12(WorkerPoolDispatchingSourceHandler.java:125)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:745)
2016-12-03 11:56:28 ERROR WorkerPoolDispatchingSourceHandler:127 - Error occurred inside the messaging engine
java.lang.NullPointerException
	at org.wso2.msf4j.internal.MSF4JMessageProcessor.receive(MSF4JMessageProcessor.java:69)
	at org.wso2.carbon.transport.http.netty.listener.WorkerPoolDispatchingSourceHandler.lambda$publishToWorkerPool$12(WorkerPoolDispatchingSourceHandler.java:125)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:745)
2016-12-03 11:56:28 ERROR WorkerPoolDispatchingSourceHandler:127 - Error occurred inside the messaging engine
java.lang.NullPointerException
	at org.wso2.msf4j.internal.MSF4JMessageProcessor.receive(MSF4JMessageProcessor.java:69)
	at org.wso2.carbon.transport.http.netty.listener.WorkerPoolDispatchingSourceHandler.lambda$publishToWorkerPool$12(WorkerPoolDispatchingSourceHandler.java:125)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:745)
2016-12-03 11:56:28 ERROR WorkerPoolDispatchingSourceHandler:127 - Error occurred inside the messaging engine
java.lang.NullPointerException
	at org.wso2.msf4j.internal.MSF4JMessageProcessor.receive(MSF4JMessageProcessor.java:69)
	at org.wso2.carbon.transport.http.netty.listener.WorkerPoolDispatchingSourceHandler.lambda$publishToWorkerPool$12(WorkerPoolDispatchingSourceHandler.java:125)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:745)
2016-12-03 11:56:28 ERROR WorkerPoolDispatchingSourceHandler:127 - Error occurred inside the messaging engine
java.lang.NullPointerException
	at org.wso2.msf4j.internal.MSF4JMessageProcessor.receive(MSF4JMessageProcessor.java:69)
	at org.wso2.carbon.transport.http.netty.listener.WorkerPoolDispatchingSourceHandler.lambda$publishToWorkerPool$12(WorkerPoolDispatchingSourceHandler.java:125)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:745)
2016-12-03 11:56:28 ERROR WorkerPoolDispatchingSourceHandler:127 - Error occurred inside the messaging engine
java.lang.NullPointerException
	at org.wso2.msf4j.internal.MSF4JMessageProcessor.receive(MSF4JMessageProcessor.java:69)
	at org.wso2.carbon.transport.http.netty.listener.WorkerPoolDispatchingSourceHandler.lambda$publishToWorkerPool$12(WorkerPoolDispatchingSourceHandler.java:125)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:745)
2016-12-03 11:56:28 ERROR WorkerPoolDispatchingSourceHandler:127 - Error occurred inside the messaging engine
java.lang.NullPointerException
	at org.wso2.msf4j.internal.MSF4JMessageProcessor.receive(MSF4JMessageProcessor.java:69)
	at org.wso2.carbon.transport.http.netty.listener.WorkerPoolDispatchingSourceHandler.lambda$publishToWorkerPool$12(WorkerPoolDispatchingSourceHandler.java:125)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:745)

mvn package is not working with this code

I did the setup for sample Helloservice .
When I was giving mvn package it shows below error:
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.788 s
[INFO] Finished at: 2016-10-06T12:38:35+05:30
[INFO] Final Memory: 18M/174M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.3:compile (default-compile) on project Hello-Service: Fatal error compiling: invalid target release: 1.8 -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

My maven version is Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-10T22:11:47+05:30)
Maven home: C:\apache-maven-3.3.9-bin\apache-maven-3.3.9\bin..
Java version: 1.7.0_80, vendor: Oracle Corporation
Java home: C:\Program Files\Java\jdk1.7.0_80\jre
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 8.1", version: "6.3", arch: "amd64", family: "windows"

Please guide where I am wrong

Thanks ,
Sudha

Packages not found

I have created a new project in eclipse based on the archetype as specified in the documentation. When this has been created I get the following errors in the pom.xml file:

Multiple annotations found at this line:
  - Missing artifact commons-io.wso2:commons-io:jar:2.4.0.wso2v1
  - Missing artifact org.wso2.carbon.transport:org.wso2.carbon.transport.http.netty:jar:2.1.2
  - Missing artifact org.wso2.carbon.messaging:org.wso2.carbon.messaging:jar:1.0.4

These packages are declared in the parent pom.

I have tried forcing an update of the snapshots as well as running maven clean install but these fail with the same errors. I have looked in the central maven repo but can't find these packages.

I am using Eclipse neon with Java 1.8.

HTTP OPTIONS Method

creating a resource with @options (javax.ws.rs) annotation gives a "405 Method Not Allowed" Response, the http OPTIONS request is not recognized.

In my case this was needed when using a AngularJS web app the browser sends an additional http OPTIONS request to check for CORS.

how to check service

can i know how check jpa service.in hello service "http://localhost:8080/hello/wso2" output was "hello wso2".like wise how can i verify that jpa module is working.........

this is not an issue.if there is any community to take help please send me that also.

thank you.

Deploy production

Hello.
We using here WSO2 DSS and identity server.
Using WebLogic too.
I should deploy the .jar to WebLogic ? or configure .war ?

Tks

Re-serializers already serialized strings

I have a already created JSON string. But if I try to return that from a MS the framework re-serializes it.
eg:

String json = "{\"a\":\"b\"}";
return Response.ok(json, "application/json");
expected = {"a":"b"}
actual   = "{\"a\":\"b\"}"

Is there a workaround to get the expected?

Performance issue with MSF4J

I'm not sure if this is an issue with MSF4J but I think it probably is.

I'm running a performance test on Ubuntu 16.04.

I'm using siege 3.1.4, with the following command line

siege -b -q -c 10 -r 10000 http://localhost:8080/purchase

I have a microservice using redis as a backend. The microservice code is available:

git clone https://github.com/pzfreo/POResourceComplete

You can simply clone / mvn clean install and then run the jar , as long as you have redis running.
mvn clean install
java -jar target/POResource-1.0.0.jar

The same code also runs under Jetty/Jersey. You can build that in the same directory with
gradle shadowJar
java -jar build/libs/POResourceComplete-all.jar

When I run under MSF4J I get a lot of failures.
When I run under Jetty/Jersey it works ok.

It might still be my Linux, but its highly repeatable and only happens with the MSF4J server not the Jersey server.

Add Bean Validation support to msf4j

It seems msf4j does not support JSR 349 yet.

The following code give nulled User:

    @POST
    @Path("/create")
    @Consumes(MediaType.APPLICATION_JSON)
    public String create(@Valid User user) {
        println "User: " + user
        return "success"
    }

I would love to see bean validation in msf4j.

Thanks!

Donny

First time and try msf4j

after maven new project, msf4j gennerate Application.java and MyService.java

Run Application.java and ERROR

Exception in thread "main" java.lang.NoClassDefFoundError: org/wso2/carbon/kernel/transports/CarbonTransport
    at org.example.service.Application.main(Application.java:28)
Caused by: java.lang.ClassNotFoundException: org.wso2.carbon.kernel.transports.CarbonTransport
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 1 more

Run Stockquote in OSGI mode

I'm following tutorial to run Stockquote in osgi mode, but i get the error Caused by: java.lang.NoClassDefFoundError: org/springframework/aop/support/AopUtils . it's look like Spring AOP not found in msf4j-core.
1480267703564.txt

error log file attached

Add OSGi tests to MSF4J

We can use the kernel 5.2.0-SNAPSHOT based carbon kernel test container and implement OSGi test for MSF4J

New Sample Request: A sample with manipulate database table

Hi All,

I'm very interested with WSO2 Microservices Server (WSO2 Microservice Framework for Java), It's awesome! ^_^

I'm looking for a sample with manipulate database table (CRUD), but i can't found it. Can you add a sample with manipulate mysql database table (CURD) ? I think it would help everyone.

Thanks,

with angular

how to use jpa module service in angularjs. i tried using #http but it didn't work.can you help me?i want to know how to use microservice in angular front end.
thank you.

Maven Archetype 2.0.0 not found

Hello,
I want to try the new msf4j framework but there is an error when trying to create the project with maven archetype.
It tells that archetype version 2.0.0 does not exist.
I've tried with version 1.0.0 with success but the generated code does not match the tutorial.

Regards

Samuel

MSF4J can't handle GZIP requests

Send a GZIP request to stockquote sample. This will throw HTTP 500 error. The reason is the message that gets from carbon-transport doesn't decode the request, hence MSF4J can't process the message.

first time try ms4j

[INFO] Reactor Summary:
[INFO]
[INFO] WSO2 MSF4J - Parent Pom ............................ SUCCESS [ 4.941 s]
[INFO] JAX-RS Delegates ................................... SUCCESS [ 8.873 s]
[INFO] WSO2 MSF4J core .................................... FAILURE [ 3.272 s]
[INFO] WSO2 MSF4J Spring .................................. SKIPPED
[INFO] MSF4J-Parent ....................................... SKIPPED
[INFO] WSO2 MSF4J Analytics ............................... SKIPPED
.
.
.
.
[INFO] Sample: PathParam with Regex ....................... SKIPPED
[INFO] WSO2 MSF4J OSGi tests .............................. SKIPPED
[INFO] msf4j .............................................. SKIPPED
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 19.355 s
[INFO] Finished at: 2016-07-18T11:21:46+05:30
[INFO] Final Memory: 49M/176M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-checkstyle-plugin:2.16:check (validate) on project msf4j-core: Failed during checkstyle execution: There are 16 errors reported by Checkstyle 6.2 with https://raw.githubusercontent.com/wso2/code-quality-tools/master/checkstyle/checkstyle.xml ruleset.

i used mvn archetype:generate -DarchetypeGroupId=org.wso2.msf4j \ -DarchetypeArtifactId=msf4j-microservice -DarchetypeVersion=1.0.0 \ -DgroupId=org.example -DartifactId=Hello-Service -Dversion=1.0.0 \ -Dpackage=org.example.service -DserviceClass=HelloService
as in quick start guidelines

Error in running server in HTTPS in MSF4J 2.0.1-SNAPSHOT

In MSF4J 2.0.1-SNAPSHOT when trying to run the micro service in https as stated in docs

it gives the following error

Exception in thread "main" java.lang.NoClassDefFoundError: org/yaml/snakeyaml/Yaml
at org.wso2.carbon.transport.http.netty.config.YAMLTransportConfigurationBuilder.build(YAMLTransportConfigurationBuilder.java:49)
at org.wso2.msf4j.MicroservicesRunner.configureTransport(MicroservicesRunner.java:156)
at org.wso2.msf4j.MicroservicesRunner.(MicroservicesRunner.java:68)
at org.wso2con.backendservice.Application.main(Application.java:33)
Caused by: java.lang.ClassNotFoundException: org.yaml.snakeyaml.Yaml
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 4 more

Prioritise existing MSF4J interceptors

Implement a mechanism to prioritise the existing interceptors so that interceptors would execute based on a certain order defined by the developer. Interceptors without a priority defined should have a default priority.

build failure spring hello world module and can't prime

mvn clean package
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building spring-helloworld 2.0.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[WARNING] The POM for org.wso2.msf4j:msf4j-spring:jar:2.0.0-SNAPSHOT is missing, no dependency information available
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.640 s
[INFO] Finished at: 2016-08-11T11:40:32+05:30
[INFO] Final Memory: 10M/185M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project spring-helloworld: Could not resolve dependencies for project org.wso2.msf4j:spring-helloworld:jar:2.0.0-SNAPSHOT: Failure to find org.wso2.msf4j:msf4j-spring:jar:2.0.0-SNAPSHOT in http://maven.wso2.org/nexus/content/repositories/releases/ was cached in the local repository, resolution will not be reattempted until the update interval of wso2.releases has elapsed or updates are forced -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException

Location support in Response

We are going to use below snippets in order to do POST request with 201 response. We want to send the Created resource location through the Response. Once we implement that we came up with below stack trace.

WARN {org.wso2.msf4j.internal.MSF4JMessageProcessor} - Unmapped exception java.lang.UnsupportedOperationException
at org.wso2.msf4j.delegates.MSF4JResponse$Builder.location(MSF4JResponse.java:334)
at javax.ws.rs.core.Response.created(Response.java:699)
at org.wso2.carbon.apimgt.rest.api.publisher.impl.ApisApiServiceImpl.apisPost(ApisApiServiceImpl.java:260)
at org.wso2.carbon.apimgt.rest.api.publisher.ApisApi.apisPost(ApisApi.java:425)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.wso2.msf4j.internal.router.HttpMethodInfo.invoke(HttpMethodInfo.java:132)
at org.wso2.msf4j.internal.MSF4JMessageProcessor.dispatchMethod(MSF4JMessageProcessor.java:130)
at org.wso2.msf4j.internal.MSF4JMessageProcessor.receive(MSF4JMessageProcessor.java:72)
at org.wso2.carbon.transport.http.netty.listener.WorkerPoolDispatchingSourceHandler.lambda$publishToWorkerPool$12(WorkerPoolDispatchingSourceHandler.java:125)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)

https://github.com/wso2/carbon-apimgt/blob/a94893c66473febc597b2895afe329ceccb1fbd3/components/apimgt/org.wso2.carbon.apimgt.rest.api.publisher/src/main/java/org/wso2/carbon/apimgt/rest/api/publisher/impl/ApisApiServiceImpl.java#L260

Custom ExceptionMapper for msf4j

Hi guys,

First of all I would like to congrats the team for the launching of msf4j framework. Personally I think the framework is promising. Being one of the first java microservices framework based on jax-rs (or the subset) which is JEE the facto REST API standard ...

However I found out that if you send any unhandled request to the msf4j service, the service will thrown an unhandled exception and stop working. Any subsequent request will simply ignored/rejected. Even the one with correct URL pattern which has specific handler method assigned for it.

This could be a special case which is only happen in my case only, but nevertheless I need to create a customized exception handler that could catch this unhandled exception. Within jax-rs specification, one way to achieve that is by creating a custom ExceptionMapper class.

My questions are :

  • Does msf4j jax-rs implementation support addition of custom ExceptionMapper ?
  • If it does, how can I actually incorporate my custom ExceptionMapper class into the framework ? Will the inclusion of @produces annotation in my custom class alone enough ?
  • If it does not support custom ExceptionMapper, what is the right way to prevent unhandled exception in msf4j ?

Thanks in advanced.

Kind regards,
Ahmad R. Djarkasih.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.