类org.springframework.messaging.simp.config.ChannelRegistration源码实例Demo

下面列出了怎么用org.springframework.messaging.simp.config.ChannelRegistration的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: Project   文件: WebSocketStompConfig.java
@Override
public void configureClientInboundChannel(ChannelRegistration registration) {
	registration.setInterceptors(new ChannelInterceptorAdapter() {

		@Override
		public Message<?> preSend(Message<?> message, MessageChannel channel) {
			System.out.println("configureClientInboundChannel");
			StompHeaderAccessor accessor = StompHeaderAccessor.wrap(message);
			User user = (User) accessor.getSessionAttributes().get("user");
			return super.preSend(message, channel);
		}
		
	});
}
 
/**
 * 通道
 *
 * @param registration
 */
@Override
public void configureClientInboundChannel ( ChannelRegistration registration ) {
	if ( Objects.nonNull( channelInterceptor ) ) {
		registration.interceptors( channelInterceptor );
	}

}
 
@Test
public void shouldRegisterInterceptors() {
    final AuthChannelInterceptorAdapter authAdaptor = mock(AuthChannelInterceptorAdapter.class);
    final WebSocketAuthenticationSecurityConfig webSocketAuthenticationSecurityConfig = spy(new WebSocketAuthenticationSecurityConfig(authAdaptor));

    final ChannelRegistration registration = mock(ChannelRegistration.class);
    webSocketAuthenticationSecurityConfig.configureClientInboundChannel(registration);

    verify(registration, times(1)).interceptors(any());
    verify(webSocketAuthenticationSecurityConfig, times(1)).createChannelInterceptors();
}
 
@Override
public void configureClientOutboundChannel(final ChannelRegistration registration)
{
	//
	// IMPORTANT: make sure we are using only one thread for sending outbound messages.
	// If not, it might be that the messages will not be sent in the right order,
	// and that's important for things like WS notifications API.
	// ( thanks to http://stackoverflow.com/questions/29689838/sockjs-receive-stomp-messages-from-spring-websocket-out-of-order )
	registration.taskExecutor()
			.corePoolSize(1)
			.maxPoolSize(1);
}
 
@Override
public void configureClientInboundChannel(final ChannelRegistration registration)
{
	registration.setInterceptors(new WebSocketChannelInterceptor());

	// NOTE: atm we don't care if the inbound messages arrived in the right order
	// When and If we would care we would restrict the taskExecutor()'s corePoolSize to ONE.
	// see: configureClientOutboundChannel().
}
 
@Override
protected void configureClientInboundChannel(ChannelRegistration registration) {
	for (WebSocketMessageBrokerConfigurer configurer : this.configurers) {
		configurer.configureClientInboundChannel(registration);
	}
}
 
@Override
protected void configureClientOutboundChannel(ChannelRegistration registration) {
	for (WebSocketMessageBrokerConfigurer configurer : this.configurers) {
		configurer.configureClientOutboundChannel(registration);
	}
}
 
@Override
public void configureClientInboundChannel(ChannelRegistration registration) {
}
 
@Override
public void configureClientOutboundChannel(ChannelRegistration registration) {
}
 
@Override
protected void configureClientInboundChannel(ChannelRegistration registration) {
	for (WebSocketMessageBrokerConfigurer configurer : this.configurers) {
		configurer.configureClientInboundChannel(registration);
	}
}
 
@Override
protected void configureClientOutboundChannel(ChannelRegistration registration) {
	for (WebSocketMessageBrokerConfigurer configurer : this.configurers) {
		configurer.configureClientOutboundChannel(registration);
	}
}
 
@Override
public void configureClientInboundChannel(ChannelRegistration registration) {
}
 
@Override
public void configureClientOutboundChannel(ChannelRegistration registration) {
}
 
源代码14 项目: tutorial   文件: WebSocketConfig.java
@Override
public void configureClientInboundChannel(ChannelRegistration registration) {
    // 注册一个自定义的拦截器
    registration.interceptors(new MyChannelInterceptorAdapter());
}
 
源代码15 项目: boot-actuator   文件: WebSocketConfig.java
@Override
public void configureClientInboundChannel(ChannelRegistration channelRegistration) {
}
 
源代码16 项目: boot-actuator   文件: WebSocketConfig.java
@Override
public void configureClientOutboundChannel(ChannelRegistration channelRegistration) {
}
 
源代码17 项目: flow-platform-x   文件: WebSocketConfig.java
@Override
public void configureClientInboundChannel(ChannelRegistration registration) {
    ThreadPoolTaskExecutor executor = ThreadHelper.createTaskExecutor(50, 50, 50, "ws-inbound-");
    registration.taskExecutor(executor);
}
 
源代码18 项目: flow-platform-x   文件: WebSocketConfig.java
@Override
public void configureClientOutboundChannel(ChannelRegistration registration) {
    ThreadPoolTaskExecutor executor = ThreadHelper.createTaskExecutor(50, 50, 50, "ws-outbound-");
    registration.taskExecutor(executor);
}
 
@Override
public void configureClientInboundChannel(final ChannelRegistration registration) {
    registration.interceptors(this.createChannelInterceptors());
}
 
@Override
public void configureClientInboundChannel(final ChannelRegistration registration) {
    registration.interceptors(this.authChannelInterceptorAdapter);
}
 
@Override
protected void configureClientInboundChannel(ChannelRegistration registration) {
	for (WebSocketMessageBrokerConfigurer configurer : this.configurers) {
		configurer.configureClientInboundChannel(registration);
	}
}
 
@Override
protected void configureClientOutboundChannel(ChannelRegistration registration) {
	for (WebSocketMessageBrokerConfigurer configurer : this.configurers) {
		configurer.configureClientOutboundChannel(registration);
	}
}
 
@Override
public void configureClientInboundChannel(ChannelRegistration registration) {
}
 
@Override
public void configureClientOutboundChannel(ChannelRegistration registration) {
}
 
源代码25 项目: haven-platform   文件: WebSocketConfiguration.java
@Override
public void configureClientInboundChannel(ChannelRegistration registration) {
    registration.setInterceptors(interceptor);
}
 
源代码26 项目: geode-demo-application   文件: WebSocketConfig.java
@Override
	public void configureClientInboundChannel(ChannelRegistration registration) {
}
 
源代码27 项目: geode-demo-application   文件: WebSocketConfig.java
@Override
public void configureClientOutboundChannel(ChannelRegistration registration) {
    registration.taskExecutor().corePoolSize(4).maxPoolSize(10);
}
 
源代码28 项目: cloudstreetmarket.com   文件: WebSocketConfig.java
@Override
public void configureClientInboundChannel(ChannelRegistration registration) {
	registration.taskExecutor().corePoolSize(Runtime.getRuntime().availableProcessors() *4);
}
 
源代码29 项目: cloudstreetmarket.com   文件: WebSocketConfig.java
@Override
//Increase number of threads for slow clients
public void configureClientOutboundChannel(ChannelRegistration registration) {
	registration.taskExecutor().corePoolSize(Runtime.getRuntime().availableProcessors() *4);
}
 
源代码30 项目: consensusj   文件: WebSocketConfig.java
@Override
public void configureClientInboundChannel(ChannelRegistration registration) {
}
 
 类方法
 同包方法