Package org.springframework.amqp.support.converter

Examples of org.springframework.amqp.support.converter.MessageConverter.toMessage()


        if(converter == null) //Try to fall back
            converter = this.fallbackConverter;
        if(converter == null) //Can't even fall back, punt
            throw new MessageConversionException("Cannot find converter for content type of "+contentType);
       
        return converter.toMessage(object, messageProperties);
    }

    @Override
    public Object fromMessage(Message message) throws MessageConversionException {
        MessageProperties messageProperties = message.getMessageProperties();
View Full Code Here


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

        Object newObject = converter.fromMessage(amqpMessage);
        Assert.assertEquals(testObject, newObject);
        Assert.assertEquals("UTF-8", ((XStreamConverter) converter).getEncoding());
View Full Code Here

        testObject.setValue("TESTING");
       
        MessageProperties messageProperties = new MessageProperties();
       
        MessageConverter converter = new StringConverter();
        Message amqpMessage = converter.toMessage(testObject, messageProperties);
        Object newObject = converter.fromMessage(amqpMessage);
       
        Assert.assertEquals("TESTING", newObject);
    }
   
View Full Code Here

        if(converter == null) //Try to fall back
            converter = this.fallbackConverter;
        if(converter == null) //Can't even fall back, punt
            throw new MessageConversionException("Cannot find converter for content type of "+contentType);
       
        return converter.toMessage(object, messageProperties);
    }

    @Override
    public Object fromMessage(Message message) throws MessageConversionException {
        MessageProperties messageProperties = message.getMessageProperties();
View Full Code Here

    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

        MessageConverter messageConverter = serviceExporter.getMessageConverter();

        Address replyTo = new Address("fakeExchangeName", "fakeRoutingKey");
        MessageProperties messageProperties = new MessageProperties();
        messageProperties.setReplyToAddress(replyTo);
        Message message = messageConverter.toMessage(payload, messageProperties);

        serviceExporter.onMessage(message);

        Message resultMessage = sentSavingTemplate.getLastMessage();
        return messageConverter.fromMessage(resultMessage);
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.