* @return the JMS {@code Message} (never {@code null})
* @throws JMSException if thrown by JMS API methods
* @see #setMessageConverter
*/
protected Message buildMessage(Session session, Object result) throws JMSException {
MessageConverter converter = getMessageConverter();
if (converter != null) {
if (result instanceof org.springframework.messaging.Message) {
return this.messagingMessageConverter.toMessage(result, session);
}
else {
return converter.toMessage(result, session);
}
}
else {
if (!(result instanceof Message)) {
throw new MessageConversionException(