跳到主要内容

Alibaba RSocket Broker with Spring Boot 2.7.0

· 阅读需 1 分钟
linux_china

Spring Boot 2.7.0正式发布了,详细请参考 https://spring.io/blog/2022/05/19/spring-boot-2-7-0-available-now 其中包括了不少新特性,这里列举一下:

@RestController
public class UserController {

@GetMapping("/user")
public User user() {
return new User(1L, "jaciej", "my-secret-password");
}
}

record User(Long id, String username, String password) {}

@JsonMixin(User.class)
class UserMixin {
@JsonIgnore
private String password;
}

  • SSL配置支持PEM格式证书
server.ssl.enabled=true
server.http2.enabled=true
server.ssl.certificate-private-key=classpath:cert/key.pem
server.ssl.certificate=classpath:cert/cert.pem
server.ssl.key-store-password=changeit

SSL的PEM配置同样适用于RSocket TCP Server,对应的配置项如下:

spring.rsocket.server.ssl.certificate-private-key=classpath:cert/key.pem
spring.rsocket.server.ssl.certificate=classpath:cert/cert.pem
  • RSocket handler支持 @Authenticated Principal
@MessageMapping ("test") 
Mono<String> hello (@Authenticated Principal p){
return Mono.just ("Hello, " + p.getName()) ;
}

当然Alibaba RSocket Broker也是支持Spring Boot 2.7.0的,此外也不要忘记Java 17的支持,祝大家开发愉快!