Package org.springframework.amqp.support.converter

Examples of org.springframework.amqp.support.converter.MessageConverter


   * @throws Exception if thrown by Rabbit API methods
   * @see #setMessageConverter
   */
  @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


    Address replyToAddress = getDefaultReplyToAddress();
    if (replyToAddress != null) {
      messageListener.setResponseExchange(replyToAddress.getExchangeName());
      messageListener.setResponseRoutingKey(replyToAddress.getRoutingKey());
    }
    MessageConverter messageConverter = container.getMessageConverter();
    if (messageConverter != null) {
      messageListener.setMessageConverter(messageConverter);
    }
    return messageListener;
  }
View Full Code Here

   * Extract the message body from the given Rabbit message.
   * @param message the Rabbit <code>Message</code>
   * @return the content of the message, to be passed into the listener method as argument
   */
  protected Object extractMessage(Message message) {
    MessageConverter converter = getMessageConverter();
    if (converter != null) {
      return converter.fromMessage(message);
    }
    return message;
  }
View Full Code Here

   * @return the Rabbit <code>Message</code> (never <code>null</code>)
   * @throws Exception if thrown by Rabbit API methods
   * @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

    messageProps.setMessageCount(response.getMessageCount());
    return new Message(response.getBody(), messageProps);
  }

  private MessageConverter getRequiredMessageConverter() throws IllegalStateException {
    MessageConverter converter = this.getMessageConverter();
    if (converter == null) {
      throw new AmqpIllegalStateException(
          "No 'messageConverter' specified. Check configuration of RabbitTemplate.");
    }
    return converter;
View Full Code Here

    AmqpProxyFactoryBean amqpProxyFactoryBean = new AmqpProxyFactoryBean();
    amqpProxyFactoryBean.setServiceInterface(TestServiceInterface.class);
    AmqpTemplate directForwardingTemplate = new AbstractAmqpTemplate() {
      @Override
      public Object convertSendAndReceive(Object payload) throws AmqpException {
        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);
      }
    };
    amqpProxyFactoryBean.setAmqpTemplate(directForwardingTemplate);
    amqpProxyFactoryBean.afterPropertiesSet();
    Object rawProxy = amqpProxyFactoryBean.getObject();
View Full Code Here

TOP

Related Classes of org.springframework.amqp.support.converter.MessageConverter

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.