Package org.springframework.amqp.core

Examples of org.springframework.amqp.core.Message


              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);
            }
            try {
              replyHandoff.put(reply);
            } catch (InterruptedException e) {
              Thread.currentThread().interrupt();
            }
          }
        };
        channel.basicConsume(replyTo, true, consumerTag, true, true,
            null, consumer);
        doSend(channel, exchange, routingKey, message, null);
        Message reply = (replyTimeout < 0) ? replyHandoff.take()
            : replyHandoff
                .poll(replyTimeout, TimeUnit.MILLISECONDS);
        channel.basicCancel(consumerTag);
        return reply;
      }
View Full Code Here


          logger.debug("Sending message with tag " + messageTag);
        }
        doSend(channel, exchange, routingKey, message, null);
        LinkedBlockingQueue<Message> replyHandoff = pendingReply
            .getQueue();
        Message reply = (replyTimeout < 0) ? replyHandoff.take()
            : replyHandoff
                .poll(replyTimeout, TimeUnit.MILLISECONDS);
        RabbitTemplate.this.replyHolder.remove(messageTag);
        return reply;
      }
View Full Code Here

  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

    } 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

      if (numRequest > 0) {
        log.debug("Retry {} sending message: {}", numRequest, request);
      }

      Message response = template.sendAndReceive(exchange, routingKey,
          new Message(request.toString().getBytes(),
              messageProperties));

      if (response != null) {
        String responseAsString = new String(response.getBody());
        log.debug("<-Res " + responseAsString.trim());
        return responseAsString;
      }
    }
View Full Code Here

    }

    log.debug("Not-> Exchange:'" + exchange + "' RoutingKey:'" + routingKey
        + "' " + message);

    template.send(exchange, routingKey, new Message(message.getBytes(),
        new MessageProperties()));
  }
View Full Code Here

public class SpringAMQPHeaderTest {
    @Test
    public void fromBasicProperties() throws Exception {
        MessageProperties properties = new MessageProperties();
        properties.setHeader("NotSecret", "Popcorn");
        org.springframework.amqp.core.Message message = new Message(new byte[]{}, properties);
        message.getMessageProperties().setPriority(1);
        message.getMessageProperties().setReplyTo("BuzzSaw");
       
        SpringAMQPMessage camelMessage = SpringAMQPHeader.setBasicPropertiesToHeaders(new SpringAMQPMessage(), message);
        Assert.assertNull(camelMessage.getHeader("NotSecret"));
        Assert.assertEquals(1, camelMessage.getHeader(SpringAMQPHeader.PRIORITY));
        Assert.assertEquals("BuzzSaw", camelMessage.getHeader(SpringAMQPHeader.REPLY_TO));
View Full Code Here

        camelMessage.setHeader(SpringAMQPHeader.REPLY_TO, "BuzzSaw");
       
        Exchange exchange = new DefaultExchange(new DefaultCamelContext());
        exchange.setIn(camelMessage);
       
        Message message = new Message(new byte[]{}, new MessageProperties());
        message = SpringAMQPHeader.setBasicPropertiesFromHeaders(message, camelMessage.getHeaders());
        Assert.assertNull(message.getMessageProperties().getHeaders().get("Secret"));
        Assert.assertEquals(Integer.valueOf(1), message.getMessageProperties().getPriority());
        Assert.assertEquals("BuzzSaw", message.getMessageProperties().getReplyTo());
    }
View Full Code Here

   
    @Test
    public void copyAMQPHeaders() throws Exception {
        MessageProperties properties = new MessageProperties();
        properties.setHeader("NotSecret", "Popcorn");
        org.springframework.amqp.core.Message message = new Message(new byte[]{}, properties);
        message.getMessageProperties().setReplyTo("BuzzSaw");
       
        SpringAMQPMessage camelMessage = SpringAMQPHeader.copyHeaders(new SpringAMQPMessage(), message.getMessageProperties().getHeaders());
        Assert.assertEquals("Popcorn", camelMessage.getHeader("NotSecret"));
        Assert.assertNull(camelMessage.getHeader(SpringAMQPHeader.REPLY_TO));
    }
View Full Code Here

        camelMessage.setHeader(SpringAMQPHeader.REPLY_TO, "BuzzSaw");
       
        Exchange exchange = new DefaultExchange(new DefaultCamelContext());
        exchange.setIn(camelMessage);
       
        Message message = new Message(new byte[]{}, new MessageProperties());
        message = SpringAMQPHeader.copyHeaders(message, camelMessage.getHeaders());
        Assert.assertEquals("My Secret", message.getMessageProperties().getHeaders().get("Secret"));
        Assert.assertNull(message.getMessageProperties().getReplyTo());
    }
View Full Code Here

TOP

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

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.