Code Monkey home page Code Monkey logo

service-broker-demo's Introduction

Service Broker Demo

This project contains a sample implementation of a Service Broker based on the Spring Cloud Open Service Broker

It provides the following solutions:

  • Dispatching of multiple services (service definitions) by the very same broker

Using the Broker

Building the Broker

Build the service broker application with

./gradlew clean build

Running the Broker

Run the service broker application with

./gradlew clean bootRun

Testing the Broker

Run the tests with

./gradlew clean test -i

Development

Implementing new ServiceInstanceRequestHandler

Let's say you want to implement a handler for a new Mega service:

  1. Create a new class MegaServiceInstanceRequestHandler in the ch.lihsmi.demobroker.service.handler package.
  2. This class needs to implement the ServiceInstanceRequestHandler interface and must be annotated with the @ServiceInstanceRequestHandlerBean annotation.
  3. Make sure that the getServiceDefinitionId() method returns the service definition ID which is processed by your new handler (mega) as defined in the service plan of the broker.
  4. Implement handler logic in handleRequest()

Sample code:

package ch.lihsmi.demobroker.service.handler;

import org.springframework.cloud.servicebroker.model.instance.CreateServiceInstanceRequest;
import org.springframework.cloud.servicebroker.model.instance.CreateServiceInstanceResponse;
import org.springframework.stereotype.Component;

@Component
@ServiceInstanceRequestHandlerBean
public class MegaServiceInstanceRequestHandler implements ServiceInstanceRequestHandler {

    private final String serviceDefinitionId = "mega";

    @Override
    public CreateServiceInstanceResponse handleRequest(final CreateServiceInstanceRequest request) {
        return CreateServiceInstanceResponse.builder()
                .operation(serviceDefinitionId)
                .build();
    }
    
    // implement further methods of the ServiceInstanceRequestHandler interface as required

    @Override
    public String getServiceDefinitionId() {
        return serviceDefinitionId;
    }

}

References

service-broker-demo's People

Contributors

michaellihs avatar

Stargazers

Alexander H avatar

Watchers

 avatar James Cloos avatar

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.