You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by cl...@apache.org on 2016/11/23 15:45:48 UTC
[1/2] activemq-artemis git commit: ARTEMIS-864 Sending to a destroyed
temp queue didn't get exception
Repository: activemq-artemis
Updated Branches:
refs/heads/master 442b8ef65 -> 0e1fa2b96
ARTEMIS-864 Sending to a destroyed temp queue didn't get exception
Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/1487fe6b
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/1487fe6b
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/1487fe6b
Branch: refs/heads/master
Commit: 1487fe6bdd08456ba7492f1fe8755fd16bbf4548
Parents: 442b8ef
Author: Howard Gao <ho...@gmail.com>
Authored: Tue Nov 22 15:47:37 2016 +0800
Committer: Howard Gao <ho...@gmail.com>
Committed: Tue Nov 22 19:42:38 2016 +0800
----------------------------------------------------------------------
.../protocol/openwire/OpenWireConnection.java | 22 ++++++++-
.../protocol/openwire/util/OpenWireUtil.java | 6 ++-
.../artemis/core/server/TempQueueObserver.java | 24 ++++++++++
.../core/server/impl/ServerSessionImpl.java | 13 ++++++
.../openwire/SimpleOpenWireTest.java | 48 ++++++++++++++++++++
5 files changed, 111 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/1487fe6b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireConnection.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireConnection.java b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireConnection.java
index 8dc0b34..a984a1c 100644
--- a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireConnection.java
+++ b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireConnection.java
@@ -65,6 +65,7 @@ import org.apache.activemq.artemis.core.server.Queue;
import org.apache.activemq.artemis.core.server.ServerConsumer;
import org.apache.activemq.artemis.core.server.ServerSession;
import org.apache.activemq.artemis.core.server.SlowConsumerDetectionListener;
+import org.apache.activemq.artemis.core.server.TempQueueObserver;
import org.apache.activemq.artemis.core.server.impl.RefsOperation;
import org.apache.activemq.artemis.core.transaction.Transaction;
import org.apache.activemq.artemis.core.transaction.TransactionOperationAbstract;
@@ -76,6 +77,7 @@ import org.apache.activemq.artemis.spi.core.remoting.Connection;
import org.apache.activemq.artemis.utils.UUIDGenerator;
import org.apache.activemq.command.ActiveMQDestination;
import org.apache.activemq.command.ActiveMQMessage;
+import org.apache.activemq.command.ActiveMQTempQueue;
import org.apache.activemq.command.ActiveMQTopic;
import org.apache.activemq.command.BrokerInfo;
import org.apache.activemq.command.BrokerSubscriptionInfo;
@@ -125,7 +127,7 @@ import org.jboss.logging.Logger;
/**
* Represents an activemq connection.
*/
-public class OpenWireConnection extends AbstractRemotingConnection implements SecurityAuth {
+public class OpenWireConnection extends AbstractRemotingConnection implements SecurityAuth, TempQueueObserver {
private static final Logger logger = Logger.getLogger(OpenWireConnection.class);
@@ -789,6 +791,24 @@ public class OpenWireConnection extends AbstractRemotingConnection implements Se
checkInactivity();
}
+ @Override
+ public void tempQueueDeleted(SimpleString bindingName) {
+ String amqName = OpenWireUtil.toAMQAddress(bindingName.toString());
+ ActiveMQDestination dest = new ActiveMQTempQueue(amqName);
+
+ if (!AdvisorySupport.isAdvisoryTopic(dest)) {
+ AMQConnectionContext context = getContext();
+ DestinationInfo advInfo = new DestinationInfo(context.getConnectionId(), DestinationInfo.REMOVE_OPERATION_TYPE, dest);
+
+ ActiveMQTopic topic = AdvisorySupport.getDestinationAdvisoryTopic(dest);
+ try {
+ protocolManager.fireAdvisory(context, topic, advInfo);
+ } catch (Exception e) {
+ logger.warn("Failed to fire advisory on " + topic, e);
+ }
+ }
+ }
+
class SlowConsumerDetection implements SlowConsumerDetectionListener {
@Override
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/1487fe6b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/util/OpenWireUtil.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/util/OpenWireUtil.java b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/util/OpenWireUtil.java
index 05e1e34..0ad6043 100644
--- a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/util/OpenWireUtil.java
+++ b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/util/OpenWireUtil.java
@@ -58,6 +58,10 @@ public class OpenWireUtil {
}
}
+ public static String toAMQAddress(String coreAddress) {
+ return coreAddress.replace(JMS_QUEUE_ADDRESS_PREFIX, "").replace(JMS_TEMP_QUEUE_ADDRESS_PREFIX, "").replace(JMS_TOPIC_ADDRESS_PREFIX, "").replace(JMS_TEMP_TOPIC_ADDRESS_PREFIX, "");
+ }
+
/**
* We convert the core address to an ActiveMQ Destination. We use the actual address on the message rather than the
* destination set on the consumer because it maybe different and the JMS spec says that it should be what ever was
@@ -66,7 +70,7 @@ public class OpenWireUtil {
*/
public static ActiveMQDestination toAMQAddress(ServerMessage message, ActiveMQDestination actualDestination) {
String address = message.getAddress().toString();
- String strippedAddress = address.replace(JMS_QUEUE_ADDRESS_PREFIX, "").replace(JMS_TEMP_QUEUE_ADDRESS_PREFIX, "").replace(JMS_TOPIC_ADDRESS_PREFIX, "").replace(JMS_TEMP_TOPIC_ADDRESS_PREFIX, "");
+ String strippedAddress = toAMQAddress(address);
if (actualDestination.isQueue()) {
return new ActiveMQQueue(strippedAddress);
} else {
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/1487fe6b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/TempQueueObserver.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/TempQueueObserver.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/TempQueueObserver.java
new file mode 100644
index 0000000..91cc36d
--- /dev/null
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/TempQueueObserver.java
@@ -0,0 +1,24 @@
+/*
+ * 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.activemq.artemis.core.server;
+
+import org.apache.activemq.artemis.api.core.SimpleString;
+
+public interface TempQueueObserver {
+
+ void tempQueueDeleted(SimpleString bindingName);
+}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/1487fe6b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerSessionImpl.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerSessionImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerSessionImpl.java
index 37d99bb..627b201 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerSessionImpl.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerSessionImpl.java
@@ -75,6 +75,7 @@ import org.apache.activemq.artemis.core.server.RoutingContext;
import org.apache.activemq.artemis.core.server.ServerConsumer;
import org.apache.activemq.artemis.core.server.ServerMessage;
import org.apache.activemq.artemis.core.server.ServerSession;
+import org.apache.activemq.artemis.core.server.TempQueueObserver;
import org.apache.activemq.artemis.core.server.management.ManagementService;
import org.apache.activemq.artemis.core.server.management.Notification;
import org.apache.activemq.artemis.core.transaction.ResourceManager;
@@ -526,6 +527,9 @@ public class ServerSessionImpl implements ServerSession, FailureListener {
// It is up to the user to delete the queue when finished with it
TempQueueCleanerUpper cleaner = new TempQueueCleanerUpper(server, name);
+ if (remotingConnection instanceof TempQueueObserver) {
+ cleaner.setObserver((TempQueueObserver) remotingConnection);
+ }
remotingConnection.addCloseListener(cleaner);
remotingConnection.addFailureListener(cleaner);
@@ -566,12 +570,18 @@ public class ServerSessionImpl implements ServerSession, FailureListener {
private final ActiveMQServer server;
+ private TempQueueObserver observer;
+
public TempQueueCleanerUpper(final ActiveMQServer server, final SimpleString bindingName) {
this.server = server;
this.bindingName = bindingName;
}
+ public void setObserver(TempQueueObserver observer) {
+ this.observer = observer;
+ }
+
private void run() {
try {
if (logger.isDebugEnabled()) {
@@ -579,6 +589,9 @@ public class ServerSessionImpl implements ServerSession, FailureListener {
}
try {
server.destroyQueue(bindingName, null, false);
+ if (observer != null) {
+ observer.tempQueueDeleted(bindingName);
+ }
} catch (ActiveMQException e) {
// that's fine.. it can happen due to queue already been deleted
logger.debug(e.getMessage(), e);
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/1487fe6b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/SimpleOpenWireTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/SimpleOpenWireTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/SimpleOpenWireTest.java
index 81f0f1b..9798fa6 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/SimpleOpenWireTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/SimpleOpenWireTest.java
@@ -17,7 +17,9 @@
package org.apache.activemq.artemis.tests.integration.openwire;
import javax.jms.Connection;
+import javax.jms.DeliveryMode;
import javax.jms.Destination;
+import javax.jms.InvalidDestinationException;
import javax.jms.JMSException;
import javax.jms.MapMessage;
import javax.jms.Message;
@@ -1146,6 +1148,52 @@ public class SimpleOpenWireTest extends BasicOpenWireTest {
}
+ @Test
+ public void testTempQueueSendAfterConnectionClose() throws Exception {
+
+ Connection connection1 = null;
+ Connection connection2 = null;
+
+ try {
+ connection1 = factory.createConnection();
+ connection2 = factory.createConnection();
+ connection1.start();
+ connection2.start();
+
+ Session session1 = connection1.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ Queue tempQueue = session1.createTemporaryQueue();
+
+ Session session2 = connection2.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ MessageProducer producer = session2.createProducer(tempQueue);
+ producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
+ TextMessage m = session2.createTextMessage("Hello temp queue");
+ producer.send(m);
+
+ MessageConsumer consumer = session1.createConsumer(tempQueue);
+ TextMessage received = (TextMessage) consumer.receive(5000);
+ assertNotNull(received);
+ assertEquals("Hello temp queue", received.getText());
+
+ //close first connection, let temp queue die
+ connection1.close();
+
+ //send again
+ try {
+ producer.send(m);
+ fail("Send should fail since temp destination should not exist anymore.");
+ } catch (InvalidDestinationException e) {
+ //ignore
+ }
+ } finally {
+ if (connection1 != null) {
+ connection1.close();
+ }
+ if (connection2 != null) {
+ connection2.close();
+ }
+ }
+ }
+
private void checkQueueEmpty(String qName) {
PostOffice po = server.getPostOffice();
LocalQueueBinding binding = (LocalQueueBinding) po.getBinding(SimpleString.toSimpleString("jms.queue." + qName));
[2/2] activemq-artemis git commit: This closes #894
Posted by cl...@apache.org.
This closes #894
Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/0e1fa2b9
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/0e1fa2b9
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/0e1fa2b9
Branch: refs/heads/master
Commit: 0e1fa2b968dd2e4e8d6afe68d047b4c0fa69a1f2
Parents: 442b8ef 1487fe6
Author: Clebert Suconic <cl...@apache.org>
Authored: Wed Nov 23 10:16:07 2016 -0500
Committer: Clebert Suconic <cl...@apache.org>
Committed: Wed Nov 23 10:16:07 2016 -0500
----------------------------------------------------------------------
.../protocol/openwire/OpenWireConnection.java | 22 ++++++++-
.../protocol/openwire/util/OpenWireUtil.java | 6 ++-
.../artemis/core/server/TempQueueObserver.java | 24 ++++++++++
.../core/server/impl/ServerSessionImpl.java | 13 ++++++
.../openwire/SimpleOpenWireTest.java | 48 ++++++++++++++++++++
5 files changed, 111 insertions(+), 2 deletions(-)
----------------------------------------------------------------------