Now we implement the RSocket service like this:
- Reactive service interface
public interface AccountService {
Mono<Account> findById(Integer id);
Flux<Account> findAll();
}
- Service implementation with RSocket Exposed
@Controller
@MessageMapping("org.xxxxx.account.AccountService")
public class AccountServiceImpl implements AccountService {
@Override
@MessageMapping("findById")
public Mono<Account> findById(Integer id) {
return Mono.just(new Account(id, "nick:" + id));
}
@Override
@MessageMapping("findAll")
public Flux<Account> findAll() {
return Flux.just(new Account(1, "Jackie"), new Account(2, "Tom"));
}
}
- Client call with Java Proxy InvocationHandler
return (T) Proxy.newProxyInstance(
serviceInterface.getClassLoader(),
new Class[]{serviceInterface},
new RSocketReactiveServiceProxy(rsocketRequester, serviceInterface, timeout));
Any plan to support this feature by default to make it easy for Java Developers. Now RsocketRequester is alike WebClient, but every developer can understand HTTP, and it's hard to developer to understand RSocket protocol.
Comment From: rstoyanchev
I think this would be useful for an RPC mechanism to have such a contract-driven approach.
Comment From: spencergibb
https://github.com/spring-projects-experimental/spring-retrosocket /cc @joshlong
Comment From: linux-china
https://github.com/spring-projects-experimental/spring-retrosocket /cc @joshlong
@spencergibb It's correct. Now I use retrosocket for demo and introduce it to other developers.
Comment From: kitkars
@linux-china @spencergibb is this retrosocket still under development?
Comment From: spencergibb
@kitkars it's experimental and maintained by @joshlong
Comment From: kitkars
Looks like a great feature to have! Thanks for confirming. @spencergibb
Comment From: spencergibb
Nice. Well done!