Skip to content

xored/vertx-typed-rpc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Vertx EventBus Typed RPC Services

Build Status Maven Central ![License](https://img.shields.io/badge/license-Apache 2.0 -blue.svg?style=flat)

Simple wrapper for Vertx EventBus that allows organize type safety RPC communication.

Features

  • Type safety (it used Kryo library for object serialization)
  • Asynchronous RPC calls by using java.util.concurrent.CompletableFuture
  • Server side exception handling

Installation

The library JARs are available on the releases page and at Maven Central. Latest snapshots of the library including snapshot builds of master are in the Sonatype Repository.

Integration with Maven

To use the Vert.x Typed RPC Services, add the following dependency to the dependencies section of your pom.xml:

<dependency>
  <groupId>com.xored.vertx</groupId>
  <artifactId>vertx-typed-rpc</artifactId>
  <version>1.0</version>
</dependency>

Quickstart

The example below describes a simple scenario of usage EventBus services:

  • Specify RPC service interface PersonService.java that should be shared for client and server side:
package example;

import com.xored.vertx.typed.rpc.EventBusService;

import java.util.concurrent.CompletableFuture;

@EventBusService("person-service")
public interface PersonService {
    
    CompletableFuture<Person> getPersonByName(String name);
}
  • Add implementation class PersonServiceImpl.java for service
package example;

import java.util.concurrent.CompletableFuture;

public class PersonServiceImpl implements PersonService {

    @Override
    public CompletableFuture<Person> getPersonByName(String name) {
        return CompletableFuture.completedFuture(new Person());
    }
}

and register service with the following code:

EventBusServiceFactory.registerServer(eventBus, new PersonServiceImpl())
  • On client side you need create proxy for service:
PersonService client = EventBusServiceFactory.createClient(eventBus, PersonService.class);
client.getPersonByName("test").thenAccept(person -> {
    // person logic here
});

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages