You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by jb...@apache.org on 2016/11/23 17:43:44 UTC
[43/48] activemq-artemis git commit: User ServerSession to create
Stomp queues/addresses
User ServerSession to create Stomp queues/addresses
Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/40a55590
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/40a55590
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/40a55590
Branch: refs/heads/ARTEMIS-780
Commit: 40a555900a331272c2d7ef290a34b54a0ff370ef
Parents: d1b62a5
Author: jbertram <jb...@apache.com>
Authored: Tue Nov 22 10:31:30 2016 -0600
Committer: jbertram <jb...@apache.com>
Committed: Wed Nov 23 09:04:37 2016 -0600
----------------------------------------------------------------------
.../core/protocol/stomp/StompConnection.java | 25 +++++++++++++-------
.../core/ServerSessionPacketHandler.java | 2 +-
.../artemis/core/server/ServerSession.java | 2 +-
.../core/server/impl/ServerSessionImpl.java | 4 ++--
4 files changed, 21 insertions(+), 12 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/40a55590/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompConnection.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompConnection.java b/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompConnection.java
index 52d3f3b..3a734eb 100644
--- a/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompConnection.java
+++ b/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompConnection.java
@@ -39,8 +39,10 @@ import org.apache.activemq.artemis.core.remoting.FailureListener;
import org.apache.activemq.artemis.core.remoting.impl.netty.TransportConstants;
import org.apache.activemq.artemis.core.server.ActiveMQServerLogger;
import org.apache.activemq.artemis.core.server.ServerMessage;
+import org.apache.activemq.artemis.core.server.ServerSession;
import org.apache.activemq.artemis.core.server.impl.AddressInfo;
import org.apache.activemq.artemis.core.server.impl.ServerMessageImpl;
+import org.apache.activemq.artemis.core.settings.impl.AddressSettings;
import org.apache.activemq.artemis.spi.core.protocol.RemotingConnection;
import org.apache.activemq.artemis.spi.core.remoting.Acceptor;
import org.apache.activemq.artemis.spi.core.remoting.Connection;
@@ -259,21 +261,24 @@ public final class StompConnection implements RemotingConnection {
public boolean autoCreateDestinationIfPossible(String queue, AddressInfo.RoutingType routingType) throws ActiveMQStompException {
boolean result = false;
+ ServerSession session = getSession().getSession();
try {
if (manager.getServer().getAddressInfo(SimpleString.toSimpleString(queue)) == null) {
- // TODO check here to see if auto-creation is enabled
- if (routingType != null && routingType.equals(AddressInfo.RoutingType.MULTICAST) && manager.getServer().getAddressSettingsRepository().getMatch(queue).isAutoCreateAddresses()) {
- manager.getServer().createOrUpdateAddressInfo(new AddressInfo(SimpleString.toSimpleString(queue)).setAutoCreated(true));
+ AddressSettings addressSettings = manager.getServer().getAddressSettingsRepository().getMatch(queue);
+ if (routingType != null && routingType.equals(AddressInfo.RoutingType.MULTICAST) && addressSettings.isAutoCreateAddresses()) {
+ session.createAddress(SimpleString.toSimpleString(queue), true, true);
+ result = true;
} else {
- if (manager.getServer().getAddressSettingsRepository().getMatch(queue).isAutoCreateAddresses()) {
- manager.getServer().createOrUpdateAddressInfo(new AddressInfo(SimpleString.toSimpleString(queue)).setRoutingType(AddressInfo.RoutingType.ANYCAST).setAutoCreated(true));
+ if (addressSettings.isAutoCreateAddresses()) {
+ session.createAddress(SimpleString.toSimpleString(queue), false, true);
+ result = true;
}
- if (manager.getServer().getAddressSettingsRepository().getMatch(queue).isAutoCreateQueues()) {
- manager.getServer().createQueue(SimpleString.toSimpleString(queue), SimpleString.toSimpleString(queue), null, null, true, false, true);
+ if (addressSettings.isAutoCreateQueues()) {
+ session.createQueue(SimpleString.toSimpleString(queue), SimpleString.toSimpleString(queue), null, false, true, null, null, true);
+ result = true;
}
}
- result = true;
}
} catch (ActiveMQQueueExistsException e) {
// ignore
@@ -559,6 +564,10 @@ public final class StompConnection implements RemotingConnection {
return manager.createServerMessage();
}
+ public StompSession getSession() throws ActiveMQStompException {
+ return getSession(null);
+ }
+
public StompSession getSession(String txID) throws ActiveMQStompException {
StompSession session = null;
try {
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/40a55590/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/ServerSessionPacketHandler.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/ServerSessionPacketHandler.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/ServerSessionPacketHandler.java
index ac8d68a..184462b 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/ServerSessionPacketHandler.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/ServerSessionPacketHandler.java
@@ -227,7 +227,7 @@ public class ServerSessionPacketHandler implements ChannelHandler {
case CREATE_ADDRESS: {
CreateAddressMessage request = (CreateAddressMessage) packet;
requiresResponse = request.isRequiresResponse();
- session.createAddress(request.getAddress(), request.isMulticast());
+ session.createAddress(request.getAddress(), request.isMulticast(), request.isAutoCreated());
if (requiresResponse) {
response = new NullResponseMessage();
}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/40a55590/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ServerSession.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ServerSession.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ServerSession.java
index 28d283d..23426ca 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ServerSession.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ServerSession.java
@@ -108,7 +108,7 @@ public interface ServerSession extends SecurityAuth {
boolean temporary,
boolean durable) throws Exception;
- AddressInfo createAddress(final SimpleString address, final boolean multicast) throws Exception;
+ AddressInfo createAddress(final SimpleString address, final boolean multicast, final boolean autoCreated) throws Exception;
void deleteQueue(SimpleString name) throws Exception;
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/40a55590/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 e4e9135..e6de6cd 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
@@ -537,11 +537,11 @@ public class ServerSessionImpl implements ServerSession, FailureListener {
}
@Override
- public AddressInfo createAddress(final SimpleString address, final boolean multicast) throws Exception {
+ public AddressInfo createAddress(final SimpleString address, final boolean multicast, final boolean autoCreated) throws Exception {
securityCheck(address, CheckType.CREATE_ADDRESS, this);
AddressInfo.RoutingType routingType = multicast ? AddressInfo.RoutingType.MULTICAST : AddressInfo.RoutingType.ANYCAST;
- AddressInfo addressInfo = server.createOrUpdateAddressInfo(new AddressInfo(address).setRoutingType(routingType));
+ AddressInfo addressInfo = server.createOrUpdateAddressInfo(new AddressInfo(address).setRoutingType(routingType).setAutoCreated(autoCreated));
return addressInfo;
}