rmi

Async RMI is modern true asynchronous Java RMI implementation.

License

License

GroupId

GroupId

com.github.barakb
ArtifactId

ArtifactId

asyncrmi
Last Version

Last Version

1.0.3
Release Date

Release Date

Type

Type

jar
Description

Description

rmi
Async RMI is modern true asynchronous Java RMI implementation.
Project URL

Project URL

http://barakb.github.io/asyncrmi/
Source Code Management

Source Code Management

https://github.com/barakb/asyncrmi

Download asyncrmi

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.barakb/asyncrmi/ -->
<dependency>
    <groupId>com.github.barakb</groupId>
    <artifactId>asyncrmi</artifactId>
    <version>1.0.3</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.barakb/asyncrmi/
implementation 'com.github.barakb:asyncrmi:1.0.3'
// https://jarcasting.com/artifacts/com.github.barakb/asyncrmi/
implementation ("com.github.barakb:asyncrmi:1.0.3")
'com.github.barakb:asyncrmi:jar:1.0.3'
<dependency org="com.github.barakb" name="asyncrmi" rev="1.0.3">
  <artifact name="asyncrmi" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.barakb', module='asyncrmi', version='1.0.3')
)
libraryDependencies += "com.github.barakb" % "asyncrmi" % "1.0.3"
[com.github.barakb/asyncrmi "1.0.3"]

Dependencies

compile (5)

Group / Artifact Type Version
io.netty : netty-all jar 4.1.9.Final
org.javassist : javassist jar 3.18.0-GA
org.slf4j : slf4j-api jar 1.7.25
org.slf4j : slf4j-site jar 1.7.25
org.yaml : snakeyaml jar 1.15

test (5)

Group / Artifact Type Version
org.slf4j : jul-to-slf4j jar 1.7.25
org.apache.logging.log4j : log4j-slf4j-impl jar 2.8.1
org.apache.logging.log4j : log4j-api jar 2.8.1
org.apache.logging.log4j : log4j-core jar 2.8.1
junit : junit jar 4.12

Project Modules

There are no modules declared in this project.
master gh-pages
Build Status Build Status

Async RMI is modern true asynchronous Java RMI implementation.

The full documentation page.

##Use with Maven dependency.

    <dependency>
      <groupId>com.github.barakb</groupId>
      <artifactId>asyncrmi</artifactId>
      <version>1.0.3</version>
    </dependency>

Alternatively you can use one jar with all dependencies.

    <dependency>
      <groupId>com.github.barakb</groupId>
      <artifactId>asyncrmi-dep</artifactId>
      <version>1.0.3</version>
    </dependency>

See sample project on github.

##How to build.

  • Install Oracle JDK8.
  • Install maven.
  • Clone the project git clone [email protected]:barakb/asyncrmi.git or download the zip or the tar.gz file.
  • Change dir to the asyncrmi directory and type mvn install at the console.

Alternatively you can get (or build) a Docker image with the dev env:

Download the pre compiled docker image:

  1. sudo docker pull barakb/asyncrmi
  2. sudo docker run -i -t --name=asyncrmi barakb/asyncrmi /bin/bash
  3. git pull --rebase
  4. mvn install

Download the DockerFile from github

How to build the examples.

  • After building Async RMI from the Async RMI dir type (cd example; mvn install)

##An example.

####The remote interface.

public interface Example extends Remote {
    public String echo(String msg) throws RemoteException;
    public CompletableFuture<String> futuredEcho(String msg) throws RemoteException;
}

####The server and the client.

public class ExampleServer implements Example {
    private static final Logger logger = LoggerFactory.getLogger(ExampleServer.class);

    @Override
    public String echo(String msg) throws RemoteException {
        logger.debug("Server: called echo({})", msg);
        return msg;
    }

    @Override
    public CompletableFuture<String> futuredEcho(final String msg)
            throws RemoteException {
        logger.debug("Server: futuredEcho echo({})", msg);
        return CompletableFuture.supplyAsync(() -> {
            try {
                Thread.sleep(10000);
            } catch (InterruptedException e) {
                Thread.currentThread().interrupt();
                logger.error(e.toString(), e);
            }
            return msg;
        });
    }

    public static void main(String[] args) throws Exception {
        try {
            ExampleServer server = new ExampleServer();
            Example proxy = (Example) Modules.getInstance().getExporter().export(server);
            File file = new File("ExampleServer.proxy");
            Util.serialize(Files.asByteSink(file), proxy);
            logger.info("proxy {} saved to file  {}, server is running at: {}:{}",
                    proxy, file.getAbsolutePath());
        } catch (Exception e) {
            logger.error("ExampleServer exception while exporting:", e);
        }

        File file = new File("ExampleServer.proxy");
        //noinspection UnusedDeclaration
        Example example = (Example) Util.deserialize(Files.asByteSource(file));
        String res = example.echo("foo");
        logger.info("client got: {}", res);
        res = example.echo("foo1");
        logger.info("client got: {}", res);

        CompletableFuture<String> future = example.futuredEcho("async foo");
        res = future.join();
        logger.debug("client got async res : {}", res);
    }
}

####And the output is:

2014-11-07 20:35:04 INFO  NettyTransport:133 - RMI server started: /0:0:0:0:0:0:0:0:46770.
2014-11-07 20:35:04 INFO  ExampleServer:45 - proxy RemoteObject{UnicastRef{remoteObjectAddress=RemoteObjectAddress{url='rmi://127.0.1.1:46770', objectId=0}, remoteInterfaces=[interface org.async.rmi.Exported, interface org.async.example.embedded.Example]}}@1310540333 saved to file  /home/barakbo/opensource/asyncrmi/ExampleServer.proxy, server is running at: {}:{}
2014-11-07 20:35:04 DEBUG UnicastRef:83 - 127.0.0.1:52244 --> 127.0.1.1:46770 : Request [echo] {requestId=0, objectId=0, methodId=5525131960618330777, params=[foo]}
2014-11-07 20:35:04 DEBUG ExampleServer:20 - Server: called echo(foo)
2014-11-07 20:35:04 DEBUG ObjectRef:63 - 127.0.1.1:46770 --> 127.0.0.1:52244 : Response [echo] {requestId=0, result=foo, error=null}
2014-11-07 20:35:04 INFO  ExampleServer:54 - client got: foo
2014-11-07 20:35:04 DEBUG UnicastRef:83 - 127.0.0.1:52245 --> 127.0.1.1:46770 : Request [echo] {requestId=1, objectId=0, methodId=5525131960618330777, params=[foo1]}
2014-11-07 20:35:04 DEBUG ExampleServer:20 - Server: called echo(foo1)
2014-11-07 20:35:04 DEBUG ObjectRef:63 - 127.0.1.1:46770 --> 127.0.0.1:52245 : Response [echo] {requestId=1, result=foo1, error=null}
2014-11-07 20:35:04 INFO  ExampleServer:56 - client got: foo1
2014-11-07 20:35:04 DEBUG UnicastRef:83 - 127.0.0.1:52246 --> 127.0.1.1:46770 : Request [futuredEcho] {requestId=2, objectId=0, methodId=2725453114525883975, params=[async foo]}
2014-11-07 20:35:04 DEBUG ExampleServer:26 - Server: futuredEcho echo(async foo)
2014-11-07 20:35:14 DEBUG ObjectRef:63 - 127.0.1.1:46770 --> 127.0.0.1:52246 : Response [futuredEcho] {requestId=2, result=async foo, error=null}
2014-11-07 20:35:14 DEBUG ExampleServer:60 - client got async res : async foo

The example code.

Versions

Version
1.0.3
1.0.2
1.0