org.springframework.messaging.simp.broker.AbstractBrokerMessageHandler Java Examples

The following examples show how to use org.springframework.messaging.simp.broker.AbstractBrokerMessageHandler. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AbstractMessageBrokerConfiguration.java    From spring-analysis-note with MIT License 6 votes vote down vote up
@Bean
@Nullable
public AbstractBrokerMessageHandler stompBrokerRelayMessageHandler() {
	StompBrokerRelayMessageHandler handler = getBrokerRegistry().getStompBrokerRelay(brokerChannel());
	if (handler == null) {
		return null;
	}
	Map<String, MessageHandler> subscriptions = new HashMap<>(4);
	String destination = getBrokerRegistry().getUserDestinationBroadcast();
	if (destination != null) {
		subscriptions.put(destination, userDestinationMessageHandler());
	}
	destination = getBrokerRegistry().getUserRegistryBroadcast();
	if (destination != null) {
		subscriptions.put(destination, userRegistryMessageHandler());
	}
	handler.setSystemSubscriptions(subscriptions);
	updateUserDestinationResolver(handler);
	return handler;
}
 
Example #2
Source File: WebSocketMessageBrokerConfigurationSupport.java    From spring-analysis-note with MIT License 6 votes vote down vote up
@Bean
public WebSocketMessageBrokerStats webSocketMessageBrokerStats() {
	AbstractBrokerMessageHandler relayBean = stompBrokerRelayMessageHandler();

	// Ensure STOMP endpoints are registered
	stompWebSocketHandlerMapping();

	WebSocketMessageBrokerStats stats = new WebSocketMessageBrokerStats();
	stats.setSubProtocolWebSocketHandler((SubProtocolWebSocketHandler) subProtocolWebSocketHandler());
	if (relayBean instanceof StompBrokerRelayMessageHandler) {
		stats.setStompBrokerRelay((StompBrokerRelayMessageHandler) relayBean);
	}
	stats.setInboundChannelExecutor(clientInboundChannelExecutor());
	stats.setOutboundChannelExecutor(clientOutboundChannelExecutor());
	stats.setSockJsTaskScheduler(messageBrokerTaskScheduler());
	return stats;
}
 
Example #3
Source File: AbstractMessageBrokerConfiguration.java    From java-technology-stack with MIT License 6 votes vote down vote up
@Bean
@Nullable
public AbstractBrokerMessageHandler stompBrokerRelayMessageHandler() {
	StompBrokerRelayMessageHandler handler = getBrokerRegistry().getStompBrokerRelay(brokerChannel());
	if (handler == null) {
		return null;
	}
	Map<String, MessageHandler> subscriptions = new HashMap<>(4);
	String destination = getBrokerRegistry().getUserDestinationBroadcast();
	if (destination != null) {
		subscriptions.put(destination, userDestinationMessageHandler());
	}
	destination = getBrokerRegistry().getUserRegistryBroadcast();
	if (destination != null) {
		subscriptions.put(destination, userRegistryMessageHandler());
	}
	handler.setSystemSubscriptions(subscriptions);
	updateUserDestinationResolver(handler);
	return handler;
}
 
Example #4
Source File: WebSocketMessageBrokerConfigurationSupport.java    From java-technology-stack with MIT License 6 votes vote down vote up
@Bean
public WebSocketMessageBrokerStats webSocketMessageBrokerStats() {
	AbstractBrokerMessageHandler relayBean = stompBrokerRelayMessageHandler();

	// Ensure STOMP endpoints are registered
	stompWebSocketHandlerMapping();

	WebSocketMessageBrokerStats stats = new WebSocketMessageBrokerStats();
	stats.setSubProtocolWebSocketHandler((SubProtocolWebSocketHandler) subProtocolWebSocketHandler());
	if (relayBean instanceof StompBrokerRelayMessageHandler) {
		stats.setStompBrokerRelay((StompBrokerRelayMessageHandler) relayBean);
	}
	stats.setInboundChannelExecutor(clientInboundChannelExecutor());
	stats.setOutboundChannelExecutor(clientOutboundChannelExecutor());
	stats.setSockJsTaskScheduler(messageBrokerTaskScheduler());
	return stats;
}
 
Example #5
Source File: AbstractMessageBrokerConfiguration.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
@Bean
public AbstractBrokerMessageHandler stompBrokerRelayMessageHandler() {
	StompBrokerRelayMessageHandler handler = getBrokerRegistry().getStompBrokerRelay(brokerChannel());
	if (handler == null) {
		return new NoOpBrokerMessageHandler();
	}
	Map<String, MessageHandler> subscriptions = new HashMap<String, MessageHandler>(1);
	String destination = getBrokerRegistry().getUserDestinationBroadcast();
	if (destination != null) {
		subscriptions.put(destination, userDestinationMessageHandler());
	}
	destination = getBrokerRegistry().getUserRegistryBroadcast();
	if (destination != null) {
		subscriptions.put(destination, userRegistryMessageHandler());
	}
	handler.setSystemSubscriptions(subscriptions);
	return handler;
}
 
Example #6
Source File: WebSocketMessageBrokerConfigurationSupport.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
@Bean
public WebSocketMessageBrokerStats webSocketMessageBrokerStats() {
	AbstractBrokerMessageHandler relayBean = stompBrokerRelayMessageHandler();
	StompBrokerRelayMessageHandler brokerRelay = (relayBean instanceof StompBrokerRelayMessageHandler ?
			(StompBrokerRelayMessageHandler) relayBean : null);

	// Ensure STOMP endpoints are registered
	stompWebSocketHandlerMapping();

	WebSocketMessageBrokerStats stats = new WebSocketMessageBrokerStats();
	stats.setSubProtocolWebSocketHandler((SubProtocolWebSocketHandler) subProtocolWebSocketHandler());
	stats.setStompBrokerRelay(brokerRelay);
	stats.setInboundChannelExecutor(clientInboundChannelExecutor());
	stats.setOutboundChannelExecutor(clientOutboundChannelExecutor());
	stats.setSockJsTaskScheduler(messageBrokerTaskScheduler());
	return stats;
}
 
Example #7
Source File: AbstractMessageBrokerConfiguration.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Bean
@Nullable
public AbstractBrokerMessageHandler simpleBrokerMessageHandler() {
	SimpleBrokerMessageHandler handler = getBrokerRegistry().getSimpleBroker(brokerChannel());
	if (handler == null) {
		return null;
	}
	updateUserDestinationResolver(handler);
	return handler;
}
 
Example #8
Source File: AbstractMessageBrokerConfiguration.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Bean
@Nullable
public AbstractBrokerMessageHandler simpleBrokerMessageHandler() {
	SimpleBrokerMessageHandler handler = getBrokerRegistry().getSimpleBroker(brokerChannel());
	if (handler == null) {
		return null;
	}
	updateUserDestinationResolver(handler);
	return handler;
}
 
Example #9
Source File: AbstractMessageBrokerConfiguration.java    From spring-analysis-note with MIT License 4 votes vote down vote up
private void updateUserDestinationResolver(AbstractBrokerMessageHandler handler) {
	Collection<String> prefixes = handler.getDestinationPrefixes();
	if (!prefixes.isEmpty() && !prefixes.iterator().next().startsWith("/")) {
		((DefaultUserDestinationResolver) userDestinationResolver()).setRemoveLeadingSlash(true);
	}
}
 
Example #10
Source File: AbstractMessageBrokerConfiguration.java    From java-technology-stack with MIT License 4 votes vote down vote up
private void updateUserDestinationResolver(AbstractBrokerMessageHandler handler) {
	Collection<String> prefixes = handler.getDestinationPrefixes();
	if (!prefixes.isEmpty() && !prefixes.iterator().next().startsWith("/")) {
		((DefaultUserDestinationResolver) userDestinationResolver()).setRemoveLeadingSlash(true);
	}
}
 
Example #11
Source File: AbstractMessageBrokerConfiguration.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@Bean
public AbstractBrokerMessageHandler simpleBrokerMessageHandler() {
	SimpleBrokerMessageHandler handler = getBrokerRegistry().getSimpleBroker(brokerChannel());
	return (handler != null ? handler : new NoOpBrokerMessageHandler());
}
 
Example #12
Source File: AbstractBrokerRegistration.java    From spring-analysis-note with MIT License votes vote down vote up
protected abstract AbstractBrokerMessageHandler getMessageHandler(SubscribableChannel brokerChannel); 
Example #13
Source File: AbstractBrokerRegistration.java    From java-technology-stack with MIT License votes vote down vote up
protected abstract AbstractBrokerMessageHandler getMessageHandler(SubscribableChannel brokerChannel); 
Example #14
Source File: AbstractBrokerRegistration.java    From spring4-understanding with Apache License 2.0 votes vote down vote up
protected abstract AbstractBrokerMessageHandler getMessageHandler(SubscribableChannel brokerChannel);