Skip to content

[DOC] A ServiceQueue that is a local service and a remote service

Richard Hightower edited this page Oct 19, 2015 · 1 revision

You have to invoke it via the service bundle of the ServiceEndpointServer. The serviceBundle will have the callback handler. Currently only one callback handler can be active per service queue. The serviceBundle callback handling is smart enough to handle the REST invoke case and the regular case.

package io.advantageous.qbit.spring.rest;


import io.advantageous.qbit.annotation.RequestMapping;

@RequestMapping("/hw")
public class HelloWorld {


    @RequestMapping("/hello/")
    public String hello() {
        System.out.println("HELLO!");
        return "hello";
    }
}
        final ServiceEndpointServer serviceEndpointServer = EndpointServerBuilder
                .endpointServerBuilder()
                .setPort(port).build();

        final Queue<Response<Object>> responses = serviceEndpointServer.serviceBundle().responses();

        final ServiceBuilder serviceBuilder = ServiceBuilder
                .serviceBuilder().setResponseQueue(responses)
                .setServiceObject(new HelloWorld());

        final ServiceQueue serviceQueue = serviceBuilder.build();
        serviceEndpointServer.addServiceQueue("helloworld", serviceQueue);

        serviceQueue.startServiceQueue();


        serviceEndpointServer.startServer();
        Sys.sleep(1_000);

        final HttpClient httpClient = HttpClientBuilder.httpClientBuilder()
                .setPort(port).buildAndStart();


        final HttpTextResponse httpTextResponse = httpClient.get("/services/hw/hello/");

        assertEquals("\"hello\"", httpTextResponse.body());
        assertEquals(200, httpTextResponse.code());
        assertEquals("application/json", httpTextResponse.contentType());

Tutorials

__

Docs

Getting Started

Basics

Concepts

REST

Callbacks and Reactor

Event Bus

Advanced

Integration

QBit case studies

QBit 2 Roadmap

-- Related Projects

Kafka training, Kafka consulting, Cassandra training, Cassandra consulting, Spark training, Spark consulting

Clone this wiki locally