MessagingExceptionTranslator lives in support subpackage now

Issue: SPR-12038
This commit is contained in:
Juergen Hoeller
2014-07-29 16:22:47 +02:00
parent 9be04b3883
commit 1fe742addf
6 changed files with 31 additions and 24 deletions

View File

@@ -23,15 +23,16 @@ import javax.jms.Session;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.jms.JmsException;
import org.springframework.jms.support.JmsMessagingExceptionTranslator;
import org.springframework.jms.support.converter.MessageConverter;
import org.springframework.jms.support.converter.MessagingMessageConverter;
import org.springframework.jms.support.converter.SimpleMessageConverter;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessagingException;
import org.springframework.messaging.MessagingExceptionTranslator;
import org.springframework.messaging.converter.MessageConversionException;
import org.springframework.messaging.core.AbstractMessagingTemplate;
import org.springframework.messaging.core.MessagePostProcessor;
import org.springframework.messaging.support.MessagingExceptionTranslator;
import org.springframework.util.Assert;
/**
@@ -230,14 +231,14 @@ public class JmsMessagingTemplate extends AbstractMessagingTemplate<Destination>
}
@Override
public Message<?> sendAndReceive(String destinationName, Message<?> requestMessage)
throws MessagingException {
public Message<?> sendAndReceive(String destinationName, Message<?> requestMessage) throws MessagingException {
return doSendAndReceive(destinationName, requestMessage);
}
@Override
public <T> T convertSendAndReceive(String destinationName, Object request, Class<T> targetClass)
throws MessagingException {
return convertSendAndReceive(destinationName, request, null, targetClass);
}
@@ -324,8 +325,8 @@ public class JmsMessagingTemplate extends AbstractMessagingTemplate<Destination>
@Override
protected Message<?> doSendAndReceive(Destination destination, Message<?> requestMessage) {
try {
javax.jms.Message jmsMessage = this.jmsTemplate
.sendAndReceive(destination, createMessageCreator(requestMessage));
javax.jms.Message jmsMessage = this.jmsTemplate.sendAndReceive(
destination, createMessageCreator(requestMessage));
return doConvert(jmsMessage);
}
catch (JmsException ex) {
@@ -335,8 +336,8 @@ public class JmsMessagingTemplate extends AbstractMessagingTemplate<Destination>
protected Message<?> doSendAndReceive(String destinationName, Message<?> requestMessage) {
try {
javax.jms.Message jmsMessage = this.jmsTemplate
.sendAndReceive(destinationName, createMessageCreator(requestMessage));
javax.jms.Message jmsMessage = this.jmsTemplate.sendAndReceive(
destinationName, createMessageCreator(requestMessage));
return doConvert(jmsMessage);
}
catch (JmsException ex) {
@@ -396,10 +397,10 @@ public class JmsMessagingTemplate extends AbstractMessagingTemplate<Destination>
return this.messageConverter.toMessage(this.message, session);
}
catch (JMSException ex) {
throw new MessageConversionException("Could not convert '" + message + "'", ex);
throw new MessageConversionException("Could not convert '" + this.message + "'", ex);
}
catch (JmsException ex) {
throw new MessageConversionException("Could not convert '" + message + "'", ex);
throw new MessageConversionException("Could not convert '" + this.message + "'", ex);
}
}
}

View File

@@ -367,6 +367,7 @@ public interface JmsOperations {
* @return the reply, possibly {@code null} if the message could not be received,
* for example due to a timeout
* @throws JmsException checked JMSException converted to unchecked
* @since 4.1
*/
Message sendAndReceive(MessageCreator messageCreator) throws JmsException;
@@ -380,6 +381,7 @@ public interface JmsOperations {
* @return the reply, possibly {@code null} if the message could not be received,
* for example due to a timeout
* @throws JmsException checked JMSException converted to unchecked
* @since 4.1
*/
Message sendAndReceive(Destination destination, MessageCreator messageCreator) throws JmsException;
@@ -394,6 +396,7 @@ public interface JmsOperations {
* @return the reply, possibly {@code null} if the message could not be received,
* for example due to a timeout
* @throws JmsException checked JMSException converted to unchecked
* @since 4.1
*/
Message sendAndReceive(String destinationName, MessageCreator messageCreator) throws JmsException;

View File

@@ -936,6 +936,7 @@ public class JmsTemplate extends JmsDestinationAccessor implements JmsOperations
*/
protected Message doSendAndReceive(Session session, Destination destination, MessageCreator messageCreator)
throws JMSException {
Assert.notNull(messageCreator, "MessageCreator must not be null");
TemporaryQueue responseQueue = null;
MessageProducer producer = null;
@@ -963,7 +964,7 @@ public class JmsTemplate extends JmsDestinationAccessor implements JmsOperations
/**
* A variant of {@link #execute(SessionCallback, boolean)} that explicitly
* creates a non transactional session. The given {@link SessionCallback}
* creates a non-transactional {@link Session}. The given {@link SessionCallback}
* does not participate in an existing transaction.
*/
private <T> T executeLocal(SessionCallback<T> action, boolean startConnection) throws JmsException {

View File

@@ -14,14 +14,14 @@
* limitations under the License.
*/
package org.springframework.jms.core;
package org.springframework.jms.support;
import org.springframework.jms.InvalidDestinationException;
import org.springframework.jms.JmsException;
import org.springframework.jms.support.converter.MessageConversionException;
import org.springframework.jms.support.destination.DestinationResolutionException;
import org.springframework.messaging.MessagingException;
import org.springframework.messaging.MessagingExceptionTranslator;
import org.springframework.messaging.support.MessagingExceptionTranslator;
/**
* {@link MessagingExceptionTranslator} capable of translating {@link JmsException}
@@ -41,16 +41,14 @@ public class JmsMessagingExceptionTranslator implements MessagingExceptionTransl
}
private MessagingException convertJmsException(JmsException ex) {
if (ex instanceof DestinationResolutionException ||
ex instanceof InvalidDestinationException) {
if (ex instanceof DestinationResolutionException || ex instanceof InvalidDestinationException) {
return new org.springframework.messaging.core.DestinationResolutionException(ex.getMessage(), ex);
}
if (ex instanceof MessageConversionException) {
return new org.springframework.messaging.converter.MessageConversionException(ex.getMessage(), ex);
}
// Fallback
return new MessagingException(ex.getMessage(), ex);
}
}