/** * Build a Rabbit message to be sent as response based on the given result object. * @param channel the Rabbit Channel to operate on * @param result the content of the message, as returned from the listener method * @param genericType the generic type of the result. * @return the Rabbit <code>Message</code> (never <code>null</code>) * @see #setMessageConverter */ @Override protected org.springframework.amqp.core.Message buildMessage(Channel channel, Object result, Type genericType) { 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(), genericType); } } else { if (!(result instanceof org.springframework.amqp.core.Message)) { throw new MessageConversionException("No MessageConverter specified - cannot handle message [" + result + "]"); } return (org.springframework.amqp.core.Message) result; } }
/** * Build a Rabbit message to be sent as response based on the given result object. * @param channel the Rabbit Channel to operate on * @param result the content of the message, as returned from the listener method * @param genericType the generic type of the result. * @return the Rabbit <code>Message</code> (never <code>null</code>) * @see #setMessageConverter */ @Override protected org.springframework.amqp.core.Message buildMessage(Channel channel, Object result, Type genericType) { 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(), genericType); } } else { if (!(result instanceof org.springframework.amqp.core.Message)) { throw new MessageConversionException("No MessageConverter specified - cannot handle message [" + result + "]"); } return (org.springframework.amqp.core.Message) result; } }