/** * Set a destination to broadcast messages to that remain unresolved because * the user is not connected. In a multi-application server scenario this * gives other application servers a chance to try. * <p>By default this is not set. * @param destination the target destination. */ public void setBroadcastDestination(@Nullable String destination) { this.broadcastHandler = (StringUtils.hasText(destination) ? new BroadcastHandler(this.messagingTemplate, destination) : null); }
@Nullable public Message<?> preHandle(Message<?> message) throws MessagingException { String destination = SimpMessageHeaderAccessor.getDestination(message.getHeaders()); if (!getBroadcastDestination().equals(destination)) { return message; } SimpMessageHeaderAccessor accessor = SimpMessageHeaderAccessor.getAccessor(message, SimpMessageHeaderAccessor.class); Assert.state(accessor != null, "No SimpMessageHeaderAccessor"); if (accessor.getSessionId() == null) { // Our own broadcast return null; } destination = accessor.getFirstNativeHeader(SimpMessageHeaderAccessor.ORIGINAL_DESTINATION); if (logger.isTraceEnabled()) { logger.trace("Checking unresolved user destination: " + destination); } SimpMessageHeaderAccessor newAccessor = SimpMessageHeaderAccessor.create(SimpMessageType.MESSAGE); for (String name : accessor.toNativeHeaderMap().keySet()) { if (NO_COPY_LIST.contains(name)) { continue; } newAccessor.setNativeHeader(name, accessor.getFirstNativeHeader(name)); } if (destination != null) { newAccessor.setDestination(destination); } newAccessor.setHeader(SimpMessageHeaderAccessor.IGNORE_ERROR, true); // ensure send doesn't block return MessageBuilder.createMessage(message.getPayload(), newAccessor.getMessageHeaders()); }
Message<?> messageToUse = message; if (this.broadcastHandler != null) { messageToUse = this.broadcastHandler.preHandle(message); if (messageToUse == null) { return; this.broadcastHandler.handleUnresolved(messageToUse);
Message<?> messageToUse = message; if (this.broadcastHandler != null) { messageToUse = this.broadcastHandler.preHandle(message); if (messageToUse == null) { return; this.broadcastHandler.handleUnresolved(messageToUse);
Message<?> messageToUse = message; if (this.broadcastHandler != null) { messageToUse = this.broadcastHandler.preHandle(message); if (messageToUse == null) { return; this.broadcastHandler.handleUnresolved(messageToUse);
@Nullable public Message<?> preHandle(Message<?> message) throws MessagingException { String destination = SimpMessageHeaderAccessor.getDestination(message.getHeaders()); if (!getBroadcastDestination().equals(destination)) { return message; } SimpMessageHeaderAccessor accessor = SimpMessageHeaderAccessor.getAccessor(message, SimpMessageHeaderAccessor.class); Assert.state(accessor != null, "No SimpMessageHeaderAccessor"); if (accessor.getSessionId() == null) { // Our own broadcast return null; } destination = accessor.getFirstNativeHeader(SimpMessageHeaderAccessor.ORIGINAL_DESTINATION); if (logger.isTraceEnabled()) { logger.trace("Checking unresolved user destination: " + destination); } SimpMessageHeaderAccessor newAccessor = SimpMessageHeaderAccessor.create(SimpMessageType.MESSAGE); for (String name : accessor.toNativeHeaderMap().keySet()) { if (NO_COPY_LIST.contains(name)) { continue; } newAccessor.setNativeHeader(name, accessor.getFirstNativeHeader(name)); } if (destination != null) { newAccessor.setDestination(destination); } newAccessor.setHeader(SimpMessageHeaderAccessor.IGNORE_ERROR, true); // ensure send doesn't block return MessageBuilder.createMessage(message.getPayload(), newAccessor.getMessageHeaders()); }
@Nullable public Message<?> preHandle(Message<?> message) throws MessagingException { String destination = SimpMessageHeaderAccessor.getDestination(message.getHeaders()); if (!getBroadcastDestination().equals(destination)) { return message; } SimpMessageHeaderAccessor accessor = SimpMessageHeaderAccessor.getAccessor(message, SimpMessageHeaderAccessor.class); Assert.state(accessor != null, "No SimpMessageHeaderAccessor"); if (accessor.getSessionId() == null) { // Our own broadcast return null; } destination = accessor.getFirstNativeHeader(SimpMessageHeaderAccessor.ORIGINAL_DESTINATION); if (logger.isTraceEnabled()) { logger.trace("Checking unresolved user destination: " + destination); } SimpMessageHeaderAccessor newAccessor = SimpMessageHeaderAccessor.create(SimpMessageType.MESSAGE); for (String name : accessor.toNativeHeaderMap().keySet()) { if (NO_COPY_LIST.contains(name)) { continue; } newAccessor.setNativeHeader(name, accessor.getFirstNativeHeader(name)); } if (destination != null) { newAccessor.setDestination(destination); } newAccessor.setHeader(SimpMessageHeaderAccessor.IGNORE_ERROR, true); // ensure send doesn't block return MessageBuilder.createMessage(message.getPayload(), newAccessor.getMessageHeaders()); }
public void handleUnresolved(Message<?> message) { MessageHeaders headers = message.getHeaders(); if (SimpMessageHeaderAccessor.getFirstNativeHeader( SimpMessageHeaderAccessor.ORIGINAL_DESTINATION, headers) != null) { // Re-broadcast return; } SimpMessageHeaderAccessor accessor = SimpMessageHeaderAccessor.wrap(message); String destination = accessor.getDestination(); accessor.setNativeHeader(SimpMessageHeaderAccessor.ORIGINAL_DESTINATION, destination); accessor.setLeaveMutable(true); message = MessageBuilder.createMessage(message.getPayload(), accessor.getMessageHeaders()); if (logger.isTraceEnabled()) { logger.trace("Translated " + destination + " -> " + getBroadcastDestination()); } this.messagingTemplate.send(getBroadcastDestination(), message); } }
public void handleUnresolved(Message<?> message) { MessageHeaders headers = message.getHeaders(); if (SimpMessageHeaderAccessor.getFirstNativeHeader( SimpMessageHeaderAccessor.ORIGINAL_DESTINATION, headers) != null) { // Re-broadcast return; } SimpMessageHeaderAccessor accessor = SimpMessageHeaderAccessor.wrap(message); String destination = accessor.getDestination(); accessor.setNativeHeader(SimpMessageHeaderAccessor.ORIGINAL_DESTINATION, destination); accessor.setLeaveMutable(true); message = MessageBuilder.createMessage(message.getPayload(), accessor.getMessageHeaders()); if (logger.isTraceEnabled()) { logger.trace("Translated " + destination + " -> " + getBroadcastDestination()); } this.messagingTemplate.send(getBroadcastDestination(), message); } }
/** * Return the configured destination for unresolved messages. */ @Nullable public String getBroadcastDestination() { return (this.broadcastHandler != null ? this.broadcastHandler.getBroadcastDestination() : null); }
/** * Set a destination to broadcast messages to that remain unresolved because * the user is not connected. In a multi-application server scenario this * gives other application servers a chance to try. * <p>By default this is not set. * @param destination the target destination. */ public void setBroadcastDestination(@Nullable String destination) { this.broadcastHandler = (StringUtils.hasText(destination) ? new BroadcastHandler(this.messagingTemplate, destination) : null); }
/** * Return the configured destination for unresolved messages. */ @Nullable public String getBroadcastDestination() { return (this.broadcastHandler != null ? this.broadcastHandler.getBroadcastDestination() : null); }
/** * Set a destination to broadcast messages to that remain unresolved because * the user is not connected. In a multi-application server scenario this * gives other application servers a chance to try. * <p>By default this is not set. * @param destination the target destination. */ public void setBroadcastDestination(@Nullable String destination) { this.broadcastHandler = (StringUtils.hasText(destination) ? new BroadcastHandler(this.messagingTemplate, destination) : null); }
Message<?> messageToUse = message; if (this.broadcastHandler != null) { messageToUse = this.broadcastHandler.preHandle(message); if (messageToUse == null) { return; this.broadcastHandler.handleUnresolved(messageToUse);
@Nullable public Message<?> preHandle(Message<?> message) throws MessagingException { String destination = SimpMessageHeaderAccessor.getDestination(message.getHeaders()); if (!getBroadcastDestination().equals(destination)) { return message; } SimpMessageHeaderAccessor accessor = SimpMessageHeaderAccessor.getAccessor(message, SimpMessageHeaderAccessor.class); Assert.state(accessor != null, "No SimpMessageHeaderAccessor"); if (accessor.getSessionId() == null) { // Our own broadcast return null; } destination = accessor.getFirstNativeHeader(SimpMessageHeaderAccessor.ORIGINAL_DESTINATION); if (logger.isTraceEnabled()) { logger.trace("Checking unresolved user destination: " + destination); } SimpMessageHeaderAccessor newAccessor = SimpMessageHeaderAccessor.create(SimpMessageType.MESSAGE); for (String name : accessor.toNativeHeaderMap().keySet()) { if (NO_COPY_LIST.contains(name)) { continue; } newAccessor.setNativeHeader(name, accessor.getFirstNativeHeader(name)); } if (destination != null) { newAccessor.setDestination(destination); } newAccessor.setHeader(SimpMessageHeaderAccessor.IGNORE_ERROR, true); // ensure send doesn't block return MessageBuilder.createMessage(message.getPayload(), newAccessor.getMessageHeaders()); }
public void handleUnresolved(Message<?> message) { MessageHeaders headers = message.getHeaders(); if (SimpMessageHeaderAccessor.getFirstNativeHeader( SimpMessageHeaderAccessor.ORIGINAL_DESTINATION, headers) != null) { // Re-broadcast return; } SimpMessageHeaderAccessor accessor = SimpMessageHeaderAccessor.wrap(message); String destination = accessor.getDestination(); accessor.setNativeHeader(SimpMessageHeaderAccessor.ORIGINAL_DESTINATION, destination); accessor.setLeaveMutable(true); message = MessageBuilder.createMessage(message.getPayload(), accessor.getMessageHeaders()); if (logger.isTraceEnabled()) { logger.trace("Translated " + destination + " -> " + getBroadcastDestination()); } this.messagingTemplate.send(getBroadcastDestination(), message); } }
/** * Set a destination to broadcast messages to that remain unresolved because * the user is not connected. In a multi-application server scenario this * gives other application servers a chance to try. * <p>By default this is not set. * @param destination the target destination. */ public void setBroadcastDestination(@Nullable String destination) { this.broadcastHandler = (StringUtils.hasText(destination) ? new BroadcastHandler(this.messagingTemplate, destination) : null); }
/** * Return the configured destination for unresolved messages. */ @Nullable public String getBroadcastDestination() { return (this.broadcastHandler != null ? this.broadcastHandler.getBroadcastDestination() : null); }
public void handleUnresolved(Message<?> message) { MessageHeaders headers = message.getHeaders(); if (SimpMessageHeaderAccessor.getFirstNativeHeader( SimpMessageHeaderAccessor.ORIGINAL_DESTINATION, headers) != null) { // Re-broadcast return; } SimpMessageHeaderAccessor accessor = SimpMessageHeaderAccessor.wrap(message); String destination = accessor.getDestination(); accessor.setNativeHeader(SimpMessageHeaderAccessor.ORIGINAL_DESTINATION, destination); accessor.setLeaveMutable(true); message = MessageBuilder.createMessage(message.getPayload(), accessor.getMessageHeaders()); if (logger.isTraceEnabled()) { logger.trace("Translated " + destination + " -> " + getBroadcastDestination()); } this.messagingTemplate.send(getBroadcastDestination(), message); } }
/** * Return the configured destination for unresolved messages. */ @Nullable public String getBroadcastDestination() { return (this.broadcastHandler != null ? this.broadcastHandler.getBroadcastDestination() : null); }