summaryrefslogtreecommitdiff
path: root/qpid/java
diff options
context:
space:
mode:
authorRobert Godfrey <rgodfrey@apache.org>2013-10-24 12:49:13 +0000
committerRobert Godfrey <rgodfrey@apache.org>2013-10-24 12:49:13 +0000
commit779a9279e52481bfa63acea6bf3fe7116257e83a (patch)
treed2b63eb5eba856d29fdfb42a90bc72000e34ef05 /qpid/java
parent1188148f10e2e814c58ca10e387cf1391b70ca35 (diff)
downloadqpid-python-779a9279e52481bfa63acea6bf3fe7116257e83a.tar.gz
QPID-5245 : Applied patch from David Ingham
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1535362 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/java')
-rw-r--r--qpid/java/amqp-1-0-client-jms/src/main/java/org/apache/qpid/amqp_1_0/jms/ErrorCodes.java25
-rw-r--r--qpid/java/amqp-1-0-client-jms/src/main/java/org/apache/qpid/amqp_1_0/jms/MessageConsumerException.java47
-rw-r--r--qpid/java/amqp-1-0-client-jms/src/main/java/org/apache/qpid/amqp_1_0/jms/MessageProducerException.java47
-rw-r--r--qpid/java/amqp-1-0-client-jms/src/main/java/org/apache/qpid/amqp_1_0/jms/SessionException.java35
-rw-r--r--qpid/java/amqp-1-0-client-jms/src/main/java/org/apache/qpid/amqp_1_0/jms/impl/MessageConsumerImpl.java9
-rw-r--r--qpid/java/amqp-1-0-client-jms/src/main/java/org/apache/qpid/amqp_1_0/jms/impl/MessageProducerImpl.java9
-rw-r--r--qpid/java/amqp-1-0-client-jms/src/main/java/org/apache/qpid/amqp_1_0/jms/impl/SessionImpl.java22
-rw-r--r--qpid/java/amqp-1-0-client/src/main/java/org/apache/qpid/amqp_1_0/client/ChannelsExhaustedException.java39
-rw-r--r--qpid/java/amqp-1-0-client/src/main/java/org/apache/qpid/amqp_1_0/client/Session.java14
9 files changed, 227 insertions, 20 deletions
diff --git a/qpid/java/amqp-1-0-client-jms/src/main/java/org/apache/qpid/amqp_1_0/jms/ErrorCodes.java b/qpid/java/amqp-1-0-client-jms/src/main/java/org/apache/qpid/amqp_1_0/jms/ErrorCodes.java
new file mode 100644
index 0000000000..e362befc67
--- /dev/null
+++ b/qpid/java/amqp-1-0-client-jms/src/main/java/org/apache/qpid/amqp_1_0/jms/ErrorCodes.java
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.qpid.amqp_1_0.jms;
+
+public interface ErrorCodes
+{
+ public static final String CHANNELS_EXHAUSTED = "org.apache:channels-exhausted";
+}
diff --git a/qpid/java/amqp-1-0-client-jms/src/main/java/org/apache/qpid/amqp_1_0/jms/MessageConsumerException.java b/qpid/java/amqp-1-0-client-jms/src/main/java/org/apache/qpid/amqp_1_0/jms/MessageConsumerException.java
new file mode 100644
index 0000000000..3fad24f61c
--- /dev/null
+++ b/qpid/java/amqp-1-0-client-jms/src/main/java/org/apache/qpid/amqp_1_0/jms/MessageConsumerException.java
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.qpid.amqp_1_0.jms;
+
+import javax.jms.JMSException;
+
+public class MessageConsumerException extends JMSException
+{
+ private String _destinationName = null;
+
+ public MessageConsumerException(String reason)
+ {
+ super(reason);
+ }
+
+ public MessageConsumerException(String reason, String errorCode)
+ {
+ super(reason, errorCode);
+ }
+
+ public MessageConsumerException(String reason, String errorCode, String destinationName)
+ {
+ super(reason, errorCode);
+ _destinationName = destinationName;
+ }
+
+ public String getDestinationName()
+ {
+ return _destinationName;
+ }
+}
diff --git a/qpid/java/amqp-1-0-client-jms/src/main/java/org/apache/qpid/amqp_1_0/jms/MessageProducerException.java b/qpid/java/amqp-1-0-client-jms/src/main/java/org/apache/qpid/amqp_1_0/jms/MessageProducerException.java
new file mode 100644
index 0000000000..45ea4662ac
--- /dev/null
+++ b/qpid/java/amqp-1-0-client-jms/src/main/java/org/apache/qpid/amqp_1_0/jms/MessageProducerException.java
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.qpid.amqp_1_0.jms;
+
+import javax.jms.JMSException;
+
+public class MessageProducerException extends JMSException
+{
+ private String _destinationName = null;
+
+ public MessageProducerException(String reason)
+ {
+ super(reason);
+ }
+
+ public MessageProducerException(String reason, String errorCode)
+ {
+ super(reason, errorCode);
+ }
+
+ public MessageProducerException(String reason, String errorCode, String destinationName)
+ {
+ super(reason, errorCode);
+ _destinationName = destinationName;
+ }
+
+ public String getDestinationName()
+ {
+ return _destinationName;
+ }
+}
diff --git a/qpid/java/amqp-1-0-client-jms/src/main/java/org/apache/qpid/amqp_1_0/jms/SessionException.java b/qpid/java/amqp-1-0-client-jms/src/main/java/org/apache/qpid/amqp_1_0/jms/SessionException.java
new file mode 100644
index 0000000000..73be5513c3
--- /dev/null
+++ b/qpid/java/amqp-1-0-client-jms/src/main/java/org/apache/qpid/amqp_1_0/jms/SessionException.java
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.qpid.amqp_1_0.jms;
+
+import javax.jms.JMSException;
+
+public class SessionException extends JMSException
+{
+ public SessionException(String reason)
+ {
+ super(reason);
+ }
+
+ public SessionException(String reason, String errorCode)
+ {
+ super(reason, errorCode);
+ }
+
+}
diff --git a/qpid/java/amqp-1-0-client-jms/src/main/java/org/apache/qpid/amqp_1_0/jms/impl/MessageConsumerImpl.java b/qpid/java/amqp-1-0-client-jms/src/main/java/org/apache/qpid/amqp_1_0/jms/impl/MessageConsumerImpl.java
index 9cbeb93dde..fd6f09d162 100644
--- a/qpid/java/amqp-1-0-client-jms/src/main/java/org/apache/qpid/amqp_1_0/jms/impl/MessageConsumerImpl.java
+++ b/qpid/java/amqp-1-0-client-jms/src/main/java/org/apache/qpid/amqp_1_0/jms/impl/MessageConsumerImpl.java
@@ -43,6 +43,7 @@ import org.apache.qpid.amqp_1_0.jms.Session;
import org.apache.qpid.amqp_1_0.jms.TemporaryDestination;
import org.apache.qpid.amqp_1_0.jms.Topic;
import org.apache.qpid.amqp_1_0.jms.TopicSubscriber;
+import org.apache.qpid.amqp_1_0.jms.MessageConsumerException;
import org.apache.qpid.amqp_1_0.type.Binary;
import org.apache.qpid.amqp_1_0.type.Symbol;
import org.apache.qpid.amqp_1_0.type.UnsignedInteger;
@@ -130,9 +131,13 @@ public class MessageConsumerImpl implements MessageConsumer, QueueReceiver, Topi
if(exceptionListener != null)
{
final Error receiverError = _receiver.getError();
- exceptionListener.onException(new JMSException(receiverError.getDescription(),
- receiverError.getCondition().getValue().toString()));
+ MessageConsumerException mce = new MessageConsumerException(
+ receiverError.getDescription(),
+ receiverError.getCondition().getValue().toString(),
+ _destination.getAddress());
+
+ exceptionListener.onException(mce);
}
}
catch (JMSException e)
diff --git a/qpid/java/amqp-1-0-client-jms/src/main/java/org/apache/qpid/amqp_1_0/jms/impl/MessageProducerImpl.java b/qpid/java/amqp-1-0-client-jms/src/main/java/org/apache/qpid/amqp_1_0/jms/impl/MessageProducerImpl.java
index b240359002..cee4f4f6f2 100644
--- a/qpid/java/amqp-1-0-client-jms/src/main/java/org/apache/qpid/amqp_1_0/jms/impl/MessageProducerImpl.java
+++ b/qpid/java/amqp-1-0-client-jms/src/main/java/org/apache/qpid/amqp_1_0/jms/impl/MessageProducerImpl.java
@@ -22,6 +22,7 @@ import org.apache.qpid.amqp_1_0.client.*;
import org.apache.qpid.amqp_1_0.client.Session;
import org.apache.qpid.amqp_1_0.jms.MessageProducer;
import org.apache.qpid.amqp_1_0.jms.MessageRejectedException;
+import org.apache.qpid.amqp_1_0.jms.MessageProducerException;
import org.apache.qpid.amqp_1_0.jms.QueueSender;
import org.apache.qpid.amqp_1_0.jms.TemporaryDestination;
import org.apache.qpid.amqp_1_0.jms.TopicPublisher;
@@ -112,9 +113,13 @@ public class MessageProducerImpl implements MessageProducer, QueueSender, TopicP
if(exceptionListener != null)
{
final org.apache.qpid.amqp_1_0.type.transport.Error receiverError = _sender.getError();
- exceptionListener.onException(new JMSException(receiverError.getDescription(),
- receiverError.getCondition().getValue().toString()));
+ MessageProducerException mpe = new MessageProducerException(
+ receiverError.getDescription(),
+ receiverError.getCondition().getValue().toString(),
+ _destination.getAddress());
+
+ exceptionListener.onException(mpe);
}
}
catch (JMSException e)
diff --git a/qpid/java/amqp-1-0-client-jms/src/main/java/org/apache/qpid/amqp_1_0/jms/impl/SessionImpl.java b/qpid/java/amqp-1-0-client-jms/src/main/java/org/apache/qpid/amqp_1_0/jms/impl/SessionImpl.java
index 7de2671357..c64b39c5a4 100644
--- a/qpid/java/amqp-1-0-client-jms/src/main/java/org/apache/qpid/amqp_1_0/jms/impl/SessionImpl.java
+++ b/qpid/java/amqp-1-0-client-jms/src/main/java/org/apache/qpid/amqp_1_0/jms/impl/SessionImpl.java
@@ -42,6 +42,7 @@ import org.apache.qpid.amqp_1_0.client.Connection;
import org.apache.qpid.amqp_1_0.client.ConnectionClosedException;
import org.apache.qpid.amqp_1_0.client.ConnectionErrorException;
import org.apache.qpid.amqp_1_0.client.ConnectionException;
+import org.apache.qpid.amqp_1_0.client.ChannelsExhaustedException;
import org.apache.qpid.amqp_1_0.client.Message;
import org.apache.qpid.amqp_1_0.client.Receiver;
import org.apache.qpid.amqp_1_0.client.Sender;
@@ -54,6 +55,8 @@ import org.apache.qpid.amqp_1_0.jms.TemporaryDestination;
import org.apache.qpid.amqp_1_0.jms.TopicPublisher;
import org.apache.qpid.amqp_1_0.jms.TopicSession;
import org.apache.qpid.amqp_1_0.jms.TopicSubscriber;
+import org.apache.qpid.amqp_1_0.jms.ErrorCodes;
+import org.apache.qpid.amqp_1_0.jms.SessionException;
import org.apache.qpid.amqp_1_0.transport.SessionEventListener;
import org.apache.qpid.amqp_1_0.type.messaging.Source;
import org.apache.qpid.amqp_1_0.type.messaging.Target;
@@ -90,7 +93,15 @@ public class SessionImpl implements Session, QueueSession, TopicSession
}
catch (ConnectionException e)
{
- final JMSException jmsException = new JMSException(e.getMessage());
+ JMSException jmsException;
+ if (e instanceof ChannelsExhaustedException)
+ {
+ jmsException = new JMSException(e.getMessage(), ErrorCodes.CHANNELS_EXHAUSTED);
+ }
+ else
+ {
+ jmsException = new JMSException(e.getMessage());
+ }
jmsException.setLinkedException(e);
throw jmsException;
}
@@ -116,12 +127,15 @@ public class SessionImpl implements Session, QueueSession, TopicSession
{
if(error != null)
{
- exceptionListener.onException(new JMSException(error.getDescription(),
- error.getCondition().getValue().toString()));
+ SessionException se = new SessionException(
+ error.getDescription(),
+ error.getCondition().getValue().toString());
+
+ exceptionListener.onException(se);
}
else
{
- exceptionListener.onException(new JMSException("Session remotely closed"));
+ exceptionListener.onException(new SessionException("Session remotely closed"));
}
}
}
diff --git a/qpid/java/amqp-1-0-client/src/main/java/org/apache/qpid/amqp_1_0/client/ChannelsExhaustedException.java b/qpid/java/amqp-1-0-client/src/main/java/org/apache/qpid/amqp_1_0/client/ChannelsExhaustedException.java
new file mode 100644
index 0000000000..1f23d02e02
--- /dev/null
+++ b/qpid/java/amqp-1-0-client/src/main/java/org/apache/qpid/amqp_1_0/client/ChannelsExhaustedException.java
@@ -0,0 +1,39 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.qpid.amqp_1_0.client;
+
+public class ChannelsExhaustedException extends ConnectionException
+{
+ protected ChannelsExhaustedException(final String message)
+ {
+ super(message);
+ }
+
+ public ChannelsExhaustedException(Throwable cause)
+ {
+ super(cause);
+ }
+
+ ChannelsExhaustedException()
+ {
+
+ }
+}
diff --git a/qpid/java/amqp-1-0-client/src/main/java/org/apache/qpid/amqp_1_0/client/Session.java b/qpid/java/amqp-1-0-client/src/main/java/org/apache/qpid/amqp_1_0/client/Session.java
index 21af6950d8..1c12907c49 100644
--- a/qpid/java/amqp-1-0-client/src/main/java/org/apache/qpid/amqp_1_0/client/Session.java
+++ b/qpid/java/amqp-1-0-client/src/main/java/org/apache/qpid/amqp_1_0/client/Session.java
@@ -51,13 +51,13 @@ public class Session
private TransactionController _sessionLocalTC;
private Connection _connection;
- public Session(final Connection connection, String name) throws SessionCreationException
+ public Session(final Connection connection, String name) throws ChannelsExhaustedException
{
_connection = connection;
_endpoint = connection.getEndpoint().createSession(name);
if(_endpoint == null)
{
- throw new SessionCreationException("Cannot create session as all channels are in use");
+ throw new ChannelsExhaustedException("Cannot create session as all channels are in use");
}
_sectionEncoder = new SectionEncoderImpl(connection.getEndpoint().getDescribedTypeRegistry());
_sectionDecoder = new SectionDecoderImpl(connection.getEndpoint().getDescribedTypeRegistry());
@@ -389,14 +389,4 @@ public class Session
{
public void configureSource(final Source source);
}
-
- private class SessionCreationException extends ConnectionException
- {
-
- private SessionCreationException(final String message)
- {
- super(message);
- }
-
- }
}