-
Notifications
You must be signed in to change notification settings - Fork 140
Making QBit Friendly with Docker, Mesos, and Heroku
Here is an example of how to change the root address from /services to something else. And this is also an example of working with the Docker, Mesos, Heroku friendly version of QBit.
package qbit.todo;
import io.advantageous.qbit.admin.ManagedServiceBuilder;
import io.advantageous.qbit.server.ServiceEndpointServer;
public class TodoRestServer {
public static void main(String... args) {
final ManagedServiceBuilder managedServiceBuilder = ManagedServiceBuilder.managedServiceBuilder();
final ServiceEndpointServer serviceServer = managedServiceBuilder.getEndpointServerBuilder().setUri("/mrs")
.build()
.initServices(new TodoService()).startServer();
/* Wait for the service to shutdown. */
managedServiceBuilder.getSystemManager().waitForShutdown();
}
}
...
package qbit.todo;
import io.advantageous.qbit.annotation.*;
/**
* Created by rhightower on 2/10/15.
*/
@RequestMapping("/todoservice")
public class TodoService {
@RequestMapping("/todoo")
public Todo list() {
return new Todo("Hello");
}
}
...
package qbit.todo;
public class Todo {
private final String todo;
private final long time = System.currentTimeMillis();
public Todo(String todo) {
this.todo = todo;
}
}
You can run this curl command.
$ curl http://localhost:9090/mrs/todoservice/todoo
{"todo":"Hello","time":1436378304880}
With the ManagedServiceBuilder you can also get health and stats.
curl http://localhost:9090/__stats/
{
"MetricsKV": {},
"MetricsMS": {},
"MetricsC": {
"TodoService": 1,
"TodoService.startBatchCount": 2,
"TodoService.receiveCount": 2
},
"version": 1
}
curl http://localhost:9090/__stats_instance
{"MetricsKV":{},"MetricsMS":{},"MetricsC":{"TodoService.startBatchCount":1,"TodoService.receiveCount":1},"version":1}
$ curl http://localhost:9090/__health
"ok"
There are flags to turn that off. And you also get a CTRL-C to nicely shutdown all of the services. :)
It also reads $WEB_PORT and then $PORT from the enviroment variables. This way is plays nice in Heroku or Docker or Mesos.
You can also get rid of the root URI altogher as follows:
public static void main(String... args) {
final ManagedServiceBuilder managedServiceBuilder = ManagedServiceBuilder.managedServiceBuilder();
final ServiceEndpointServer serviceServer = managedServiceBuilder.getEndpointServerBuilder().setUri("/")
.build()
.initServices(new TodoService()).startServer();
/* Wait for the service to shutdown. */
managedServiceBuilder.getSystemManager().waitForShutdown();
}
Then to curl you would do this:
$ curl http://localhost:9090/todoservice/todoo
{"todo":"Hello","time":143637868275}
QBit Website What is Microservices Architecture?
QBit Java Micorservices lib tutorials
The Java microservice lib. QBit is a reactive programming lib for building microservices - JSON, HTTP, WebSocket, and REST. QBit uses reactive programming to build elastic REST, and WebSockets based cloud friendly, web services. SOA evolved for mobile and cloud. ServiceDiscovery, Health, reactive StatService, events, Java idiomatic reactive programming for Microservices.
Reactive Programming, Java Microservices, Rick Hightower
Java Microservices Architecture
[Microservice Service Discovery with Consul] (http://www.mammatustech.com/Microservice-Service-Discovery-with-Consul)
Microservices Service Discovery Tutorial with Consul
[Reactive Microservices] (http://www.mammatustech.com/reactive-microservices)
[High Speed Microservices] (http://www.mammatustech.com/high-speed-microservices)
Reactive Microservices Tutorial, using the Reactor
QBit is mentioned in the Restlet blog
All code is written using JetBrains Idea - the best IDE ever!
Kafka training, Kafka consulting, Cassandra training, Cassandra consulting, Spark training, Spark consulting
Tutorials
- QBit tutorials
- Microservices Intro
- Microservice KPI Monitoring
- Microservice Batteries Included
- RESTful APIs
- QBit and Reakt Promises
- Resourceful REST
- Microservices Reactor
- Working with JSON maps and lists
__
Docs
Getting Started
- First REST Microservice
- REST Microservice Part 2
- ServiceQueue
- ServiceBundle
- ServiceEndpointServer
- REST with URI Params
- Simple Single Page App
Basics
- What is QBit?
- Detailed Overview of QBit
- High level overview
- Low-level HTTP and WebSocket
- Low level WebSocket
- HttpClient
- HTTP Request filter
- HTTP Proxy
- Queues and flushing
- Local Proxies
- ServiceQueue remote and local
- ManagedServiceBuilder, consul, StatsD, Swagger support
- Working with Service Pools
- Callback Builders
- Error Handling
- Health System
- Stats System
- Reactor callback coordination
- Early Service Examples
Concepts
REST
Callbacks and Reactor
Event Bus
Advanced
Integration
- Using QBit in Vert.x
- Reactor-Integrating with Cassandra
- Using QBit with Spring Boot
- SolrJ and service pools
- Swagger support
- MDC Support
- Reactive Streams
- Mesos, Docker, Heroku
- DNS SRV
QBit case studies
QBit 2 Roadmap
-- Related Projects
- QBit Reactive Microservices
- Reakt Reactive Java
- Reakt Guava Bridge
- QBit Extensions
- Reactive Microservices
Kafka training, Kafka consulting, Cassandra training, Cassandra consulting, Spark training, Spark consulting