I am currently undertaking a project that involves extensive use of Java RMI and I was wondering if anyone is aware of any good resources about it.
The problem I am havi
Here is another good example of remote method invocation with Redisson framework:
Let's assume YourServiceImpl
contains method you need to invoke remotely and implements YourService
interface.
YourServiceImpl should be registered in Redisson via RemoteService object:
YourService yourService = new YourServiceImpl();
RRemoteService remoteService = redisson.getRemoteService();
remoteService.register(YourService.class, yourService);
To invoke method remotely only service interface is needed:
RRemoteService remoteService = redisson.getRemoteService();
YourService service = remoteService.get(YourService.class);
MyObject result = service.myMethod(someParam1, someParam2);
Also it supports asynchronous calls.
// async interface for YourService
@RRemoteAsync(YourService.class)
public interface YourServiceAsync {
RFuture someMethod1(Long param1, String param2);
RFuture someMethod2(MyObject param);
}
RRemoteService remoteService = redisson.getRemoteService();
YourServiceAsync asyncService = remoteService.get(YourServiceAsync.class);
RFuture res = asyncService.someMethod1(12L, "param");
res.thenApply(r -> {
...
});
More details here