Package org.springframework.amqp.core

Examples of org.springframework.amqp.core.MessageProperties


  @Override
  protected org.springframework.amqp.core.Message buildMessage(Channel channel, Object result) throws Exception {
    MessageConverter converter = getMessageConverter();
    if (converter != null && !(result instanceof org.springframework.amqp.core.Message)) {
      if (result instanceof org.springframework.messaging.Message) {
        return this.messagingMessageConverter.toMessage(result, new MessageProperties());
      }
      else {
        return converter.toMessage(result, new MessageProperties());
      }
    }
    else {
      if (!(result instanceof org.springframework.amqp.core.Message)) {
        throw new MessageConversionException("No MessageConverter specified - cannot handle message ["
View Full Code Here


   * @see #setMessageConverter
   */
  protected Message buildMessage(Channel channel, Object result) throws Exception {
    MessageConverter converter = getMessageConverter();
    if (converter != null && !(result instanceof Message)) {
      return converter.toMessage(result, new MessageProperties());
    }
    else {
      if (!(result instanceof Message)) {
        throw new MessageConversionException("No MessageConverter specified - cannot handle message ["
            + result + "]");
View Full Code Here

          if (reply != null) {
            Address replyTo = replyToAddressCallback.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()'.
            RabbitTemplate.this.doSend(channel, replyTo.getExchangeName(), replyTo.getRoutingKey(), replyMessage, null);
          }
View Full Code Here

  protected Message convertMessageIfNecessary(final Object object) {
    if (object instanceof Message) {
      return (Message) object;
    }
    return getRequiredMessageConverter().toMessage(object, new MessageProperties());
  }
View Full Code Here

        DefaultConsumer consumer = new DefaultConsumer(channel) {

          @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.mandatoryExpression.getValue(this.evaluationContext, message, Boolean.class);
    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, convertedMessageProperties, message.getBody());
    // Check if commit needed
View Full Code Here

  protected boolean isChannelLocallyTransacted(Channel channel) {
    return isChannelTransacted() && !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

  }

  public final Message toMessage(Object object, MessageProperties messageProperties)
      throws MessageConversionException {
    if (messageProperties==null) {
      messageProperties = new MessageProperties();
    }
    Message message = createMessage(object, messageProperties);
    messageProperties = message.getMessageProperties();
    if (this.createMessageIds && messageProperties.getMessageId()==null) {
      messageProperties.setMessageId(UUID.randomUUID().toString());
View Full Code Here

   * Converts from a AMQP Message to an Object.
   */
  @Override
  public Object fromMessage(Message message) throws MessageConversionException {
    Object content = null;
    MessageProperties properties = message.getMessageProperties();
    if (properties != null) {
      String contentType = properties.getContentType();
      if (contentType != null && contentType.startsWith("text") && !ignoreContentType) {
        String encoding = properties.getContentEncoding();
        if (encoding == null) {
          encoding = this.defaultCharset;
        }
        try {
          content = new String(message.getBody(), encoding);
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.