Package org.springframework.amqp.core

Examples of org.springframework.amqp.core.MessageProperties


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


    }

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

    MessageProperties messageProperties = new MessageProperties();
    messageProperties.setExpiration(EXPIRATION_TIME);
    messageProperties.setCorrelationId(calculateCorrelationId(request)
        .getBytes());

    for (int numRequest = 0; numRequest < numRetries + 1; numRequest++) {

      if (numRequest > 0) {
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 void testExchangePattern() throws Exception {
        org.apache.camel.Message camelMessage = new DefaultMessage();
        Exchange exchange = new DefaultExchange(new DefaultCamelContext(), ExchangePattern.InOut);
        exchange.setIn(camelMessage);
       
        MessageProperties properties = new MessageProperties();
        org.springframework.amqp.core.Message amqpMessage = new org.springframework.amqp.core.Message("Testing".getBytes(), properties);
       
        amqpMessage = new SpringAMQPMessage.HeadersPostProcessor(camelMessage).postProcessMessage(amqpMessage);
        ExchangePattern exchangePattern = SpringAMQPMessage.getExchangePattern(amqpMessage);
        Assert.assertEquals(exchange.getPattern(), exchangePattern);
View Full Code Here

   
    @Test
    public void fromAMQP() throws Exception {
        String body = "Test Message";
        MessageConverter msgConverter = new StringMessageConverter();
        MessageProperties properties = new MessageProperties();
        properties.setHeader("NotSecret", "Popcorn");
        org.springframework.amqp.core.Message message = new org.springframework.amqp.core.Message(body.getBytes(), properties);
       
        SpringAMQPMessage camelMessage = SpringAMQPMessage.fromAMQPMessage(msgConverter, message);
        Assert.assertEquals(body, camelMessage.getBody(String.class));
        Assert.assertEquals("Popcorn", camelMessage.getHeader("NotSecret"));
View Full Code Here

import org.springframework.amqp.core.MessageProperties;

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);
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

        Assert.assertEquals("BuzzSaw", message.getMessageProperties().getReplyTo());
    }
   
    @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"));
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

    @Test
    public void testConversion() throws Exception {
        TestObject testObject = new TestObject();
        testObject.setValue("TESTING");
       
        MessageProperties messageProperties = new MessageProperties();
       
        MessageConverter converter = new XStreamConverter();
        ((XStreamConverter) converter).setEncoding("UTF-8");
        Message amqpMessage = converter.toMessage(testObject, messageProperties);
        Assert.assertEquals("{\"amqp.spring.converter.XStreamConverterTest_-TestObject\":{\"value\":\"TESTING\"}}", new String(amqpMessage.getBody()));
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.