v0.62 of Microserver : A plugin architecture and Microserver goes Reactive
New in Microserver v0.62
A new plugin Architecture and 11 plugins, with lots more to follow!
- micro-reactive - reactive programming via Pipes (Queues & Topics) and Asyncrhonous Streams.
- micro-events - capture scheduled jobs / active requests
- micro-data - Spring Data, Hibernate and JDBC
- micro-metrics - Dropwizard metrics for Spring
- micro-swagger
- micro-client - Async Rest Clients (NIO & Thread based)
- micro-grizzly - Grizzly Web server
- micro-jersey - Jersey jax-rs implementation
- micro-guava - Guava support (Jackson & Event bus configuration)
- micro-ip-tracker
- micro-cors
Other stuff!
- Users can create custom plugins
- Reactive Microserver first phase, with Reactive mixin that makes it easy to create performance optimised simple-react Streams
- simple-react version upgraded to 0.98
- Grizzly upgraded to version 2.3.21
- Jersey upgraded to version 2.19
Reactive Microserver
IO Bound Example, implement Reactive on your Rest Resource to inject Reactive capabilities!
@GET
@Produces("application/json")
public void mainfest(@Suspended AsyncResponse asyncResponse, @Context ServletContext context) {
this.ioStream().of("/META-INF/MANIFEST.MF")
.map(url->context.getResourceAsStream(url))
.map(this::getManifest)
.peek(result->asyncResponse.resume(result))
.run();
}
Get a thread per I/O task, but each event chain operates with thread affinity for performance reasons.
Pipes example
Create a bounded wait free Queue called "test"
LazyFutureStream<String> stream = Pipes.registerForIO("test", QueueFactories.
<String>boundedNonBlockingQueue(100)
.build());
Create a batch processing Stream
stream.sync() //do not distribute the next task to a task executor
.filter(it->it!=null)
.async() //now fan out across threads using a task executor
.batchBySize(20)
.sync() //any additional processing to continue on executing thread
.map(this::save)
.forEach(Logger::info);
new MicroserverApp(()-> "simple-app").run();
In our Rest Resources pipe information to our processing Stream
@Path("/status")
@Rest
public class PipesStatusResource implements Reactive {
volatile int next=0;
@GET
@Produces("text/plain")
@Path("/ping")
public String ping() {
this.enqueue("test",nextData());
return "ok";
}
}
Getting Microserver
Maven dependency
Microserver core
<dependency>
<groupId>com.aol.microservices</groupId>
<artifactId>micro-grizzly-with-jersey</artifactId>
<version>0.62</version>
</dependency>
Microserver Spring Boot
<dependency>
<groupId>com.aol.microservices</groupId>
<artifactId>micro-boot</artifactId>
<version>0.62</version>
</dependency>
Other modules are available in Maven Central
Gradle dependency
Microserver core
compile group: 'com.aol.microservices', name:'micro-grizzly-with-jersey', version:'0.62'
Microserver Spring Boot
compile group: 'com.aol.microservices', name:'micro-boot', version:'0.62'
Java Doc : Microserver Core
Java Doc : Microserver Boot
Java Doc : Microserver Data
Java Doc : Microserver Grizzly
Java Doc : Microserver Jersey
Java Doc : Microserver Swagger
Java Doc : Microserver Metrics
Java Doc : Microserver Reactive
Java Doc : Microserver Events