Java RMI Resources

后端 未结 10 1732
一生所求
一生所求 2021-02-07 23:40

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

10条回答
  •  名媛妹妹
    2021-02-08 00:15

    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

提交回复
热议问题