use of org.springframework.messaging.simp.broker.SimpleBrokerMessageHandler in project spring-integration by spring-projects.
the class WebSocketInboundChannelAdapter method onInit.
@Override
protected void onInit() {
super.onInit();
this.webSocketContainer.setMessageListener(this);
if (!CollectionUtils.isEmpty(this.messageConverters)) {
List<MessageConverter> converters = this.messageConverter.getConverters();
if (this.mergeWithDefaultConverters) {
ListIterator<MessageConverter> iterator = this.messageConverters.listIterator(this.messageConverters.size());
while (iterator.hasPrevious()) {
MessageConverter converter = iterator.previous();
converters.add(0, converter);
}
} else {
converters.clear();
converters.addAll(this.messageConverters);
}
}
if (this.server && this.useBroker) {
Map<String, AbstractBrokerMessageHandler> brokers = getApplicationContext().getBeansOfType(AbstractBrokerMessageHandler.class);
for (AbstractBrokerMessageHandler broker : brokers.values()) {
if (broker instanceof SimpleBrokerMessageHandler || broker instanceof StompBrokerRelayMessageHandler) {
this.brokerHandler = broker;
break;
}
}
Assert.state(this.brokerHandler != null, "WebSocket Broker Relay isn't present in the application context; " + "it is required when 'useBroker = true'.");
}
}
use of org.springframework.messaging.simp.broker.SimpleBrokerMessageHandler in project spring-framework by spring-projects.
the class WebSocketMessageBrokerConfigurationSupportTests method taskScheduler.
@Test
void taskScheduler() {
ApplicationContext context = createContext(TestChannelConfig.class, TestConfigurer.class);
String name = "messageBrokerSockJsTaskScheduler";
ThreadPoolTaskScheduler taskScheduler = context.getBean(name, ThreadPoolTaskScheduler.class);
ScheduledThreadPoolExecutor executor = taskScheduler.getScheduledThreadPoolExecutor();
assertThat(executor.getCorePoolSize()).isEqualTo(Runtime.getRuntime().availableProcessors());
assertThat(executor.getRemoveOnCancelPolicy()).isTrue();
SimpleBrokerMessageHandler handler = context.getBean(SimpleBrokerMessageHandler.class);
assertThat(handler.getTaskScheduler()).isNotNull();
assertThat(handler.getHeartbeatValue()).containsExactly(15000, 15000);
}
use of org.springframework.messaging.simp.broker.SimpleBrokerMessageHandler in project spring-framework by spring-projects.
the class SimpleBrokerRegistration method getMessageHandler.
@Override
protected SimpleBrokerMessageHandler getMessageHandler(SubscribableChannel brokerChannel) {
SimpleBrokerMessageHandler handler = new SimpleBrokerMessageHandler(getClientInboundChannel(), getClientOutboundChannel(), brokerChannel, getDestinationPrefixes());
if (this.taskScheduler != null) {
handler.setTaskScheduler(this.taskScheduler);
}
if (this.heartbeat != null) {
handler.setHeartbeatValue(this.heartbeat);
}
handler.setSelectorHeaderName(this.selectorHeaderName);
return handler;
}
use of org.springframework.messaging.simp.broker.SimpleBrokerMessageHandler in project spring-framework by spring-projects.
the class MessageBrokerConfigurationTests method clientOutboundChannelCustomized.
@Test
public void clientOutboundChannelCustomized() {
ApplicationContext context = loadConfig(CustomConfig.class);
AbstractSubscribableChannel channel = context.getBean("clientOutboundChannel", AbstractSubscribableChannel.class);
assertThat(channel.getInterceptors().size()).isEqualTo(4);
ThreadPoolTaskExecutor taskExecutor = context.getBean("clientOutboundChannelExecutor", ThreadPoolTaskExecutor.class);
assertThat(taskExecutor.getCorePoolSize()).isEqualTo(21);
assertThat(taskExecutor.getMaxPoolSize()).isEqualTo(22);
assertThat(taskExecutor.getKeepAliveSeconds()).isEqualTo(23);
SimpleBrokerMessageHandler broker = context.getBean("simpleBrokerMessageHandler", SimpleBrokerMessageHandler.class);
assertThat(broker.isPreservePublishOrder()).isTrue();
}
use of org.springframework.messaging.simp.broker.SimpleBrokerMessageHandler in project spring-framework by spring-projects.
the class MessageBrokerConfigurationTests method customPathMatcher.
@Test
public void customPathMatcher() {
ApplicationContext context = loadConfig(CustomConfig.class);
SimpleBrokerMessageHandler broker = context.getBean(SimpleBrokerMessageHandler.class);
DefaultSubscriptionRegistry registry = (DefaultSubscriptionRegistry) broker.getSubscriptionRegistry();
assertThat(registry.getPathMatcher().combine("a", "a")).isEqualTo("a.a");
PathMatcher pathMatcher = context.getBean(SimpAnnotationMethodMessageHandler.class).getPathMatcher();
assertThat(pathMatcher.combine("a", "a")).isEqualTo("a.a");
DefaultUserDestinationResolver resolver = context.getBean(DefaultUserDestinationResolver.class);
assertThat(resolver).isNotNull();
assertThat(resolver.isRemoveLeadingSlash()).isFalse();
}
Aggregations