You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ma...@apache.org on 2016/11/07 16:06:16 UTC
activemq-artemis git commit: Fix AutoCreateTopics
Repository: activemq-artemis
Updated Branches:
refs/heads/ARTEMIS-780 3858b1cfc -> 5459cf76f
Fix AutoCreateTopics
Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/5459cf76
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/5459cf76
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/5459cf76
Branch: refs/heads/ARTEMIS-780
Commit: 5459cf76fdcfaf76977017d932b92f622b8f3b3d
Parents: 3858b1c
Author: Martyn Taylor <mt...@redhat.com>
Authored: Mon Nov 7 16:00:58 2016 +0000
Committer: Martyn Taylor <mt...@redhat.com>
Committed: Mon Nov 7 16:05:35 2016 +0000
----------------------------------------------------------------------
.../apache/activemq/cli/test/ArtemisTest.java | 2 +-
.../artemis/jms/client/ActiveMQSession.java | 32 ++++++++++++++------
.../artemis/core/server/ActiveMQServer.java | 2 ++
.../core/server/impl/ActiveMQServerImpl.java | 27 +++++++++++------
4 files changed, 43 insertions(+), 20 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/5459cf76/artemis-cli/src/test/java/org/apache/activemq/cli/test/ArtemisTest.java
----------------------------------------------------------------------
diff --git a/artemis-cli/src/test/java/org/apache/activemq/cli/test/ArtemisTest.java b/artemis-cli/src/test/java/org/apache/activemq/cli/test/ArtemisTest.java
index ac18d30..4838499 100644
--- a/artemis-cli/src/test/java/org/apache/activemq/cli/test/ArtemisTest.java
+++ b/artemis-cli/src/test/java/org/apache/activemq/cli/test/ArtemisTest.java
@@ -254,7 +254,7 @@ public class ArtemisTest {
Assert.assertTrue("Couldn't find queue " + str, queryResult.isExists());
}
for (String str : topics.split(",")) {
- ClientSession.QueueQuery queryResult = coreSession.queueQuery(SimpleString.toSimpleString(str));
+ ClientSession.AddressQuery queryResult = coreSession.addressQuery(SimpleString.toSimpleString(str));
Assert.assertTrue("Couldn't find topic " + str, queryResult.isExists());
}
}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/5459cf76/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQSession.java
----------------------------------------------------------------------
diff --git a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQSession.java b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQSession.java
index d40ca21..d554cf8 100644
--- a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQSession.java
+++ b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQSession.java
@@ -299,19 +299,31 @@ public class ActiveMQSession implements QueueSession, TopicSession {
if (jbd != null) {
ClientSession.AddressQuery response = session.addressQuery(jbd.getSimpleAddress());
- if (!response.isExists() && response.isAutoCreateJmsQueues()) {
- if (jbd.isQueue()) {
- session.createAddress(jbd.getSimpleAddress(), false);
- session.createQueue(jbd.getSimpleAddress(), jbd.getSimpleAddress(), null, true);
- } else {
- session.createAddress(jbd.getSimpleAddress(), true);
+ if (jbd.isQueue()) {
+ if (!response.isExists()) {
+ if (response.isAutoCreateJmsQueues()) {
+ session.createAddress(jbd.getSimpleAddress(), false);
+ } else {
+ throw new InvalidDestinationException("Destination " + jbd.getName() + " does not exist");
+ }
}
- } else if (!response.isExists() && !response.isAutoCreateJmsQueues()) {
- throw new InvalidDestinationException("Destination " + jbd.getName() + " does not exist");
+ if (response.getQueueNames().isEmpty()) {
+ if (response.isAutoCreateJmsQueues()) {
+ session.createQueue(jbd.getSimpleAddress(), jbd.getSimpleAddress(), null, true);
+ } else {
+ throw new InvalidDestinationException("Destination " + jbd.getName() + " does not exist");
+ }
+ }
+ } else {
+ if (!response.isExists()) {
+ if (response.isAutoCreateJmsTopics()) {
+ session.createAddress(jbd.getSimpleAddress(), true);
+ } else {
+ throw new InvalidDestinationException("Destination " + jbd.getName() + " does not exist");
+ }
+ }
}
-
- connection.addKnownDestination(jbd.getSimpleAddress());
}
ClientProducer producer = session.createProducer(jbd == null ? null : jbd.getSimpleAddress());
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/5459cf76/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQServer.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQServer.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQServer.java
index bb819ae..09f679b 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQServer.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQServer.java
@@ -465,6 +465,8 @@ public interface ActiveMQServer extends ActiveMQComponent {
void removeClientConnection(String clientId);
+ AddressInfo putAddressInfoIfAbsent(AddressInfo addressInfo) throws Exception;
+
AddressInfo createOrUpdateAddressInfo(AddressInfo addressInfo) throws Exception;
AddressInfo removeAddressInfo(SimpleString address) throws Exception;
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/5459cf76/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java
index 58d8ff2..df00cc1 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java
@@ -653,7 +653,11 @@ public class ActiveMQServerImpl implements ActiveMQServer {
}
}
- return new BindingQueryResult(!names.isEmpty(), names, autoCreateJmsQueues, autoCreateJmsTopics);
+ if (autoCreateJmsTopics) {
+ putAddressInfoIfAbsent(new AddressInfo(address));
+ }
+
+ return new BindingQueryResult(getAddressInfo(address) != null, names, autoCreateJmsQueues, autoCreateJmsTopics);
}
@Override
@@ -2153,14 +2157,7 @@ public class ActiveMQServerImpl implements ActiveMQServer {
private void deployQueuesFromListCoreQueueConfiguration(List<CoreQueueConfiguration> queues) throws Exception {
for (CoreQueueConfiguration config : queues) {
- deployQueue(SimpleString.toSimpleString(config.getAddress()),
- SimpleString.toSimpleString(config.getName()),
- SimpleString.toSimpleString(config.getFilterString()),
- config.isDurable(),
- false,
- false,
- config.getMaxConsumers(),
- config.getDeleteOnNoConsumers());
+ deployQueue(SimpleString.toSimpleString(config.getAddress()), SimpleString.toSimpleString(config.getName()), SimpleString.toSimpleString(config.getFilterString()), config.isDurable(), false, false, config.getMaxConsumers(), config.getDeleteOnNoConsumers());
}
}
@@ -2264,6 +2261,18 @@ public class ActiveMQServerImpl implements ActiveMQServer {
}
@Override
+ public AddressInfo putAddressInfoIfAbsent(AddressInfo addressInfo) throws Exception {
+ AddressInfo result = postOffice.addAddressInfo(addressInfo);
+
+ // TODO: is this the right way to do this?
+ long txID = storageManager.generateID();
+ storageManager.addAddressBinding(txID, addressInfo);
+ storageManager.commitBindings(txID);
+
+ return result;
+ }
+
+ @Override
public AddressInfo createOrUpdateAddressInfo(AddressInfo addressInfo) throws Exception {
AddressInfo result = postOffice.addOrUpdateAddressInfo(addressInfo);