Package org.springframework.amqp.core

Examples of org.springframework.amqp.core.Message


            String routingKey = routingKeyHeader != null ? routingKeyHeader : endpoint.routingKey;

            try {
                if(exchange.getPattern().isOutCapable()) {
                    LOG.debug("Synchronous send and request for exchange {}", exchange.getExchangeId());
                    Message amqpResponse = endpoint.getAmqpTemplate().sendAndReceive(endpoint.exchangeName, routingKey, inMessage.toAMQPMessage(msgConverter));
                    SpringAMQPMessage camelResponse = SpringAMQPMessage.fromAMQPMessage(msgConverter, amqpResponse);

                    Boolean isExceptionCaught = (Boolean)camelResponse.getHeader(SpringAMQPMessage.IS_EXCEPTION_CAUGHT);
                    if (isExceptionCaught != null && isExceptionCaught.equals(Boolean.TRUE)) {
                        Object caughtObject = camelResponse.getBody();
View Full Code Here


    public Message toAMQPMessage(MessageConverter msgConverter) {
        MessageProperties properties = new MessageProperties();
        properties.setMessageId(this.getMessageId());
       
        Message amqpMessage;
        if(this.getBody() != null) {
            amqpMessage = msgConverter.toMessage(this.getBody(), properties);
           
            if(LOG.isTraceEnabled()) {
                String asText = new String(amqpMessage.getBody());
                LOG.trace("Translating To AMQP Message: "+asText);
            }
        } else {
            amqpMessage = new Message(new byte[]{}, properties);
        }
       
        return new HeadersPostProcessor(this).postProcessMessage(amqpMessage);
    }
View Full Code Here

                msgConverter = new SimpleMessageConverter();
            }

            if(exchange.getPattern().isOutCapable()) {
                LOG.debug("Synchronous send and request for exchange {}", exchange.getExchangeId());
                Message amqpResponse = endpoint.getAmqpTemplate().sendAndReceive(endpoint.exchangeName, endpoint.routingKey, inMessage.toAMQPMessage(msgConverter));
                SpringAMQPMessage camelResponse = SpringAMQPMessage.fromAMQPMessage(msgConverter, amqpResponse);
                exchange.setOut(camelResponse);
            } else {
                LOG.debug("Synchronous send for exchange {}", exchange.getExchangeId());
                endpoint.getAmqpTemplate().send(endpoint.exchangeName, endpoint.routingKey, inMessage.toAMQPMessage(msgConverter));
View Full Code Here

            msgConverter = new SimpleMessageConverter();
        }
       
        if(exchange.getPattern().isOutCapable()) {
            LOG.debug("Synchronous send and request for exchange {}", exchange.getExchangeId());
            Message amqpResponse = this.endpoint.getAmqpTemplate().sendAndReceive(this.endpoint.exchangeName, this.endpoint.routingKey, inMessage.toAMQPMessage(msgConverter));
            SpringAMQPMessage camelResponse = SpringAMQPMessage.fromAMQPMessage(msgConverter, amqpResponse);
            exchange.setOut(camelResponse);
        } else {
            LOG.debug("Synchronous send for exchange {}", exchange.getExchangeId());
            this.endpoint.getAmqpTemplate().send(this.endpoint.exchangeName, this.endpoint.routingKey, inMessage.toAMQPMessage(msgConverter));
View Full Code Here

    public Message toAMQPMessage(MessageConverter msgConverter) {
        MessageProperties properties = new MessageProperties();
        properties.setMessageId(this.getMessageId());
       
        Message amqpMessage;
        if(this.getBody() != null) {
            amqpMessage = msgConverter.toMessage(this.getBody(), properties);
           
            if(LOG.isTraceEnabled()) {
                String asText = new String(amqpMessage.getBody());
                LOG.trace("Translating To AMQP Message: "+asText);
            }
        } else {
            amqpMessage = new Message(new byte[]{}, properties);
        }
       
        return new HeadersPostProcessor(this).postProcessMessage(amqpMessage);
    }
View Full Code Here

           
            messageProperties.setContentType(MessageProperties.CONTENT_TYPE_JSON);
            messageProperties.setContentEncoding(this.encoding);
            messageProperties.setContentLength(body.length);
            classMapper.fromClass(object.getClass(), messageProperties);
            return new Message(body, messageProperties);
        } catch (XMLStreamException ex) {
            String typeId = (String) messageProperties.getHeaders().get(DefaultClassMapper.DEFAULT_CLASSID_FIELD_NAME);
            LOG.error("XMLStreamException trying to marshal message of type {}", typeId, ex);
            throw new MessageConversionException("Could not marshal message of type "+typeId, ex);
        }
View Full Code Here

  public void convertAndSend(String exchange, String routingKey,
      final Object message,
      final MessagePostProcessor messagePostProcessor,
      CorrelationData correlationData) throws AmqpException {
    Message messageToSend = convertMessageIfNecessary(message);
    messageToSend = messagePostProcessor.postProcessMessage(messageToSend);
    send(exchange, routingKey, messageToSend, correlationData);
  }
View Full Code Here

    return receiveAndConvert(this.getRequiredQueue());
  }

  @Override
  public Object receiveAndConvert(String queueName) throws AmqpException {
    Message response = receive(queueName);
    if (response != null) {
      return getRequiredMessageConverter().fromMessage(response);
    }
    return null;
  }
View Full Code Here

            ConnectionFactoryUtils.registerDeliveryTag(
                RabbitTemplate.this.getConnectionFactory(),
                channel, deliveryTag);
          }

          Message receiveMessage = RabbitTemplate.this
              .buildMessageFromResponse(response);

          Object receive = receiveMessage;
          if (!(ReceiveAndReplyMessageCallback.class
              .isAssignableFrom(callback.getClass()))) {
            receive = RabbitTemplate.this
                .getRequiredMessageConverter().fromMessage(
                    receiveMessage);
          }

          S reply;
          try {
            reply = callback.handle((R) receive);
          } catch (ClassCastException e) {
            StackTraceElement[] trace = e.getStackTrace();
            if (trace[0].getMethodName().equals("handle")
                && trace[1].getFileName().equals(
                    "RabbitTemplate.java")) {
              throw new IllegalArgumentException(
                  "ReceiveAndReplyCallback '"
                      + callback
                      + "' can't handle received object '"
                      + receive + "'", e);
            } else {
              throw e;
            }
          }

          if (reply != null) {
            Address replyTo = replyToAddressCallback
                .getReplyToAddress(receiveMessage, reply);

            Message replyMessage = RabbitTemplate.this
                .convertMessageIfNecessary(reply);

            MessageProperties receiveMessageProperties = receiveMessage
                .getMessageProperties();
            MessageProperties replyMessageProperties = replyMessage
                .getMessageProperties();

            Object correlation = RabbitTemplate.this.correlationKey == null ? receiveMessageProperties
                .getCorrelationId() : receiveMessageProperties
                .getHeaders().get(
View Full Code Here

  @Override
  public Object convertSendAndReceive(final String exchange,
      final String routingKey, final Object message,
      final MessagePostProcessor messagePostProcessor)
      throws AmqpException {
    Message requestMessage = convertMessageIfNecessary(message);
    if (messagePostProcessor != null) {
      requestMessage = messagePostProcessor
          .postProcessMessage(requestMessage);
    }
    Message replyMessage = this.doSendAndReceive(exchange, routingKey,
        requestMessage);
    if (replyMessage == null) {
      return null;
    }
    return this.getRequiredMessageConverter().fromMessage(replyMessage);
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.