Springboot 2 RSocket 应用程序启动然后立即停止,没有错误消息
Springboot 2 RSocket application starts then stops immediately with no error message
我只是选择了一个带有 RSocket starter 的 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());
}
}
同样的结果^^
任何将 RSocket 与 SpringBoot 一起使用的人都找到了 "beautiful" 强制 Springboot 线程等待的方法吗?
解决方案是添加 RSocket 配置。
只需添加以下内容 application.yaml
:
# application.yaml
spring:
rsocket:
server:
port: 7000
然后 Netty 服务器将在端口 7000 上启动:
. ____ _ __ _ _
/\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.2.1.RELEASE)
INFO 4472 --- [ main] com.example.DemoApplication : Starting DemoApplication on ...
INFO 4472 --- [ main] com.example.DemoApplication : No active profile set, falling back to default profiles: default
INFO 4472 --- [ main] o.s.b.rsocket.netty.NettyRSocketServer : Netty RSocket started on port(s): 7000
INFO 4472 --- [ main] com.example.DemoApplication : Started DemoApplication in 2.704 seconds (JVM running for 3.142)
我只是选择了一个带有 RSocket starter 的 springboot 应用程序示例:
. ____ _ __ _ _
/\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: 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());
}
}
同样的结果^^
任何将 RSocket 与 SpringBoot 一起使用的人都找到了 "beautiful" 强制 Springboot 线程等待的方法吗?
解决方案是添加 RSocket 配置。
只需添加以下内容 application.yaml
:
# application.yaml
spring:
rsocket:
server:
port: 7000
然后 Netty 服务器将在端口 7000 上启动:
. ____ _ __ _ _
/\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.2.1.RELEASE)
INFO 4472 --- [ main] com.example.DemoApplication : Starting DemoApplication on ...
INFO 4472 --- [ main] com.example.DemoApplication : No active profile set, falling back to default profiles: default
INFO 4472 --- [ main] o.s.b.rsocket.netty.NettyRSocketServer : Netty RSocket started on port(s): 7000
INFO 4472 --- [ main] com.example.DemoApplication : Started DemoApplication in 2.704 seconds (JVM running for 3.142)