Package org.springframework.amqp.core

Examples of org.springframework.amqp.core.Message


    }
    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


    Channel channel = consumer.getChannel();

    for (int i = 0; i < txSize; i++) {

      logger.trace("Waiting for message from consumer.");
      Message message = consumer.nextMessage(receiveTimeout);
      if (message == null) {
        break;
      }
      try {
        executeListener(channel, message);
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());
    }
    return message;
  }
View Full Code Here

      messageProperties.setContentType(MessageProperties.CONTENT_TYPE_SERIALIZED_OBJECT);
    }
    if (bytes != null) {
      messageProperties.setContentLength(bytes.length);
    }
    return new Message(bytes, messageProperties);
  }
View Full Code Here

public class SimpleMessageConverterTests {

  @Test
  public void bytesAsDefaultMessageBodyType() throws Exception {
    SimpleMessageConverter converter = new SimpleMessageConverter();
    Message message = new Message("test".getBytes(), new MessageProperties());
    Object result = converter.fromMessage(message);
    assertEquals(byte[].class, result.getClass());
    assertEquals("test", new String((byte[]) result, "UTF-8"));
  }
View Full Code Here

  }

  @Test
  public void noMessageIdByDefault() throws Exception {
    SimpleMessageConverter converter = new SimpleMessageConverter();
    Message message = converter.toMessage("foo", null);
    assertNull(message.getMessageProperties().getMessageId());
  }
View Full Code Here

  @Test
  public void optionalMessageId() throws Exception {
    SimpleMessageConverter converter = new SimpleMessageConverter();
    converter.setCreateMessageIds(true);
    Message message = converter.toMessage("foo", null);
    assertNotNull(message.getMessageProperties().getMessageId());
  }
View Full Code Here

  }

  @Test
  public void messageToString() {
    SimpleMessageConverter converter = new SimpleMessageConverter();
    Message message = new Message("test".getBytes(), new MessageProperties());
    message.getMessageProperties().setContentType(MessageProperties.CONTENT_TYPE_TEXT_PLAIN);
    Object result = converter.fromMessage(message);
    assertEquals(String.class, result.getClass());
    assertEquals("test", result);
  }
View Full Code Here

  }

  @Test
  public void messageToBytes() {
    SimpleMessageConverter converter = new SimpleMessageConverter();
    Message message = new Message(new byte[] { 1, 2, 3 }, new MessageProperties());
    message.getMessageProperties().setContentType(MessageProperties.CONTENT_TYPE_BYTES);
    Object result = converter.fromMessage(message);
    assertEquals(byte[].class, result.getClass());
    byte[] resultBytes = (byte[]) result;
    assertEquals(3, resultBytes.length);
    assertEquals(1, resultBytes[0]);
View Full Code Here

    TestBean testBean = new TestBean("foo");
    objectStream.writeObject(testBean);
    objectStream.flush();
    objectStream.close();
    byte[] bytes = byteStream.toByteArray();
    Message message = new Message(bytes, properties);
    Object result = converter.fromMessage(message);
    assertEquals(TestBean.class, result.getClass());
    assertEquals(testBean, result);
  }
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.