summaryrefslogtreecommitdiff
path: root/java/client/src/main/java/org/apache
diff options
context:
space:
mode:
authorKeith Wall <kwall@apache.org>2011-10-06 18:36:38 +0000
committerKeith Wall <kwall@apache.org>2011-10-06 18:36:38 +0000
commita383c2e4f5acb3654ce8e927d7035752e75674e9 (patch)
tree6fb9ca35944f0c3e37e794b7e8115a58f6e34961 /java/client/src/main/java/org/apache
parentb60aee6f1f3e167fd42d343cd33235b07b5ffe6b (diff)
downloadqpid-python-a383c2e4f5acb3654ce8e927d7035752e75674e9.tar.gz
QPID-2442: Make 0-10 TemporaryQueue#delete and TemporaryTopic#delete perform the delete on the Broker
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@1179754 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/client/src/main/java/org/apache')
-rw-r--r--java/client/src/main/java/org/apache/qpid/client/AMQSession.java15
-rw-r--r--java/client/src/main/java/org/apache/qpid/client/AMQSession_0_8.java19
-rw-r--r--java/client/src/main/java/org/apache/qpid/client/AMQTemporaryQueue.java17
-rw-r--r--java/client/src/main/java/org/apache/qpid/client/AMQTemporaryTopic.java12
-rw-r--r--java/client/src/main/java/org/apache/qpid/client/TemporaryDestination.java5
5 files changed, 52 insertions, 16 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 30c7403a90..4f7d344655 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
@@ -2772,6 +2772,21 @@ public abstract class AMQSession<C extends BasicMessageConsumer, P extends Basic
}
}
+ /**
+ * Undeclares the specified temporary queue/topic.
+ *
+ * <p/>Note that this operation automatically retries in the event of fail-over.
+ *
+ * @param amqQueue The name of the temporary destination to delete.
+ *
+ * @throws JMSException If the queue could not be deleted for any reason.
+ * @todo Be aware of possible changes to parameter order as versions change.
+ */
+ protected void deleteTemporaryDestination(final TemporaryDestination amqQueue) throws JMSException
+ {
+ deleteQueue(amqQueue.getAMQQueueName());
+ }
+
public abstract void sendQueueDelete(final AMQShortString queueName) throws AMQException, FailoverException;
private long getNextProducerId()
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 ccb2b00947..369c8a6e9d 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
@@ -82,7 +82,6 @@ import org.slf4j.LoggerFactory;
public final class AMQSession_0_8 extends AMQSession<BasicMessageConsumer_0_8, BasicMessageProducer_0_8>
{
-
/** Used for debugging. */
private static final Logger _logger = LoggerFactory.getLogger(AMQSession.class);
@@ -92,7 +91,7 @@ public final class AMQSession_0_8 extends AMQSession<BasicMessageConsumer_0_8, B
* @param con The connection on which to create the session.
* @param channelId The unique identifier for the session.
* @param transacted Indicates whether or not the session is transactional.
- * @param acknowledgeMode The acknoledgement mode for the session.
+ * @param acknowledgeMode The acknowledgement mode for the session.
* @param messageFactoryRegistry The message factory factory for the session.
* @param defaultPrefetchHighMark The maximum number of messages to prefetched before suspending the session.
* @param defaultPrefetchLowMark The number of prefetched messages at which to resume the session.
@@ -110,7 +109,7 @@ public final class AMQSession_0_8 extends AMQSession<BasicMessageConsumer_0_8, B
* @param con The connection on which to create the session.
* @param channelId The unique identifier for the session.
* @param transacted Indicates whether or not the session is transactional.
- * @param acknowledgeMode The acknoledgement mode for the session.
+ * @param acknowledgeMode The acknowledgement mode for the session.
* @param defaultPrefetchHigh The maximum number of messages to prefetched before suspending the session.
* @param defaultPrefetchLow The number of prefetched messages at which to resume the session.
*/
@@ -169,7 +168,7 @@ public final class AMQSession_0_8 extends AMQSession<BasicMessageConsumer_0_8, B
// we also need to check the state manager for 08/09 as the
// _connection variable may not be updated in time by the error receiving
// thread.
- // We can't close the session if we are alreadying in the process of
+ // We can't close the session if we are already in the process of
// closing/closed the connection.
if (!(getProtocolHandler().getStateManager().getCurrentState().equals(AMQState.CONNECTION_CLOSED)
@@ -605,6 +604,18 @@ public final class AMQSession_0_8 extends AMQSession<BasicMessageConsumer_0_8, B
}
+ @Override
+ protected void deleteTemporaryDestination(final TemporaryDestination amqQueue)
+ throws JMSException
+ {
+ // Currently TemporaryDestination is set to be auto-delete which, for 0-8..0-9-1, means that the queue will be deleted
+ // by the server when there are no more subscriptions to that queue/topic (rather than when the client disconnects).
+ // This is not quite right for JMSCompliance as the queue/topic should remain until the connection closes, or the
+ // client explicitly deletes it.
+
+ /* intentional no-op */
+ }
+
public boolean isQueueBound(String exchangeName, String queueName,
String bindingKey, Map<String, Object> args) throws JMSException
{
diff --git a/java/client/src/main/java/org/apache/qpid/client/AMQTemporaryQueue.java b/java/client/src/main/java/org/apache/qpid/client/AMQTemporaryQueue.java
index f54cb782c8..28f838057e 100644
--- a/java/client/src/main/java/org/apache/qpid/client/AMQTemporaryQueue.java
+++ b/java/client/src/main/java/org/apache/qpid/client/AMQTemporaryQueue.java
@@ -20,14 +20,13 @@
*/
package org.apache.qpid.client;
+import java.util.UUID;
+
import javax.jms.JMSException;
import javax.jms.TemporaryQueue;
import org.apache.qpid.framing.AMQShortString;
-import java.util.Random;
-import java.util.UUID;
-
/** AMQ implementation of a TemporaryQueue. */
final class AMQTemporaryQueue extends AMQQueue implements TemporaryQueue, TemporaryDestination
{
@@ -50,11 +49,15 @@ final class AMQTemporaryQueue extends AMQQueue implements TemporaryQueue, Tempor
{
throw new JMSException("Temporary Queue has consumers so cannot be deleted");
}
- _deleted = true;
- // Currently TemporaryQueue is set to be auto-delete which means that the queue will be deleted
- // by the server when there are no more subscriptions to that queue. This is probably not
- // quite right for JMSCompliance.
+ try
+ {
+ _session.deleteTemporaryDestination(this);
+ }
+ finally
+ {
+ _deleted = true;
+ }
}
public AMQSession getSession()
diff --git a/java/client/src/main/java/org/apache/qpid/client/AMQTemporaryTopic.java b/java/client/src/main/java/org/apache/qpid/client/AMQTemporaryTopic.java
index 7b5781530b..db54b320dc 100644
--- a/java/client/src/main/java/org/apache/qpid/client/AMQTemporaryTopic.java
+++ b/java/client/src/main/java/org/apache/qpid/client/AMQTemporaryTopic.java
@@ -53,10 +53,14 @@ class AMQTemporaryTopic extends AMQTopic implements TemporaryTopic, TemporaryDes
throw new JMSException("Temporary Topic has consumers so cannot be deleted");
}
- _deleted = true;
- // Currently TemporaryQueue is set to be auto-delete which means that the queue will be deleted
- // by the server when there are no more subscriptions to that queue. This is probably not
- // quite right for JMSCompliance.
+ try
+ {
+ _session.deleteTemporaryDestination(this);
+ }
+ finally
+ {
+ _deleted = true;
+ }
}
public AMQSession getSession()
diff --git a/java/client/src/main/java/org/apache/qpid/client/TemporaryDestination.java b/java/client/src/main/java/org/apache/qpid/client/TemporaryDestination.java
index 7f8e80c73a..ca137f5a51 100644
--- a/java/client/src/main/java/org/apache/qpid/client/TemporaryDestination.java
+++ b/java/client/src/main/java/org/apache/qpid/client/TemporaryDestination.java
@@ -24,13 +24,16 @@ package org.apache.qpid.client;
import javax.jms.Destination;
import javax.jms.JMSException;
+import org.apache.qpid.framing.AMQShortString;
+
/**
- * Provides support for covenience interface implemented by both AMQTemporaryTopic and AMQTemporaryQueue
+ * Provides support for convenience interface implemented by both AMQTemporaryTopic and AMQTemporaryQueue
* so that operations related to their "temporary-ness" can be abstracted out.
*/
interface TemporaryDestination extends Destination
{
+ public AMQShortString getAMQQueueName();
public void delete() throws JMSException;
public AMQSession getSession();
public boolean isDeleted();