diff options
| author | Rajith Muditha Attapattu <rajith@apache.org> | 2011-01-25 03:23:22 +0000 |
|---|---|---|
| committer | Rajith Muditha Attapattu <rajith@apache.org> | 2011-01-25 03:23:22 +0000 |
| commit | 0fcb012b16caebf855f975bf30d8d31cd1b49bd0 (patch) | |
| tree | 56e3a5bc8a2dd01f623d1332376325a2f4d90b24 /java/client/src | |
| parent | 8a4866524a3fb7ce671058b3fd60d57a805ba6b4 (diff) | |
| download | qpid-python-0fcb012b16caebf855f975bf30d8d31cd1b49bd0.tar.gz | |
QPID-3019
The createMessageProducer method now throws a JMSException.
The MessageProducer constructors now throw an AMQException allowing any exceptions caught during destination validation to be propogated back to the createMessageProducer method.
Fixed the exception handling for the 0-10 code path where all exceptions are chained properly. This allows the user to get all the relavent information by examing the stack trace.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@1063123 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/client/src')
6 files changed, 47 insertions, 14 deletions
diff --git a/java/client/src/main/java/org/apache/qpid/client/AMQSession.java b/java/client/src/main/java/org/apache/qpid/client/AMQSession.java index f54189db6d..b5c41e483c 100644 --- a/java/client/src/main/java/org/apache/qpid/client/AMQSession.java +++ b/java/client/src/main/java/org/apache/qpid/client/AMQSession.java @@ -2566,7 +2566,7 @@ public abstract class AMQSession<C extends BasicMessageConsumer, P extends Basic } public abstract P createMessageProducer(final Destination destination, final boolean mandatory, - final boolean immediate, final boolean waitUntilSent, long producerId); + final boolean immediate, final boolean waitUntilSent, long producerId) throws JMSException; private void declareExchange(AMQDestination amqd, AMQProtocolHandler protocolHandler, boolean nowait) throws AMQException { diff --git a/java/client/src/main/java/org/apache/qpid/client/AMQSession_0_10.java b/java/client/src/main/java/org/apache/qpid/client/AMQSession_0_10.java index 297a8da65b..81f1d3e5e7 100644 --- a/java/client/src/main/java/org/apache/qpid/client/AMQSession_0_10.java +++ b/java/client/src/main/java/org/apache/qpid/client/AMQSession_0_10.java @@ -660,10 +660,21 @@ public class AMQSession_0_10 extends AMQSession<BasicMessageConsumer_0_10, Basic */ public BasicMessageProducer_0_10 createMessageProducer(final Destination destination, final boolean mandatory, final boolean immediate, final boolean waitUntilSent, - long producerId) + long producerId) throws JMSException { - return new BasicMessageProducer_0_10(_connection, (AMQDestination) destination, _transacted, _channelId, this, + try + { + return new BasicMessageProducer_0_10(_connection, (AMQDestination) destination, _transacted, _channelId, this, getProtocolHandler(), producerId, immediate, mandatory, waitUntilSent); + } + catch (AMQException e) + { + JMSException ex = new JMSException("Error creating producer"); + ex.initCause(e); + ex.setLinkedException(e); + + throw ex; + } } diff --git a/java/client/src/main/java/org/apache/qpid/client/AMQSession_0_8.java b/java/client/src/main/java/org/apache/qpid/client/AMQSession_0_8.java index 8cca92da1f..f41b1c94fa 100644 --- a/java/client/src/main/java/org/apache/qpid/client/AMQSession_0_8.java +++ b/java/client/src/main/java/org/apache/qpid/client/AMQSession_0_8.java @@ -400,11 +400,21 @@ public final class AMQSession_0_8 extends AMQSession<BasicMessageConsumer_0_8, B public BasicMessageProducer_0_8 createMessageProducer(final Destination destination, final boolean mandatory, - final boolean immediate, final boolean waitUntilSent, long producerId) + final boolean immediate, final boolean waitUntilSent, long producerId) throws JMSException { - - return new BasicMessageProducer_0_8(_connection, (AMQDestination) destination, _transacted, _channelId, + try + { + return new BasicMessageProducer_0_8(_connection, (AMQDestination) destination, _transacted, _channelId, this, getProtocolHandler(), producerId, immediate, mandatory, waitUntilSent); + } + catch (AMQException e) + { + JMSException ex = new JMSException("Error creating producer"); + ex.initCause(e); + ex.setLinkedException(e); + + throw ex; + } } diff --git a/java/client/src/main/java/org/apache/qpid/client/BasicMessageProducer.java b/java/client/src/main/java/org/apache/qpid/client/BasicMessageProducer.java index 14e1601993..8756ac4d05 100644 --- a/java/client/src/main/java/org/apache/qpid/client/BasicMessageProducer.java +++ b/java/client/src/main/java/org/apache/qpid/client/BasicMessageProducer.java @@ -127,7 +127,7 @@ public abstract class BasicMessageProducer extends Closeable implements org.apac protected BasicMessageProducer(AMQConnection connection, AMQDestination destination, boolean transacted, int channelId, AMQSession session, AMQProtocolHandler protocolHandler, long producerId, boolean immediate, boolean mandatory, - boolean waitUntilSent) + boolean waitUntilSent) throws AMQException { _connection = connection; _destination = destination; @@ -175,7 +175,7 @@ public abstract class BasicMessageProducer extends Closeable implements org.apac } } - abstract void declareDestination(AMQDestination destination); + abstract void declareDestination(AMQDestination destination) throws AMQException; public void setDisableMessageID(boolean b) throws JMSException { @@ -434,7 +434,18 @@ public abstract class BasicMessageProducer extends Closeable implements org.apac AMQDestination amqDestination = (AMQDestination) destination; if(!amqDestination.isExchangeExistsChecked()) { - declareDestination(amqDestination); + try + { + declareDestination(amqDestination); + } + catch(Exception e) + { + JMSException ex = new JMSException("Error validating destination"); + ex.initCause(e); + ex.setLinkedException(e); + + throw ex; + } amqDestination.setExchangeExistsChecked(true); } } diff --git a/java/client/src/main/java/org/apache/qpid/client/BasicMessageProducer_0_10.java b/java/client/src/main/java/org/apache/qpid/client/BasicMessageProducer_0_10.java index f874ea08f2..53c0457120 100644 --- a/java/client/src/main/java/org/apache/qpid/client/BasicMessageProducer_0_10.java +++ b/java/client/src/main/java/org/apache/qpid/client/BasicMessageProducer_0_10.java @@ -56,7 +56,7 @@ public class BasicMessageProducer_0_10 extends BasicMessageProducer BasicMessageProducer_0_10(AMQConnection connection, AMQDestination destination, boolean transacted, int channelId, AMQSession session, AMQProtocolHandler protocolHandler, long producerId, - boolean immediate, boolean mandatory, boolean waitUntilSent) + boolean immediate, boolean mandatory, boolean waitUntilSent) throws AMQException { super(connection, destination, transacted, channelId, session, protocolHandler, producerId, immediate, mandatory, waitUntilSent); @@ -64,7 +64,7 @@ public class BasicMessageProducer_0_10 extends BasicMessageProducer userIDBytes = Strings.toUTF8(_userID); } - void declareDestination(AMQDestination destination) + void declareDestination(AMQDestination destination) throws AMQException { if (destination.getDestSyntax() == DestSyntax.BURL) { @@ -83,8 +83,8 @@ public class BasicMessageProducer_0_10 extends BasicMessageProducer } catch(Exception e) { - // Idealy this should be thrown to the JMS layer. - _logger.warn("Exception occured while verifying destination",e); + AMQException ex = new AMQException("Exception occured while verifying destination",e); + throw ex; } } } diff --git a/java/client/src/main/java/org/apache/qpid/client/BasicMessageProducer_0_8.java b/java/client/src/main/java/org/apache/qpid/client/BasicMessageProducer_0_8.java index b770a8b524..27f7486890 100644 --- a/java/client/src/main/java/org/apache/qpid/client/BasicMessageProducer_0_8.java +++ b/java/client/src/main/java/org/apache/qpid/client/BasicMessageProducer_0_8.java @@ -28,6 +28,7 @@ import javax.jms.Topic; import javax.jms.Queue; import org.apache.mina.common.ByteBuffer; +import org.apache.qpid.AMQException; import org.apache.qpid.client.message.AbstractJMSMessage; import org.apache.qpid.client.message.AMQMessageDelegate; import org.apache.qpid.client.message.AMQMessageDelegate_0_8; @@ -46,7 +47,7 @@ public class BasicMessageProducer_0_8 extends BasicMessageProducer BasicMessageProducer_0_8(AMQConnection connection, AMQDestination destination, boolean transacted, int channelId, AMQSession session, AMQProtocolHandler protocolHandler, long producerId, boolean immediate, boolean mandatory, - boolean waitUntilSent) + boolean waitUntilSent) throws AMQException { super(connection, destination,transacted,channelId,session, protocolHandler, producerId, immediate, mandatory,waitUntilSent); } |
