Package org.springframework.amqp.core

Examples of org.springframework.amqp.core.MessageProperties


       
        return ExchangePattern.valueOf(exchangePatternName);
    }

    public Message toAMQPMessage(MessageConverter msgConverter) {
        MessageProperties properties = new MessageProperties();
        properties.setMessageId(this.getMessageId());
       
        Message amqpMessage;
        if(this.getBody() != null) {
            amqpMessage = msgConverter.toMessage(this.getBody(), properties);
           
View Full Code Here


   * .Message)
   */
  @Override
  public Object fromMessage(Message message) throws MessageConversionException {
    AmqpLogMessage content = null;
    MessageProperties properties = message.getMessageProperties();
    if (properties != null) {
      String applicationId = properties.getAppId();
      Date timestamp = properties.getTimestamp();
      Map<String, Object> headers = properties.getHeaders();

      if (CollectionUtils.isEmpty(headers)) {
        log.warn("Retrieved log message properties should contain headers");
        return null;
      }
View Full Code Here

        return converter.toMessage(object, messageProperties);
    }

    @Override
    public Object fromMessage(Message message) throws MessageConversionException {
        MessageProperties messageProperties = message.getMessageProperties();
        String contentType = messageProperties.getContentType();
        if(messageProperties == null)
            throw new MessageConversionException("Cannot decode a message with no properties!");
       
        MessageConverter converter = converters.get(contentType);
        if(converter == null) //Try to fall back
View Full Code Here

       
        return ExchangePattern.valueOf(exchangePatternName);
    }

    public Message toAMQPMessage(MessageConverter msgConverter) {
        MessageProperties properties = new MessageProperties();
        properties.setMessageId(this.getMessageId());
       
        Message amqpMessage;
        if(this.getBody() != null) {
            amqpMessage = msgConverter.toMessage(this.getBody(), properties);
           
View Full Code Here

        }
    }

    @Override
    public Object fromMessage(Message message) throws MessageConversionException {
        MessageProperties messageProperties = message.getMessageProperties();
        if(messageProperties == null)
            throw new MessageConversionException("Cannot decode a message with no properties!");

        byte[] body = message.getBody();
        if(body == null)
            return null;

        String messageEncoding = messageProperties.getContentEncoding();
        if(messageEncoding == null)
            messageEncoding = getEncoding();

        String contentType = messageProperties.getContentType();
        if(! MessageProperties.CONTENT_TYPE_JSON.equalsIgnoreCase(contentType))
            throw new MessageConversionException("Cannot understand a message of type "+contentType);

        try {
            ByteArrayInputStream inStream = new ByteArrayInputStream(body);
            StaxReader reader = new StaxReader(new QNameMap(), this.inputFactory.createXMLStreamReader(inStream, getEncoding()));
            return this.objectMapper.unmarshal(reader);
        } catch (XMLStreamException ex) {
            String typeId = (String) messageProperties.getHeaders().get(DefaultClassMapper.DEFAULT_CLASSID_FIELD_NAME);
            LOG.error("XMLStreamException trying to unmarshal message of type {}", typeId, ex);
            throw new MessageConversionException("Could not unmarshal message of type "+typeId, ex);
        }
    }
View Full Code Here

          @Override
          public void handleDelivery(String consumerTag,
              Envelope envelope, AMQP.BasicProperties properties,
              byte[] body) throws IOException {
            MessageProperties messageProperties = messagePropertiesConverter
                .toMessageProperties(properties, envelope,
                    encoding);
            Message reply = new Message(body, messageProperties);
            if (logger.isTraceEnabled()) {
              logger.trace("Message received " + reply);
View Full Code Here

      publisherCallbackChannel.addPendingConfirm(this, channel
          .getNextPublishSeqNo(), new PendingConfirm(correlationData,
          System.currentTimeMillis()));
    }
    boolean mandatory = this.returnCallback != null && this.mandatory;
    MessageProperties messageProperties = message.getMessageProperties();
    if (mandatory) {
      messageProperties.getHeaders().put(
          PublisherCallbackChannel.RETURN_CORRELATION, this.uuid);
    }
    BasicProperties convertedMessageProperties = this.messagePropertiesConverter
        .fromMessageProperties(messageProperties, encoding);
    channel.basicPublish(exchange, routingKey, mandatory,
View Full Code Here

        && !ConnectionFactoryUtils.isChannelTransactional(channel,
            getConnectionFactory());
  }

  private Message buildMessageFromResponse(GetResponse response) {
    MessageProperties messageProps = this.messagePropertiesConverter
        .toMessageProperties(response.getProps(),
            response.getEnvelope(), this.encoding);
    messageProps.setMessageCount(response.getMessageCount());
    return new Message(response.getBody(), messageProps);
  }
View Full Code Here

        logger.warn("Returned message but no callback available");
      }
    } else {
      properties.getHeaders().remove(
          PublisherCallbackChannel.RETURN_CORRELATION);
      MessageProperties messageProperties = messagePropertiesConverter
          .toMessageProperties(properties, null, this.encoding);
      Message returnedMessage = new Message(body, messageProperties);
      this.returnCallback.returnedMessage(returnedMessage, replyCode,
          replyText, exchange, routingKey);
    }
View Full Code Here

                .getReplyToAddress(receiveMessage, reply);

            Message replyMessage = RabbitTemplate.this
                .convertMessageIfNecessary(reply);

            MessageProperties receiveMessageProperties = receiveMessage
                .getMessageProperties();
            MessageProperties replyMessageProperties = replyMessage
                .getMessageProperties();

            Object correlation = RabbitTemplate.this.correlationKey == null ? receiveMessageProperties
                .getCorrelationId() : receiveMessageProperties
                .getHeaders().get(
                    RabbitTemplate.this.correlationKey);

            if (RabbitTemplate.this.correlationKey == null
                || correlation == null) {
              // using standard correlationId property
              if (correlation == null) {
                String messageId = receiveMessageProperties
                    .getMessageId();
                if (messageId != null) {
                  correlation = messageId
                      .getBytes(RabbitTemplate.this.encoding);
                }
              }
              replyMessageProperties
                  .setCorrelationId((byte[]) correlation);
            } else {
              replyMessageProperties.setHeader(
                  RabbitTemplate.this.correlationKey,
                  correlation);
            }

            // 'doSend()' takes care about 'channel.txCommit()'.
View Full Code Here

TOP

Related Classes of org.springframework.amqp.core.MessageProperties

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.