- 9.1.2. 发送即不管(Fire-and-Forget)模式和应答回执(Ack-Response)模式
9.1.2. 发送即不管(Fire-and-Forget)模式和应答回执(Ack-Response)模式
分布式远程服务通过org.redisson.core.RemoteInvocationOptions类,为每个远程过程调用提供了一些可配置选项。这些选项可以用来指定和修改请求超时和选择跳过应答回执或结果的发送模式。例如:
// 应答回执超时1秒钟,远程执行超时30秒钟RemoteInvocationOptions options = RemoteInvocationOptions.defaults();// 无需应答回执,远程执行超时30秒钟RemoteInvocationOptions options = RemoteInvocationOptions.defaults().noAck();// 应答回执超时1秒钟,不等待执行结果RemoteInvocationOptions options = RemoteInvocationOptions.defaults().noResult();// 应答回执超时1分钟,不等待执行结果RemoteInvocationOptions options = RemoteInvocationOptions.defaults().expectAckWithin(1, TimeUnit.MINUTES).noResult();// 发送即不管(Fire-and-Forget)模式,无需应答回执,不等待结果RemoteInvocationOptions options = RemoteInvocationOptions.defaults().noAck().noResult();RRemoteService remoteService = redisson.getRemoteService();YourService service = remoteService.get(YourService.class, options);
