【发布时间】:2019-07-08 02:49:21
【问题描述】:
我是 stomp 的新手,使用 spring boot 2.1.2.RELEASE。我有多个端点并配置了ChannelInterceptor 以获取一些信息。
@Override
public void registerStompEndpoints(StompEndpointRegistry registry) {
registry.addEndpoint("/endpoint1")
.addInterceptors(new IpHandshakeInterceptor())
.setAllowedOrigins(origin)
.withSockJS();
registry.addEndpoint("/endpoint2")
.addInterceptors(new IpHandshakeInterceptor())
.setAllowedOrigins(origin)
.withSockJS();
// other andpoint
}
@Override
public void configureClientInboundChannel(ChannelRegistration registration) {
registration.interceptors(myChannelInterceptor());
}
所有端点都使用myChannelInterceptor(实际上,我希望端点使用自己的ChannelInterceptor),我想通过端点路径在ChannelInterceptor中做事。
@Override
public Message<?> preSend(Message<?> message, MessageChannel channel) {
if (endpoint.equals("endpoint1")) {
} else if (endpoint.equals("endpoint2")) {
}
}
如何在ChannelInterceptor 中获取endpoint 信息?
【问题讨论】:
标签: spring-boot stomp