Java Code Examples for org.springframework.messaging.simp.SimpMessageHeaderAccessor#getSubscriptionId()
The following examples show how to use
org.springframework.messaging.simp.SimpMessageHeaderAccessor#getSubscriptionId() .
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: SubscriptionMethodReturnValueHandler.java From spring4-understanding with Apache License 2.0 | 6 votes |
@Override public void handleReturnValue(Object returnValue, MethodParameter returnType, Message<?> message) throws Exception { if (returnValue == null) { return; } MessageHeaders headers = message.getHeaders(); String destination = SimpMessageHeaderAccessor.getDestination(headers); String sessionId = SimpMessageHeaderAccessor.getSessionId(headers); String subscriptionId = SimpMessageHeaderAccessor.getSubscriptionId(headers); if (subscriptionId == null) { throw new IllegalStateException( "No subscriptionId in " + message + " returned by: " + returnType.getMethod()); } if (logger.isDebugEnabled()) { logger.debug("Reply to @SubscribeMapping: " + returnValue); } this.messagingTemplate.convertAndSend( destination, returnValue, createHeaders(sessionId, subscriptionId, returnType)); }
Example 2
Source File: AbstractSubscriptionRegistry.java From spring4-understanding with Apache License 2.0 | 6 votes |
@Override public final void unregisterSubscription(Message<?> message) { MessageHeaders headers = message.getHeaders(); SimpMessageType messageType = SimpMessageHeaderAccessor.getMessageType(headers); if (!SimpMessageType.UNSUBSCRIBE.equals(messageType)) { throw new IllegalArgumentException("Expected UNSUBSCRIBE: " + message); } String sessionId = SimpMessageHeaderAccessor.getSessionId(headers); if (sessionId == null) { logger.error("No sessionId in " + message); return; } String subscriptionId = SimpMessageHeaderAccessor.getSubscriptionId(headers); if (subscriptionId == null) { logger.error("No subscriptionId " + message); return; } removeSubscriptionInternal(sessionId, subscriptionId, message); }
Example 3
Source File: SubscriptionMethodReturnValueHandler.java From spring-analysis-note with MIT License | 5 votes |
@Override public void handleReturnValue(@Nullable Object returnValue, MethodParameter returnType, Message<?> message) throws Exception { if (returnValue == null) { return; } MessageHeaders headers = message.getHeaders(); String sessionId = SimpMessageHeaderAccessor.getSessionId(headers); String subscriptionId = SimpMessageHeaderAccessor.getSubscriptionId(headers); String destination = SimpMessageHeaderAccessor.getDestination(headers); if (subscriptionId == null) { throw new IllegalStateException("No simpSubscriptionId in " + message + " returned by: " + returnType.getMethod()); } if (destination == null) { throw new IllegalStateException("No simpDestination in " + message + " returned by: " + returnType.getMethod()); } if (logger.isDebugEnabled()) { logger.debug("Reply to @SubscribeMapping: " + returnValue); } MessageHeaders headersToSend = createHeaders(sessionId, subscriptionId, returnType); this.messagingTemplate.convertAndSend(destination, returnValue, headersToSend); }
Example 4
Source File: AbstractSubscriptionRegistry.java From spring-analysis-note with MIT License | 5 votes |
@Override public final void registerSubscription(Message<?> message) { MessageHeaders headers = message.getHeaders(); SimpMessageType messageType = SimpMessageHeaderAccessor.getMessageType(headers); if (!SimpMessageType.SUBSCRIBE.equals(messageType)) { throw new IllegalArgumentException("Expected SUBSCRIBE: " + message); } String sessionId = SimpMessageHeaderAccessor.getSessionId(headers); if (sessionId == null) { if (logger.isErrorEnabled()) { logger.error("No sessionId in " + message); } return; } String subscriptionId = SimpMessageHeaderAccessor.getSubscriptionId(headers); if (subscriptionId == null) { if (logger.isErrorEnabled()) { logger.error("No subscriptionId in " + message); } return; } String destination = SimpMessageHeaderAccessor.getDestination(headers); if (destination == null) { if (logger.isErrorEnabled()) { logger.error("No destination in " + message); } return; } addSubscriptionInternal(sessionId, subscriptionId, destination, message); }
Example 5
Source File: AbstractSubscriptionRegistry.java From spring-analysis-note with MIT License | 5 votes |
@Override public final void unregisterSubscription(Message<?> message) { MessageHeaders headers = message.getHeaders(); SimpMessageType messageType = SimpMessageHeaderAccessor.getMessageType(headers); if (!SimpMessageType.UNSUBSCRIBE.equals(messageType)) { throw new IllegalArgumentException("Expected UNSUBSCRIBE: " + message); } String sessionId = SimpMessageHeaderAccessor.getSessionId(headers); if (sessionId == null) { if (logger.isErrorEnabled()) { logger.error("No sessionId in " + message); } return; } String subscriptionId = SimpMessageHeaderAccessor.getSubscriptionId(headers); if (subscriptionId == null) { if (logger.isErrorEnabled()) { logger.error("No subscriptionId " + message); } return; } removeSubscriptionInternal(sessionId, subscriptionId, message); }
Example 6
Source File: SubscriptionMethodReturnValueHandler.java From java-technology-stack with MIT License | 5 votes |
@Override public void handleReturnValue(@Nullable Object returnValue, MethodParameter returnType, Message<?> message) throws Exception { if (returnValue == null) { return; } MessageHeaders headers = message.getHeaders(); String sessionId = SimpMessageHeaderAccessor.getSessionId(headers); String subscriptionId = SimpMessageHeaderAccessor.getSubscriptionId(headers); String destination = SimpMessageHeaderAccessor.getDestination(headers); if (subscriptionId == null) { throw new IllegalStateException("No simpSubscriptionId in " + message + " returned by: " + returnType.getMethod()); } if (destination == null) { throw new IllegalStateException("No simpDestination in " + message + " returned by: " + returnType.getMethod()); } if (logger.isDebugEnabled()) { logger.debug("Reply to @SubscribeMapping: " + returnValue); } MessageHeaders headersToSend = createHeaders(sessionId, subscriptionId, returnType); this.messagingTemplate.convertAndSend(destination, returnValue, headersToSend); }
Example 7
Source File: AbstractSubscriptionRegistry.java From java-technology-stack with MIT License | 5 votes |
@Override public final void registerSubscription(Message<?> message) { MessageHeaders headers = message.getHeaders(); SimpMessageType messageType = SimpMessageHeaderAccessor.getMessageType(headers); if (!SimpMessageType.SUBSCRIBE.equals(messageType)) { throw new IllegalArgumentException("Expected SUBSCRIBE: " + message); } String sessionId = SimpMessageHeaderAccessor.getSessionId(headers); if (sessionId == null) { if (logger.isErrorEnabled()) { logger.error("No sessionId in " + message); } return; } String subscriptionId = SimpMessageHeaderAccessor.getSubscriptionId(headers); if (subscriptionId == null) { if (logger.isErrorEnabled()) { logger.error("No subscriptionId in " + message); } return; } String destination = SimpMessageHeaderAccessor.getDestination(headers); if (destination == null) { if (logger.isErrorEnabled()) { logger.error("No destination in " + message); } return; } addSubscriptionInternal(sessionId, subscriptionId, destination, message); }
Example 8
Source File: AbstractSubscriptionRegistry.java From java-technology-stack with MIT License | 5 votes |
@Override public final void unregisterSubscription(Message<?> message) { MessageHeaders headers = message.getHeaders(); SimpMessageType messageType = SimpMessageHeaderAccessor.getMessageType(headers); if (!SimpMessageType.UNSUBSCRIBE.equals(messageType)) { throw new IllegalArgumentException("Expected UNSUBSCRIBE: " + message); } String sessionId = SimpMessageHeaderAccessor.getSessionId(headers); if (sessionId == null) { if (logger.isErrorEnabled()) { logger.error("No sessionId in " + message); } return; } String subscriptionId = SimpMessageHeaderAccessor.getSubscriptionId(headers); if (subscriptionId == null) { if (logger.isErrorEnabled()) { logger.error("No subscriptionId " + message); } return; } removeSubscriptionInternal(sessionId, subscriptionId, message); }
Example 9
Source File: AbstractSubscriptionRegistry.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Override public final void registerSubscription(Message<?> message) { MessageHeaders headers = message.getHeaders(); SimpMessageType messageType = SimpMessageHeaderAccessor.getMessageType(headers); if (!SimpMessageType.SUBSCRIBE.equals(messageType)) { throw new IllegalArgumentException("Expected SUBSCRIBE: " + message); } String sessionId = SimpMessageHeaderAccessor.getSessionId(headers); if (sessionId == null) { logger.error("No sessionId in " + message); return; } String subscriptionId = SimpMessageHeaderAccessor.getSubscriptionId(headers); if (subscriptionId == null) { logger.error("No subscriptionId in " + message); return; } String destination = SimpMessageHeaderAccessor.getDestination(headers); if (destination == null) { logger.error("No destination in " + message); return; } addSubscriptionInternal(sessionId, subscriptionId, destination, message); }