@Override protected Message createMessageForPayload(Object payload, Session session, @Nullable Object conversionHint) throws JMSException { MessageConverter converter = getMessageConverter(); if (converter == null) { throw new IllegalStateException("No message converter, cannot handle '" + payload + "'"); } if (converter instanceof SmartMessageConverter) { return ((SmartMessageConverter) converter).toMessage(payload, session, conversionHint); } return converter.toMessage(payload, session); }
/** * Extract the message body from the given JMS message. * @param message the JMS {@code Message} * @return the content of the message, to be passed into the listener method * as an argument * @throws MessageConversionException if the message could not be extracted */ protected Object extractMessage(Message message) { try { MessageConverter converter = getMessageConverter(); if (converter != null) { return converter.fromMessage(message); } return message; } catch (JMSException ex) { throw new MessageConversionException("Could not convert JMS message", ex); } }
/** * Build a JMS message to be sent as response based on the given result object. * @param session the JMS Session to operate on * @param result the content of the message, as returned from the listener method * @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 { Object content = preProcessResponse(result instanceof JmsResponse ? ((JmsResponse<?>) result).getResponse() : result); MessageConverter converter = getMessageConverter(); if (converter != null) { if (content instanceof org.springframework.messaging.Message) { return this.messagingMessageConverter.toMessage(content, session); } else { return converter.toMessage(content, session); } } if (!(content instanceof Message)) { throw new MessageConversionException( "No MessageConverter specified - cannot handle message [" + content + "]"); } return (Message) content; }
@Override protected Message createMessageForPayload(Object payload, Session session, Object conversionHint) throws JMSException { MessageConverter converter = getMessageConverter(); if (converter == null) { throw new IllegalStateException("No message converter, cannot handle '" + payload + "'"); } if (converter instanceof SmartMessageConverter) { return ((SmartMessageConverter) converter).toMessage(payload, session, conversionHint); } return converter.toMessage(payload, session); }
@Override protected Message createMessageForPayload(Object payload, Session session, @Nullable Object conversionHint) throws JMSException { MessageConverter converter = getMessageConverter(); if (converter == null) { throw new IllegalStateException("No message converter, cannot handle '" + payload + "'"); } if (converter instanceof SmartMessageConverter) { return ((SmartMessageConverter) converter).toMessage(payload, session, conversionHint); } return converter.toMessage(payload, session); }
/** * Extract the message body from the given JMS message. * @param message the JMS {@code Message} * @return the content of the message, to be passed into the listener method * as an argument * @throws MessageConversionException if the message could not be extracted */ protected Object extractMessage(Message message) { try { MessageConverter converter = getMessageConverter(); if (converter != null) { return converter.fromMessage(message); } return message; } catch (JMSException ex) { throw new MessageConversionException("Could not convert JMS message", ex); } }
/** * Build a JMS message to be sent as response based on the given result object. * @param session the JMS Session to operate on * @param result the content of the message, as returned from the listener method * @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 { Object content = preProcessResponse(result instanceof JmsResponse ? ((JmsResponse<?>) result).getResponse() : result); MessageConverter converter = getMessageConverter(); if (converter != null) { if (content instanceof org.springframework.messaging.Message) { return this.messagingMessageConverter.toMessage(content, session); } else { return converter.toMessage(content, session); } } if (!(content instanceof Message)) { throw new MessageConversionException( "No MessageConverter specified - cannot handle message [" + content + "]"); } return (Message) content; }