Package org.springframework.messaging

Examples of org.springframework.messaging.MessageHeaders


 
    EmployeeList employeeList = new EmployeeList();
    Map<String, Object> responseHeaderMap = new HashMap<String, Object>();
   
    try{
      MessageHeaders headers = inMessage.getHeaders();
      String id = (String)headers.get("employeeId");
      boolean isFound;
      if (id.equals("1")){
        employeeList.getEmployee().add(new Employee(1, "John", "Doe"));
        isFound = true;
      }else if (id.equals("2")){
View Full Code Here


        Assert.notNull(typeToMatch, "typeToMatch cannot be null");
        this.typeToMatch = typeToMatch;
    }

    public boolean matches(Message<? extends Object> message) {
        MessageHeaders headers = message.getHeaders();
        SimpMessageType messageType = SimpMessageHeaderAccessor
                .getMessageType(headers);

        return typeToMatch == messageType;
    }
View Full Code Here

        assertEquals("Mismatched type", type, op.getType());

        assertEquals("Mismatched component type", compType, op.get("siComponentType", String.class));
        assertEquals("Mismatched bean name", beanName, op.get("beanName", String.class));

        MessageHeaders hdrs = message.getHeaders();
        UUID msgId = hdrs.getId();
        assertEquals("Mismatched message id", msgId.toString(), op.get("idHeader", String.class));
        assertEquals("Mismatched payload type", "java.lang.String", op.get("payloadType", String.class));

        return op;
    }
View Full Code Here

  @Test
  public void connectReceiveAndCloseWithStompFrame() throws Exception {
    StompHeaderAccessor accessor = StompHeaderAccessor.create(StompCommand.SEND);
    accessor.setDestination("/destination");
    MessageHeaders headers = accessor.getMessageHeaders();
    Message<byte[]> message = MessageBuilder.createMessage("body".getBytes(Charset.forName("UTF-8")), headers);
    byte[] bytes = new StompEncoder().encode(message);
    TextMessage textMessage = new TextMessage(bytes);
    SockJsFrame frame = SockJsFrame.messageFrame(new Jackson2SockJsMessageCodec(), textMessage.getPayload());
View Full Code Here

    catch (JMSException ex) {
      if (logger.isWarnEnabled()) {
        logger.warn("Error occurred while mapping from JMS properties to MessageHeaders", ex);
      }
    }
    return new MessageHeaders(headers);
  }
View Full Code Here

  protected final Log logger = LogFactory.getLog(getClass());


  @Override
  public final void registerSubscription(Message<?> message) {
    MessageHeaders headers = message.getHeaders();
    SimpMessageType messageType = SimpMessageHeaderAccessor.getMessageType(headers);
    Assert.isTrue(SimpMessageType.SUBSCRIBE.equals(messageType), "Expected SUBSCRIBE: " + message);
    String sessionId = SimpMessageHeaderAccessor.getSessionId(headers);
    if (sessionId == null) {
      logger.error("No sessionId in  " + message);
View Full Code Here

  protected abstract void addSubscriptionInternal(String sessionId, String subscriptionId,
      String destination, Message<?> message);

  @Override
  public final void unregisterSubscription(Message<?> message) {
    MessageHeaders headers = message.getHeaders();
    SimpMessageType messageType = SimpMessageHeaderAccessor.getMessageType(headers);
    Assert.isTrue(SimpMessageType.UNSUBSCRIBE.equals(messageType), "Expected UNSUBSCRIBE: " + message);
    String sessionId = SimpMessageHeaderAccessor.getSessionId(headers);
    if (sessionId == null) {
      logger.error("No sessionId in " + message);
View Full Code Here

  @Override
  public abstract void unregisterAllSubscriptions(String sessionId);

  @Override
  public final MultiValueMap<String, String> findSubscriptions(Message<?> message) {
    MessageHeaders headers = message.getHeaders();
    SimpMessageType type = SimpMessageHeaderAccessor.getMessageType(headers);
    Assert.isTrue(SimpMessageType.MESSAGE.equals(type), "Unexpected message type: " + type);
    String destination = SimpMessageHeaderAccessor.getDestination(headers);
    if (destination == null) {
      logger.error("No destination in " + message);
View Full Code Here

   * wrap them in a {@link SimpAttributes} instance.
   * @param message the message to extract session attributes from
   */
  public static SimpAttributes fromMessage(Message<?> message) {
    Assert.notNull(message, "Message must not be null");
    MessageHeaders headers = message.getHeaders();
    String sessionId = SimpMessageHeaderAccessor.getSessionId(headers);
    Map<String, Object> sessionAttributes = SimpMessageHeaderAccessor.getSessionAttributes(headers);
    if (sessionId == null) {
      throw new IllegalStateException("No session id in " + message);
    }
View Full Code Here

   * @param headers headers for the message to send
   * @param postProcessor the post processor to apply to the message
   * @return the converted message
   */
  protected Message<?> doConvert(Object payload, Map<String, Object> headers, MessagePostProcessor postProcessor) {
    MessageHeaders messageHeaders = null;
    Map<String, Object> headersToUse = processHeadersToSend(headers);
    if (headersToUse != null) {
      if (headersToUse instanceof MessageHeaders) {
        messageHeaders = (MessageHeaders) headersToUse;
      }
      else {
        messageHeaders = new MessageHeaders(headersToUse);
      }
    }

    Message<?> message = getMessageConverter().toMessage(payload, messageHeaders);
    if (message == null) {
      String payloadType = (payload != null ? payload.getClass().getName() : null);
      Object contentType = (messageHeaders != null ? messageHeaders.get(MessageHeaders.CONTENT_TYPE) : null);
      throw new MessageConversionException("Unable to convert payload with type='" + payloadType +
          "', contentType='" + contentType + "', converter=[" + getMessageConverter() + "]");
    }
    if (postProcessor != null) {
      message = postProcessor.postProcessMessage(message);
View Full Code Here

TOP

Related Classes of org.springframework.messaging.MessageHeaders

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.