private void updateUserDestinationResolver(AbstractBrokerMessageHandler handler) { Collection<String> prefixes = handler.getDestinationPrefixes(); if (!prefixes.isEmpty() && !prefixes.iterator().next().startsWith("/")) { ((DefaultUserDestinationResolver) userDestinationResolver()).setRemoveLeadingSlash(true); } }
@Override public void afterSendCompletion( Message<?> message, MessageChannel channel, boolean sent, @Nullable Exception ex) { if (!sent) { SimpMessageType messageType = SimpMessageHeaderAccessor.getMessageType(message.getHeaders()); if (SimpMessageType.DISCONNECT.equals(messageType)) { logger.debug("Detected unsent DISCONNECT message. Processing anyway."); handleMessage(message); } } } }
/** * Get the MessageChannel to use for sending messages to clients, possibly * a per-session wrapper when {@code preservePublishOrder=true}. * @since 5.1 */ protected MessageChannel getClientOutboundChannelForSession(String sessionId) { return this.preservePublishOrder ? new OrderedMessageSender(getClientOutboundChannel(), logger) : getClientOutboundChannel(); }
@Override public final void stop(Runnable callback) { synchronized (this.lifecycleMonitor) { stop(); callback.run(); } }
@Override public void start() { synchronized (this.lifecycleMonitor) { logger.info("Starting..."); this.clientInboundChannel.subscribe(this); this.brokerChannel.subscribe(this); if (this.clientInboundChannel instanceof InterceptableChannel) { ((InterceptableChannel) this.clientInboundChannel).addInterceptor(0, this.unsentDisconnectInterceptor); } startInternal(); this.running = true; logger.info("Started."); } }
@Override public void handleMessage(Message<?> message) { if (!this.running) { if (logger.isTraceEnabled()) { logger.trace(this + " not running yet. Ignoring " + message); } return; } handleMessageInternal(message); }
@Override public void stop() { synchronized (this.lifecycleMonitor) { logger.info("Stopping..."); stopInternal(); this.clientInboundChannel.unsubscribe(this); this.brokerChannel.unsubscribe(this); if (this.clientInboundChannel instanceof InterceptableChannel) { ((InterceptableChannel) this.clientInboundChannel).removeInterceptor(this.unsentDisconnectInterceptor); } this.running = false; logger.info("Stopped."); } }
@Override public final void stop(Runnable callback) { synchronized (this.lifecycleMonitor) { stop(); callback.run(); } }
@Override public void start() { synchronized (this.lifecycleMonitor) { logger.info("Starting..."); this.clientInboundChannel.subscribe(this); this.brokerChannel.subscribe(this); if (this.clientInboundChannel instanceof InterceptableChannel) { ((InterceptableChannel) this.clientInboundChannel).addInterceptor(0, this.unsentDisconnectInterceptor); } startInternal(); this.running = true; logger.info("Started."); } }
@Override public void handleMessage(Message<?> message) { if (!this.running) { if (logger.isTraceEnabled()) { logger.trace(this + " not running yet. Ignoring " + message); } return; } handleMessageInternal(message); }
@Override public void stop() { synchronized (this.lifecycleMonitor) { logger.info("Stopping..."); stopInternal(); this.clientInboundChannel.unsubscribe(this); this.brokerChannel.unsubscribe(this); if (this.clientInboundChannel instanceof InterceptableChannel) { ((InterceptableChannel) this.clientInboundChannel).removeInterceptor(this.unsentDisconnectInterceptor); } this.running = false; logger.info("Stopped."); } }
private boolean checkDestinationPrefix(String destination) { if (this.useBroker) { Collection<String> destinationPrefixes = this.brokerHandler.getDestinationPrefixes(); if ((destination == null) || CollectionUtils.isEmpty(destinationPrefixes)) { return false; } return destinationPrefixes.stream().anyMatch(destination::startsWith); } return false; }
@Override public void afterSendCompletion( Message<?> message, MessageChannel channel, boolean sent, @Nullable Exception ex) { if (!sent) { SimpMessageType messageType = SimpMessageHeaderAccessor.getMessageType(message.getHeaders()); if (SimpMessageType.DISCONNECT.equals(messageType)) { logger.debug("Detected unsent DISCONNECT message. Processing anyway."); handleMessage(message); } } } }
@Override public final void stop(Runnable callback) { synchronized (this.lifecycleMonitor) { stop(); callback.run(); } }
/** * Get the MessageChannel to use for sending messages to clients, possibly * a per-session wrapper when {@code preservePublishOrder=true}. * @since 5.1 */ protected MessageChannel getClientOutboundChannelForSession(String sessionId) { return this.preservePublishOrder ? new OrderedMessageSender(getClientOutboundChannel(), logger) : getClientOutboundChannel(); }
@Override public void start() { synchronized (this.lifecycleMonitor) { logger.info("Starting..."); this.clientInboundChannel.subscribe(this); this.brokerChannel.subscribe(this); if (this.clientInboundChannel instanceof InterceptableChannel) { ((InterceptableChannel) this.clientInboundChannel).addInterceptor(0, this.unsentDisconnectInterceptor); } startInternal(); this.running = true; logger.info("Started."); } }
@Override public void handleMessage(Message<?> message) { if (!this.running) { if (logger.isTraceEnabled()) { logger.trace(this + " not running yet. Ignoring " + message); } return; } handleMessageInternal(message); }
@Override public void stop() { synchronized (this.lifecycleMonitor) { logger.info("Stopping..."); stopInternal(); this.clientInboundChannel.unsubscribe(this); this.brokerChannel.unsubscribe(this); if (this.clientInboundChannel instanceof InterceptableChannel) { ((InterceptableChannel) this.clientInboundChannel).removeInterceptor(this.unsentDisconnectInterceptor); } this.running = false; logger.info("Stopped."); } }
private void updateUserDestinationResolver(AbstractBrokerMessageHandler handler) { Collection<String> prefixes = handler.getDestinationPrefixes(); if (!prefixes.isEmpty() && !prefixes.iterator().next().startsWith("/")) { ((DefaultUserDestinationResolver) userDestinationResolver()).setRemoveLeadingSlash(true); } }
this.brokerHandler.handleMessage(message);