我只是选择了一个带有 RSocket 启动器的 springboot 应用程序示例:
构建,然后运行可运行的 jar 给我以下日志:
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.2.1.RELEASE)
2019-12-04 09:45:20.985 INFO 12928 --- [ main] com.example.DemoApplication : Starting DemoApplication on XXX with PID 1234 (demo/target/classes started by me in ~/demo)
2019-12-04 09:45:20.987 INFO 12928 --- [ main] com.example.DemoApplication : No active profile set, falling back to default profiles: default
2019-12-04 09:45:21.761 INFO 12928 --- [ main] com.example.DemoApplication : Started DemoApplication in 1.172 seconds (JVM running for 2.378)
Process finished with exit code 0
问题是 Springboot 主线程立即停止而无需等待 RSocket 请求。我想问题是 RSocket 服务器没有启动所以我尝试添加一个这样的 RSocket 控制器:
@Controller
public class DemoController {
@MessageMapping("retreiveSomeData")
public Mono<Data> retreiveAccount(String criteria) {
return Mono.just(new Data());
}
}
结果一样^^
任何使用带有 SpringBoot 的 RSocket 的人都找到了一种强制 Springboot 线程等待的“漂亮”方法?