From 0a7426287fb6c2f560f6f77c9d0d624a01eabab7 Mon Sep 17 00:00:00 2001 From: Mark Fisher Date: Mon, 10 Oct 2011 16:39:11 -0400 Subject: [PATCH] fallback if proxy does not support Queue* types --- .../integration/jms/JmsOutboundGateway.java | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/spring-integration-jms/src/main/java/org/springframework/integration/jms/JmsOutboundGateway.java b/spring-integration-jms/src/main/java/org/springframework/integration/jms/JmsOutboundGateway.java index 706647822b..9382cfb110 100644 --- a/spring-integration-jms/src/main/java/org/springframework/integration/jms/JmsOutboundGateway.java +++ b/spring-integration-jms/src/main/java/org/springframework/integration/jms/JmsOutboundGateway.java @@ -379,7 +379,6 @@ public class JmsOutboundGateway extends AbstractReplyProducingMessageHandler { } } - @SuppressWarnings("unchecked") @Override protected Object handleRequestMessage(final Message message) { if (!this.initialized) { @@ -581,7 +580,15 @@ public class JmsOutboundGateway extends AbstractReplyProducingMessageHandler { protected Connection createConnection() throws JMSException { ConnectionFactory cf = this.connectionFactory; if (!this.requestPubSubDomain && !this.replyPubSubDomain && cf instanceof QueueConnectionFactory) { - return ((QueueConnectionFactory) cf).createQueueConnection(); + try { + return ((QueueConnectionFactory) cf).createQueueConnection(); + } + catch (Exception e) { + if (logger.isWarnEnabled()) { + logger.warn("An error occurred while trying to use ConnectionFactory as a QueueConnectionFactory " + + " even though the instanceof check passed. Falling back to use it only as a ConnectionFactory."); + } + } } return cf.createConnection(); } @@ -597,7 +604,15 @@ public class JmsOutboundGateway extends AbstractReplyProducingMessageHandler { */ protected Session createSession(Connection connection) throws JMSException { if (!this.requestPubSubDomain && !this.replyPubSubDomain && connection instanceof QueueConnection) { - return ((QueueConnection) connection).createQueueSession(false, Session.AUTO_ACKNOWLEDGE); + try { + return ((QueueConnection) connection).createQueueSession(false, Session.AUTO_ACKNOWLEDGE); + } + catch (Exception e) { + if (logger.isWarnEnabled()) { + logger.warn("An error occurred while trying to use Connection as a QueueConnection " + + " even though the instanceof check passed. Falling back to use it only as a Connection."); + } + } } return connection.createSession(false, Session.AUTO_ACKNOWLEDGE); }