Skip to content
/ fuse Public

Micro REST server on top of akka, netty, spring-core & JDK8

Notifications You must be signed in to change notification settings

gibffe/fuse

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

87 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

fuse Build Status

The main purpouse of this project is to serve as a boostrap into the world of reactive programming for busy Java Developers (like myself). Fuse is a work in progress micro rest server that enables creating actor based backends. Fuse has been built on top of Netty & Akka.

Hard dependencies


Java 8, Spring

Hello World server


There are few steps necessary to boot your first reactive server

Clone the repo & install fuse locally, then add as dependency.

<dependency>
    <groupId>com.sulaco</groupId>
    <artifactId>fuse</artifactId>
    <version>0.0.4-SNAPSHOT</version>
</dependency>

Create fuse.conf in resources folder of your new project. This is where we configure our routes.

routes {
    GET /hello {
        class : fuse.test.endpoint.HelloWorld
    }
}
actors {

}

Create spring application context.xml file. Fuse currently requires spring to operate.

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
	   xmlns:context="http://www.springframework.org/schema/context"
	   xsi:schemaLocation="http://www.springframework.org/schema/beans
						   http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
						   http://www.springframework.org/schema/context
						   http://www.springframework.org/schema/context/spring-context-4.0.xsd"
       default-init-method="init"
>

    <context:annotation-config />
    <context:component-scan base-package="com.sulaco.fuse" />
    <bean class="com.sulaco.fuse.codec.JsonWireCodec" />

</beans>

Create HelloWorld endpoint actor

package fuse.test.endpoint.HelloWorld;

import com.sulaco.fuse.akka.actor.FuseEndpointActor;
import com.sulaco.fuse.akka.message.FuseRequestMessage;

public class HelloWorld extends FuseEndpointActor {
    
    @Override
    protected void onRequest(FuseRequestMessage request) {
        proto.respond(request, "Hello World !\n");
    }

}

Bootstrap the server - create Bootstrap.java file which will serve as an application entry point.

package fuse.test;

import com.sulaco.fuse.FuseBootstrap;

public class Bootstrap extends FuseBootstrap {

    public static void main(String[] args) throws Exception {
        FuseBootstrap.main(args);
    }

}

Running the Bootstrap will start the server up.

Examples

There are few examples available here

About

Micro REST server on top of akka, netty, spring-core & JDK8

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages