/** * An accessor for the {@link MessageBrokerRegistry} that ensures its one-time creation * and initialization through {@link #configureMessageBroker(MessageBrokerRegistry)}. */ protected final MessageBrokerRegistry getBrokerRegistry() { if (this.brokerRegistry == null) { MessageBrokerRegistry registry = new MessageBrokerRegistry(clientInboundChannel(), clientOutboundChannel()); configureMessageBroker(registry); this.brokerRegistry = registry; } return this.brokerRegistry; }
/** * Configure the thread pool backing this message channel. */ public TaskExecutorRegistration taskExecutor() { return taskExecutor(null); }
/** * Enable a STOMP broker relay and configure the destination prefixes supported by the * message broker. Check the STOMP documentation of the message broker for supported * destinations. */ public StompBrokerRelayRegistration enableStompBrokerRelay(String... destinationPrefixes) { this.brokerRelayRegistration = new StompBrokerRelayRegistration( this.clientInboundChannel, this.clientOutboundChannel, destinationPrefixes); return this.brokerRelayRegistration; }
@Override public void configureMessageBroker(MessageBrokerRegistry configurer) { configurer.setApplicationDestinationPrefixes("/app"); configurer.enableSimpleBroker("/topic", "/queue"); }
@Override protected void configureMessageBroker(MessageBrokerRegistry registry) { registry.configureBrokerChannel().interceptors(this.interceptor, this.interceptor, this.interceptor); registry.configureBrokerChannel().taskExecutor() .corePoolSize(31).maxPoolSize(32).keepAliveSeconds(33).queueCapacity(34); registry.setPathMatcher(new AntPathMatcher(".")).enableSimpleBroker("/topic", "/queue"); registry.setCacheLimit(8192); registry.setPreservePublishOrder(true); registry.setUserRegistryOrder(99); } }
@Override protected void configureMessageBroker(MessageBrokerRegistry registry) { super.configureMessageBroker(registry); registry.enableSimpleBroker("/topic", "/queue"); } }
@Override public void configureMessageBroker(MessageBrokerRegistry registry) { registry.enableSimpleBroker() .setTaskScheduler(mock(TaskScheduler.class)) .setHeartbeatValue(new long[] {15000, 15000}); } }
@Override protected void configureClientInboundChannel(ChannelRegistration registration) { registration.interceptors(this.interceptor); registration.taskExecutor(new CustomThreadPoolTaskExecutor()) .corePoolSize(11).maxPoolSize(12).keepAliveSeconds(13).queueCapacity(14); }
@Bean public ThreadPoolTaskExecutor brokerChannelExecutor() { ChannelRegistration reg = getBrokerRegistry().getBrokerChannelRegistration(); ThreadPoolTaskExecutor executor; if (reg.hasTaskExecutor()) { executor = reg.taskExecutor().getTaskExecutor(); } else { // Should never be used executor = new ThreadPoolTaskExecutor(); executor.setCorePoolSize(0); executor.setMaxPoolSize(1); executor.setQueueCapacity(0); } executor.setThreadNamePrefix("brokerChannel-"); return executor; }
protected final ChannelRegistration getClientOutboundChannelRegistration() { if (this.clientOutboundChannelRegistration == null) { ChannelRegistration registration = new ChannelRegistration(); configureClientOutboundChannel(registration); registration.interceptors(new ImmutableMessageChannelInterceptor()); this.clientOutboundChannelRegistration = registration; } return this.clientOutboundChannelRegistration; }
protected final ChannelRegistration getClientInboundChannelRegistration() { if (this.clientInboundChannelRegistration == null) { ChannelRegistration registration = new ChannelRegistration(); configureClientInboundChannel(registration); registration.interceptors(new ImmutableMessageChannelInterceptor()); this.clientInboundChannelRegistration = registration; } return this.clientInboundChannelRegistration; }
@Bean public ThreadPoolTaskExecutor clientInboundChannelExecutor() { TaskExecutorRegistration reg = getClientInboundChannelRegistration().taskExecutor(); ThreadPoolTaskExecutor executor = reg.getTaskExecutor(); executor.setThreadNamePrefix("clientInboundChannel-"); return executor; }
@Bean public ThreadPoolTaskExecutor clientOutboundChannelExecutor() { TaskExecutorRegistration reg = getClientOutboundChannelRegistration().taskExecutor(); ThreadPoolTaskExecutor executor = reg.getTaskExecutor(); executor.setThreadNamePrefix("clientOutboundChannel-"); return executor; }
@Bean @Nullable public AbstractBrokerMessageHandler simpleBrokerMessageHandler() { SimpleBrokerMessageHandler handler = getBrokerRegistry().getSimpleBroker(brokerChannel()); if (handler == null) { return null; } updateUserDestinationResolver(handler); return handler; }
@Override public void configureMessageBroker(MessageBrokerRegistry registry) { registry.enableStompBrokerRelay("/topic", "/queue").setAutoStartup(true) .setUserDestinationBroadcast("/topic/unresolved-user-destination") .setUserRegistryBroadcast("/topic/simp-user-registry"); } }
/** * Provide access to the configured PatchMatcher for access from other * configuration classes. */ @Nullable public final PathMatcher getPathMatcher() { return getBrokerRegistry().getPathMatcher(); }
/** * Enable a simple message broker and configure one or more prefixes to filter * destinations targeting the broker (e.g. destinations prefixed with "/topic"). */ public SimpleBrokerRegistration enableSimpleBroker(String... destinationPrefixes) { this.simpleBrokerRegistration = new SimpleBrokerRegistration( this.clientInboundChannel, this.clientOutboundChannel, destinationPrefixes); return this.simpleBrokerRegistration; }
@Override public void configureMessageBroker(MessageBrokerRegistry configurer) { configurer.setApplicationDestinationPrefixes("/app"); configurer.enableSimpleBroker("/topic", "/queue"); } }
@Override protected void configureMessageBroker(MessageBrokerRegistry registry) { super.configureMessageBroker(registry); registry.enableSimpleBroker("topic.", "queue."); } }
@Override protected void configureClientOutboundChannel(ChannelRegistration registration) { registration.interceptors(this.interceptor, this.interceptor); registration.taskExecutor().corePoolSize(21).maxPoolSize(22).keepAliveSeconds(23).queueCapacity(24); }