io.scalecube:scalecube-services-examples-parent

ScaleCube is a lightweight decentralized cluster membership, failure detection, messaging and gossip protocol library for the Java VM.

License

License

Categories

Categories

ScaleCube Services Application Layer Libs Distributed Applications
GroupId

GroupId

io.scalecube
ArtifactId

ArtifactId

scalecube-services-examples-parent
Last Version

Last Version

2.10.5
Release Date

Release Date

Type

Type

pom
Description

Description

ScaleCube is a lightweight decentralized cluster membership, failure detection, messaging and gossip protocol library for the Java VM.

Download scalecube-services-examples-parent

How to add to project

<!-- https://jarcasting.com/artifacts/io.scalecube/scalecube-services-examples-parent/ -->
<dependency>
    <groupId>io.scalecube</groupId>
    <artifactId>scalecube-services-examples-parent</artifactId>
    <version>2.10.5</version>
    <type>pom</type>
</dependency>
// https://jarcasting.com/artifacts/io.scalecube/scalecube-services-examples-parent/
implementation 'io.scalecube:scalecube-services-examples-parent:2.10.5'
// https://jarcasting.com/artifacts/io.scalecube/scalecube-services-examples-parent/
implementation ("io.scalecube:scalecube-services-examples-parent:2.10.5")
'io.scalecube:scalecube-services-examples-parent:pom:2.10.5'
<dependency org="io.scalecube" name="scalecube-services-examples-parent" rev="2.10.5">
  <artifact name="scalecube-services-examples-parent" type="pom" />
</dependency>
@Grapes(
@Grab(group='io.scalecube', module='scalecube-services-examples-parent', version='2.10.5')
)
libraryDependencies += "io.scalecube" % "scalecube-services-examples-parent" % "2.10.5"
[io.scalecube/scalecube-services-examples-parent "2.10.5"]

Dependencies

test (6)

Group / Artifact Type Version
org.junit.jupiter : junit-jupiter-engine jar 5.1.1
org.junit.jupiter : junit-jupiter-params jar 5.1.1
org.mockito : mockito-junit-jupiter jar 2.24.5
org.hamcrest : hamcrest-all jar 1.3
org.hamcrest : hamcrest-core jar 1.3
io.projectreactor : reactor-test jar

Project Modules

  • services-examples
  • services-examples-runner

scalecube-services

Codacy Badge Maven Central SourceSpy Dashboard

MICROSERVICES 2.0

An open-source project that is focused on streamlining reactive-programming of Microservices Reactive-systems that scale, built by developers for developers.

ScaleCube Services provides a low latency Reactive Microservices library for peer-to-peer service registry and discovery based on gossip protocol, without single point-of-failure or bottlenecks.

Scalecube more gracefully address the cross cutting concernes of distributed microservices architecture.

ScaleCube Services Features:
  • Provision and interconnect microservices peers in a cluster
  • Fully Distributed with No single-point-of-failure or single-point-of-bottleneck
  • Fast - Low latency and high throughput
  • Scaleable over- cores, jvms, clusters, regions.
  • Built-in Service Discovery and service routing
  • Zero configuration, automatic peer-to-peer service discovery using gossip
  • Simple non-blocking, asynchronous programming model
  • Reactive Streams support.
    • Fire And Forget - Send and not wait for a reply
    • Request Response - Send single request and expect single reply
    • Request Stream - Send single request and expect stream of responses.
    • Request bidirectional - send stream of requests and expect stream of responses.
  • Built-in failure detection, fault tolerance, and elasticity
  • Routing and balancing strategies for both stateless and stateful services
  • Embeddable into existing applications
  • Natural Circuit-Breaker via scalecube-cluster discovery and failure detector.
  • Support Service instance tagging.
  • Modular, flexible deployment models and topology
  • pluggable api-gateway providers (http / websocket / rsocket)
  • pluggable service transports (tcp / aeron / rsocket)
  • pluggable encoders (json, SBE, Google protocol buffers)

User Guide:

Basic Usage:

The example provisions 2 cluster nodes and making a remote interaction.

  1. seed is a member node and provision no services of its own.
  2. then microservices variable is a member that joins seed member and provision GreetingService instance.
  3. finally from seed node - create a proxy by the GreetingService api and send a greeting request.
    //1. ScaleCube Node node with no members
    Microservices seed = Microservices.builder().startAwait();

    //2. Construct a ScaleCube node which joins the cluster hosting the Greeting Service
    Microservices microservices =
        Microservices.builder()
            .discovery(
                self ->
                    new ScalecubeServiceDiscovery(self)
                        .options(opts -> opts.seedMembers(toAddress(seed.discovery().address()))))
            .transport(ServiceTransports::rsocketServiceTransport)
            .services(new GreetingServiceImpl())
            .startAwait();

    //3. Create service proxy
    GreetingsService service = seed.call().api(GreetingsService.class);

    // Execute the services and subscribe to service events
    service.sayHello("joe").subscribe(consumer -> {
      System.out.println(consumer.message());
    });

Basic Service Example:

  • RequestOne: Send single request and expect single reply
  • RequestStream: Send single request and expect stream of responses.
  • RequestBidirectional: send stream of requests and expect stream of responses.

A service is nothing but an interface declaring what methods we wish to provision at our cluster.

@Service
public interface ExampleService {

  @ServiceMethod
  Mono<String> sayHello(String request);

  @ServiceMethod
  Flux<MyResponse> helloStream();

  @ServiceMethod
  Flux<MyResponse> helloBidirectional(Flux<MyRequest> requests);
}

API-Gateway:

Available api-gateways are rsocket, http and websocket

Basic API-Gateway example:

    Microservices.builder()
        .discovery(options -> options.seeds(seed.discovery().address()))
        .services(...) // OPTIONAL: services (if any) as part of this node.

        // configure list of gateways plugins exposing the apis
        .gateway(options -> new WebsocketGateway(options.id("ws").port(8080)))
        .gateway(options -> new HttpGateway(options.id("http").port(7070)))
        .gateway(options -> new RSocketGateway(options.id("rsws").port(9090)))

        .startAwait();

        // HINT: you can try connect using the api sandbox to these ports to try the api.
        // http://scalecube.io/api-sandbox/app/index.html

Maven

With scalecube-services you may plug-and-play alternative providers for Transport,Codecs and discovery. Scalecube is using ServiceLoader to load providers from class path,

You can think about scalecube as slf4j for microservices - Currently supported SPIs:

Transport providers:

  • scalecube-services-transport-rsocket: using rsocket to communicate with remote services.

Message codec providers:

Service discovery providers:

Binaries and dependency information for Maven can be found at http://search.maven.org.

https://mvnrepository.com/artifact/io.scalecube

To add a dependency on ScaleCube Services using Maven, use the following:

Maven Central

 <properties>
   <scalecube.version>2.x.x</scalecube.version>
 </properties>

 <!-- -------------------------------------------
   scalecube core and api:
 ------------------------------------------- -->

 <!-- scalecube apis   -->
 <dependency>
  <groupId>io.scalecube</groupId>
  <artifactId>scalecube-services-api</artifactId>
  <version>${scalecube.version}</version>
 </dependency>

 <!-- scalecube services module   -->
 <dependency>
  <groupId>io.scalecube</groupId>
  <artifactId>scalecube-services</artifactId>
  <version>${scalecube.version}</version>
 </dependency>


 <!--

     Plugins / SPIs: bellow a list of providers you may choose from. to constract your own configuration:
     you are welcome to build/contribute your own plugins please consider the existing ones as example.

  -->

 <!-- scalecube transport providers:  -->
 <dependency>
  <groupId>io.scalecube</groupId>
  <artifactId>scalecube-services-transport-rsocket</artifactId>
  <version>${scalecube.version}</version>
 </dependency>

Sponsored by OM2

io.scalecube

SCΛLΞ CUBΞ

⚛ High-Speed ⚛ Cloud-Native ⚛ Reactive Microservices ⚛

Versions

Version
2.10.5
2.10.4
2.10.4-RC1
2.10.3
2.10.2
2.10.1-RC11-RC9-RC9
2.10.1-RC10-RC9
2.10.1-RC8
2.10.0
2.10.0-RC6
2.10.0-RC5
2.10.0-RC4
2.10.0-RC3
2.10.0-RC2
2.10.0-RC1
2.9.2
2.9.1-RC9
2.9.1-RC8
2.9.1-RC7
2.9.1-RC6
2.9.1-RC5
2.9.1-RC4
2.9.1-RC3
2.9.1-RC2
2.9.1-RC1
2.9.0
2.8.10
2.8.10-RC3
2.8.10-RC2
2.8.10-RC1
2.8.9
2.8.8
2.8.7
2.8.6
2.8.5
2.8.4
2.8.3
2.8.2
2.8.1
2.8.0
2.7.2
2.7.1
2.7.0
2.6.3