ARTEMIS-782 Added configuration elements for new address model
This commit is contained in:
parent
ebbc91c728
commit
abdeb72eb7
|
@ -438,6 +438,10 @@ public final class ActiveMQDefaultConfiguration {
|
|||
|
||||
public static final int DEFAULT_DISK_SCAN = 5000;
|
||||
|
||||
public static final int DEFAULT_MAX_QUEUE_CONSUMERS = -1;
|
||||
|
||||
public static final boolean DEFAULT_DELETE_QUEUE_ON_NO_CONSUMERS = false;
|
||||
|
||||
public static final String DEFAULT_SYSTEM_PROPERTY_PREFIX = "brokerconfig.";
|
||||
|
||||
public static String DEFAULT_NETWORK_CHECK_LIST = null;
|
||||
|
@ -1188,6 +1192,14 @@ public final class ActiveMQDefaultConfiguration {
|
|||
return DEFAULT_DISK_SCAN;
|
||||
}
|
||||
|
||||
public static int getDefaultMaxQueueConsumers() {
|
||||
return DEFAULT_MAX_QUEUE_CONSUMERS;
|
||||
}
|
||||
|
||||
public static boolean getDefaultDeleteQueueOnNoConsumers() {
|
||||
return DEFAULT_DELETE_QUEUE_ON_NO_CONSUMERS;
|
||||
}
|
||||
|
||||
public static String getDefaultSystemPropertyPrefix() {
|
||||
return DEFAULT_SYSTEM_PROPERTY_PREFIX;
|
||||
}
|
||||
|
|
|
@ -428,6 +428,21 @@ public interface Configuration {
|
|||
|
||||
Configuration addQueueConfiguration(final CoreQueueConfiguration config);
|
||||
|
||||
/**
|
||||
* Returns the addresses configured for this server.
|
||||
*/
|
||||
List<CoreAddressConfiguration> getAddressConfigurations();
|
||||
|
||||
/**
|
||||
* Sets the addresses configured for this server.
|
||||
*/
|
||||
Configuration setAddressConfigurations(final List<CoreAddressConfiguration> configs);
|
||||
|
||||
/**
|
||||
* Adds an addresses configuration
|
||||
*/
|
||||
Configuration addAddressConfiguration(final CoreAddressConfiguration config);
|
||||
|
||||
/**
|
||||
* Returns the management address of this server. <br>
|
||||
* Clients can send management messages to this address to manage this server. <br>
|
||||
|
|
|
@ -0,0 +1,141 @@
|
|||
/*
|
||||
* 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.config;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration;
|
||||
import org.apache.activemq.artemis.core.server.impl.AddressInfo.RoutingType;
|
||||
|
||||
public class CoreAddressConfiguration implements Serializable {
|
||||
|
||||
private String name = null;
|
||||
|
||||
private RoutingType routingType = null;
|
||||
|
||||
private Integer defaultMaxConsumers = ActiveMQDefaultConfiguration.getDefaultMaxQueueConsumers();
|
||||
|
||||
private Boolean defaultDeleteOnNoConsumers = ActiveMQDefaultConfiguration.getDefaultDeleteQueueOnNoConsumers();
|
||||
|
||||
private List<CoreQueueConfiguration> queueConfigurations = new ArrayList<>();
|
||||
|
||||
public CoreAddressConfiguration() {
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public CoreAddressConfiguration setName(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
public RoutingType getRoutingType() {
|
||||
return routingType;
|
||||
}
|
||||
|
||||
public CoreAddressConfiguration setRoutingType(RoutingType routingType) {
|
||||
this.routingType = routingType;
|
||||
return this;
|
||||
}
|
||||
|
||||
public CoreAddressConfiguration setQueueConfigurations(List<CoreQueueConfiguration> queueConfigurations) {
|
||||
this.queueConfigurations = queueConfigurations;
|
||||
return this;
|
||||
}
|
||||
|
||||
public CoreAddressConfiguration addQueueConfiguration(CoreQueueConfiguration queueConfiguration) {
|
||||
this.queueConfigurations.add(queueConfiguration);
|
||||
return this;
|
||||
}
|
||||
|
||||
public List<CoreQueueConfiguration> getQueueConfigurations() {
|
||||
return queueConfigurations;
|
||||
}
|
||||
|
||||
public Boolean getDefaultDeleteOnNoConsumers() {
|
||||
return defaultDeleteOnNoConsumers;
|
||||
}
|
||||
|
||||
public CoreAddressConfiguration setDefaultDeleteOnNoConsumers(Boolean defaultDeleteOnNoConsumers) {
|
||||
this.defaultDeleteOnNoConsumers = defaultDeleteOnNoConsumers;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getDefaultMaxConsumers() {
|
||||
return defaultMaxConsumers;
|
||||
}
|
||||
|
||||
public CoreAddressConfiguration setDefaultMaxConsumers(Integer defaultMaxConsumers) {
|
||||
this.defaultMaxConsumers = defaultMaxConsumers;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((name == null) ? 0 : name.hashCode());
|
||||
result = prime * result + ((routingType == null) ? 0 : routingType.hashCode());
|
||||
result = prime * result + ((queueConfigurations == null) ? 0 : queueConfigurations.hashCode());
|
||||
result = prime * result + ((defaultMaxConsumers == null) ? 0 : defaultMaxConsumers.hashCode());
|
||||
result = prime * result + ((defaultDeleteOnNoConsumers == null) ? 0 : defaultDeleteOnNoConsumers.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
CoreAddressConfiguration other = (CoreAddressConfiguration) obj;
|
||||
if (name == null) {
|
||||
if (other.name != null)
|
||||
return false;
|
||||
} else if (!name.equals(other.name))
|
||||
return false;
|
||||
if (routingType == null) {
|
||||
if (other.routingType != null)
|
||||
return false;
|
||||
} else if (!routingType.equals(other.routingType))
|
||||
return false;
|
||||
if (queueConfigurations == null) {
|
||||
if (other.queueConfigurations != null)
|
||||
return false;
|
||||
} else if (!queueConfigurations.equals(other.queueConfigurations))
|
||||
return false;
|
||||
if (defaultMaxConsumers == null) {
|
||||
if (other.defaultMaxConsumers != null)
|
||||
return false;
|
||||
} else if (!defaultMaxConsumers.equals(other.defaultMaxConsumers))
|
||||
return false;
|
||||
if (defaultDeleteOnNoConsumers == null) {
|
||||
if (other.defaultDeleteOnNoConsumers != null)
|
||||
return false;
|
||||
} else if (!defaultDeleteOnNoConsumers.equals(other.defaultDeleteOnNoConsumers)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -30,6 +30,10 @@ public class CoreQueueConfiguration implements Serializable {
|
|||
|
||||
private boolean durable = true;
|
||||
|
||||
private Integer maxConsumers = null;
|
||||
|
||||
private Boolean deleteOnNoConsumers = null;
|
||||
|
||||
public CoreQueueConfiguration() {
|
||||
}
|
||||
|
||||
|
@ -49,6 +53,8 @@ public class CoreQueueConfiguration implements Serializable {
|
|||
return durable;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @param address the address to set
|
||||
*/
|
||||
|
@ -81,6 +87,30 @@ public class CoreQueueConfiguration implements Serializable {
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param maxConsumers for this queue, default is -1 (unlimited)
|
||||
*/
|
||||
public CoreQueueConfiguration setMaxConsumers(Integer maxConsumers) {
|
||||
this.maxConsumers = maxConsumers;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param deleteOnNoConsumers delete this queue when consumer count reaches 0, default is false
|
||||
*/
|
||||
public CoreQueueConfiguration setDeleteOnNoConsumers(Boolean deleteOnNoConsumers) {
|
||||
this.deleteOnNoConsumers = deleteOnNoConsumers;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Boolean getDeleteOnNoConsumers() {
|
||||
return deleteOnNoConsumers;
|
||||
}
|
||||
|
||||
public Integer getMaxConsumers() {
|
||||
return maxConsumers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
|
@ -89,6 +119,8 @@ public class CoreQueueConfiguration implements Serializable {
|
|||
result = prime * result + (durable ? 1231 : 1237);
|
||||
result = prime * result + ((filterString == null) ? 0 : filterString.hashCode());
|
||||
result = prime * result + ((name == null) ? 0 : name.hashCode());
|
||||
result = prime * result + ((maxConsumers == null) ? 0 : maxConsumers.hashCode());
|
||||
result = prime * result + ((deleteOnNoConsumers == null) ? 0 : deleteOnNoConsumers.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -118,6 +150,17 @@ public class CoreQueueConfiguration implements Serializable {
|
|||
return false;
|
||||
} else if (!name.equals(other.name))
|
||||
return false;
|
||||
if (maxConsumers == null) {
|
||||
if (other.maxConsumers != null)
|
||||
return false;
|
||||
} else if (!maxConsumers.equals(other.maxConsumers))
|
||||
return false;
|
||||
if (deleteOnNoConsumers == null) {
|
||||
if (other.deleteOnNoConsumers != null)
|
||||
return false;
|
||||
} else if (!deleteOnNoConsumers.equals(other.deleteOnNoConsumers)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,6 +48,7 @@ import org.apache.activemq.artemis.core.config.BridgeConfiguration;
|
|||
import org.apache.activemq.artemis.core.config.ClusterConnectionConfiguration;
|
||||
import org.apache.activemq.artemis.core.config.Configuration;
|
||||
import org.apache.activemq.artemis.core.config.ConnectorServiceConfiguration;
|
||||
import org.apache.activemq.artemis.core.config.CoreAddressConfiguration;
|
||||
import org.apache.activemq.artemis.core.config.CoreQueueConfiguration;
|
||||
import org.apache.activemq.artemis.core.config.DivertConfiguration;
|
||||
import org.apache.activemq.artemis.core.config.HAPolicyConfiguration;
|
||||
|
@ -135,6 +136,8 @@ public class ConfigurationImpl implements Configuration, Serializable {
|
|||
|
||||
private List<CoreQueueConfiguration> queueConfigurations = new ArrayList<>();
|
||||
|
||||
private List<CoreAddressConfiguration> addressConfigurations = new ArrayList<>();
|
||||
|
||||
protected transient List<BroadcastGroupConfiguration> broadcastGroupConfigurations = new ArrayList<>();
|
||||
|
||||
protected transient Map<String, DiscoveryGroupConfiguration> discoveryGroupConfigurations = new LinkedHashMap<>();
|
||||
|
@ -653,6 +656,23 @@ public class ConfigurationImpl implements Configuration, Serializable {
|
|||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CoreAddressConfiguration> getAddressConfigurations() {
|
||||
return addressConfigurations;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Configuration setAddressConfigurations(List<CoreAddressConfiguration> configs) {
|
||||
this.addressConfigurations = configs;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Configuration addAddressConfiguration(CoreAddressConfiguration config) {
|
||||
this.addressConfigurations.add(config);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, DiscoveryGroupConfiguration> getDiscoveryGroupConfigurations() {
|
||||
return discoveryGroupConfigurations;
|
||||
|
|
|
@ -43,6 +43,7 @@ import org.apache.activemq.artemis.core.config.BridgeConfiguration;
|
|||
import org.apache.activemq.artemis.core.config.ClusterConnectionConfiguration;
|
||||
import org.apache.activemq.artemis.core.config.Configuration;
|
||||
import org.apache.activemq.artemis.core.config.ConnectorServiceConfiguration;
|
||||
import org.apache.activemq.artemis.core.config.CoreAddressConfiguration;
|
||||
import org.apache.activemq.artemis.core.config.CoreQueueConfiguration;
|
||||
import org.apache.activemq.artemis.core.config.DivertConfiguration;
|
||||
import org.apache.activemq.artemis.core.config.ScaleDownConfiguration;
|
||||
|
@ -63,6 +64,7 @@ import org.apache.activemq.artemis.core.server.JournalType;
|
|||
import org.apache.activemq.artemis.core.server.SecuritySettingPlugin;
|
||||
import org.apache.activemq.artemis.core.server.cluster.impl.MessageLoadBalancingType;
|
||||
import org.apache.activemq.artemis.core.server.group.impl.GroupingHandlerConfiguration;
|
||||
import org.apache.activemq.artemis.core.server.impl.AddressInfo;
|
||||
import org.apache.activemq.artemis.core.settings.impl.AddressFullMessagePolicy;
|
||||
import org.apache.activemq.artemis.core.settings.impl.AddressSettings;
|
||||
import org.apache.activemq.artemis.core.settings.impl.ResourceLimitSettings;
|
||||
|
@ -560,6 +562,8 @@ public final class FileConfigurationParser extends XMLConfigurationUtil {
|
|||
|
||||
parseQueues(e, config);
|
||||
|
||||
parseAddresses(e, config);
|
||||
|
||||
parseSecurity(e, config);
|
||||
|
||||
NodeList connectorServiceConfigs = e.getElementsByTagName("connector-service");
|
||||
|
@ -603,13 +607,35 @@ public final class FileConfigurationParser extends XMLConfigurationUtil {
|
|||
*/
|
||||
private void parseQueues(final Element e, final Configuration config) {
|
||||
NodeList elements = e.getElementsByTagName("queues");
|
||||
if (elements.getLength() != 0) {
|
||||
Element node = (Element) elements.item(0);
|
||||
config.setQueueConfigurations(parseQueueConfigurations(node));
|
||||
}
|
||||
}
|
||||
|
||||
private List<CoreQueueConfiguration> parseQueueConfigurations(final Element node) {
|
||||
List<CoreQueueConfiguration> queueConfigurations = new ArrayList<>();
|
||||
NodeList list = node.getElementsByTagName("queue");
|
||||
for (int i = 0; i < list.getLength(); i++) {
|
||||
CoreQueueConfiguration queueConfig = parseQueueConfiguration(list.item(i));
|
||||
queueConfigurations.add(queueConfig);
|
||||
}
|
||||
return queueConfigurations;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param e
|
||||
* @param config
|
||||
*/
|
||||
private void parseAddresses(final Element e, final Configuration config) {
|
||||
NodeList elements = e.getElementsByTagName("addresses");
|
||||
|
||||
if (elements.getLength() != 0) {
|
||||
Element node = (Element) elements.item(0);
|
||||
NodeList list = node.getElementsByTagName("queue");
|
||||
NodeList list = node.getElementsByTagName("address");
|
||||
for (int i = 0; i < list.getLength(); i++) {
|
||||
CoreQueueConfiguration queueConfig = parseQueueConfiguration(list.item(i));
|
||||
config.getQueueConfigurations().add(queueConfig);
|
||||
CoreAddressConfiguration addrConfig = parseAddressConfiguration(list.item(i));
|
||||
config.getAddressConfigurations().add(addrConfig);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -847,9 +873,20 @@ public final class FileConfigurationParser extends XMLConfigurationUtil {
|
|||
String address = null;
|
||||
String filterString = null;
|
||||
boolean durable = true;
|
||||
Integer maxConsumers = null;
|
||||
Boolean deleteOnNoConsumers = null;
|
||||
|
||||
NamedNodeMap attributes = node.getAttributes();
|
||||
for (int i = 0; i < attributes.getLength(); i++) {
|
||||
Node item = attributes.item(i);
|
||||
if (item.getNodeName().equals("max-consumers")) {
|
||||
maxConsumers = Integer.parseInt(item.getNodeValue());
|
||||
} else if (item.getNodeName().equals("delete-on-no-consumers")) {
|
||||
deleteOnNoConsumers = Boolean.parseBoolean(item.getNodeValue());
|
||||
}
|
||||
}
|
||||
|
||||
NodeList children = node.getChildNodes();
|
||||
|
||||
for (int j = 0; j < children.getLength(); j++) {
|
||||
Node child = children.item(j);
|
||||
|
||||
|
@ -862,7 +899,41 @@ public final class FileConfigurationParser extends XMLConfigurationUtil {
|
|||
}
|
||||
}
|
||||
|
||||
return new CoreQueueConfiguration().setAddress(address).setName(name).setFilterString(filterString).setDurable(durable);
|
||||
return new CoreQueueConfiguration()
|
||||
.setAddress(address)
|
||||
.setName(name)
|
||||
.setFilterString(filterString)
|
||||
.setDurable(durable)
|
||||
.setMaxConsumers(maxConsumers)
|
||||
.setDeleteOnNoConsumers(deleteOnNoConsumers);
|
||||
}
|
||||
|
||||
protected CoreAddressConfiguration parseAddressConfiguration(final Node node) {
|
||||
String name = getAttributeValue(node, "name");
|
||||
String routingType = getAttributeValue(node, "type");
|
||||
|
||||
CoreAddressConfiguration addressConfiguration = new CoreAddressConfiguration();
|
||||
addressConfiguration.setName(name)
|
||||
.setRoutingType(AddressInfo.RoutingType.valueOf(routingType.toUpperCase()));
|
||||
|
||||
NodeList children = node.getChildNodes();
|
||||
for (int j = 0; j < children.getLength(); j++) {
|
||||
Node child = children.item(j);
|
||||
if (child.getNodeName().equals("queues")) {
|
||||
addressConfiguration.setQueueConfigurations(parseQueueConfigurations((Element) child));
|
||||
}
|
||||
}
|
||||
|
||||
for (CoreQueueConfiguration coreQueueConfiguration : addressConfiguration.getQueueConfigurations()) {
|
||||
coreQueueConfiguration.setAddress(addressConfiguration.getName());
|
||||
if (coreQueueConfiguration.getMaxConsumers() == null) {
|
||||
coreQueueConfiguration.setMaxConsumers(addressConfiguration.getDefaultMaxConsumers());
|
||||
}
|
||||
if (coreQueueConfiguration.getDeleteOnNoConsumers() == null) {
|
||||
coreQueueConfiguration.setDeleteOnNoConsumers(addressConfiguration.getDefaultDeleteOnNoConsumers());
|
||||
}
|
||||
}
|
||||
return addressConfiguration;
|
||||
}
|
||||
|
||||
private TransportConfiguration parseAcceptorTransportConfiguration(final Element e,
|
||||
|
|
|
@ -20,6 +20,7 @@ import java.util.Map;
|
|||
import java.util.Set;
|
||||
|
||||
import org.apache.activemq.artemis.api.core.SimpleString;
|
||||
import org.apache.activemq.artemis.core.server.impl.AddressInfo;
|
||||
import org.apache.activemq.artemis.core.transaction.Transaction;
|
||||
|
||||
/**
|
||||
|
@ -50,4 +51,10 @@ public interface AddressManager {
|
|||
Map<SimpleString, Binding> getBindings();
|
||||
|
||||
Set<SimpleString> getAddresses();
|
||||
|
||||
AddressInfo addAddressInfo(AddressInfo addressInfo);
|
||||
|
||||
AddressInfo removeAddressInfo(SimpleString address);
|
||||
|
||||
AddressInfo getAddressInfo(SimpleString address);
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ import org.apache.activemq.artemis.core.server.Queue;
|
|||
import org.apache.activemq.artemis.core.server.QueueCreator;
|
||||
import org.apache.activemq.artemis.core.server.RoutingContext;
|
||||
import org.apache.activemq.artemis.core.server.ServerMessage;
|
||||
import org.apache.activemq.artemis.core.server.impl.AddressInfo;
|
||||
import org.apache.activemq.artemis.core.transaction.Transaction;
|
||||
|
||||
/**
|
||||
|
@ -42,6 +43,12 @@ import org.apache.activemq.artemis.core.transaction.Transaction;
|
|||
*/
|
||||
public interface PostOffice extends ActiveMQComponent {
|
||||
|
||||
AddressInfo addAddressInfo(AddressInfo addressInfo);
|
||||
|
||||
AddressInfo removeAddressInfo(SimpleString address);
|
||||
|
||||
AddressInfo getAddressInfo(SimpleString address);
|
||||
|
||||
void addBinding(Binding binding) throws Exception;
|
||||
|
||||
Binding removeBinding(SimpleString uniqueName, Transaction tx, boolean deleteData) throws Exception;
|
||||
|
@ -113,4 +120,5 @@ public interface PostOffice extends ActiveMQComponent {
|
|||
|
||||
Set<SimpleString> getAddresses();
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -69,6 +69,7 @@ import org.apache.activemq.artemis.core.server.RouteContextList;
|
|||
import org.apache.activemq.artemis.core.server.RoutingContext;
|
||||
import org.apache.activemq.artemis.core.server.ServerMessage;
|
||||
import org.apache.activemq.artemis.core.server.group.GroupingHandler;
|
||||
import org.apache.activemq.artemis.core.server.impl.AddressInfo;
|
||||
import org.apache.activemq.artemis.core.server.impl.RoutingContextImpl;
|
||||
import org.apache.activemq.artemis.core.server.impl.ServerMessageImpl;
|
||||
import org.apache.activemq.artemis.core.server.management.ManagementService;
|
||||
|
@ -418,6 +419,21 @@ public class PostOfficeImpl implements PostOffice, NotificationListener, Binding
|
|||
|
||||
// PostOffice implementation -----------------------------------------------
|
||||
|
||||
@Override
|
||||
public AddressInfo addAddressInfo(AddressInfo addressInfo) {
|
||||
return addressManager.addAddressInfo(addressInfo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AddressInfo removeAddressInfo(SimpleString address) {
|
||||
return addressManager.removeAddressInfo(address);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AddressInfo getAddressInfo(SimpleString addressName) {
|
||||
return addressManager.getAddressInfo(addressName);
|
||||
}
|
||||
|
||||
// TODO - needs to be synchronized to prevent happening concurrently with activate()
|
||||
// (and possible removeBinding and other methods)
|
||||
// Otherwise can have situation where createQueue comes in before failover, then failover occurs
|
||||
|
|
|
@ -30,6 +30,7 @@ import org.apache.activemq.artemis.core.postoffice.Binding;
|
|||
import org.apache.activemq.artemis.core.postoffice.Bindings;
|
||||
import org.apache.activemq.artemis.core.postoffice.BindingsFactory;
|
||||
import org.apache.activemq.artemis.core.server.ActiveMQMessageBundle;
|
||||
import org.apache.activemq.artemis.core.server.impl.AddressInfo;
|
||||
import org.apache.activemq.artemis.core.transaction.Transaction;
|
||||
import org.jboss.logging.Logger;
|
||||
|
||||
|
@ -40,6 +41,8 @@ public class SimpleAddressManager implements AddressManager {
|
|||
|
||||
private static final Logger logger = Logger.getLogger(Page.class);
|
||||
|
||||
private final ConcurrentMap<SimpleString, AddressInfo> addressInfoMap = new ConcurrentHashMap<>();
|
||||
|
||||
/**
|
||||
* HashMap<Address, Binding>
|
||||
*/
|
||||
|
@ -178,4 +181,19 @@ public class SimpleAddressManager implements AddressManager {
|
|||
|
||||
return prevBindings != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AddressInfo addAddressInfo(AddressInfo addressInfo) {
|
||||
return addressInfoMap.putIfAbsent(addressInfo.getName(), addressInfo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AddressInfo removeAddressInfo(SimpleString address) {
|
||||
return addressInfoMap.remove(address);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AddressInfo getAddressInfo(SimpleString addressName) {
|
||||
return addressInfoMap.get(addressName);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,6 +41,7 @@ import org.apache.activemq.artemis.core.server.cluster.ClusterManager;
|
|||
import org.apache.activemq.artemis.core.server.cluster.ha.HAPolicy;
|
||||
import org.apache.activemq.artemis.core.server.group.GroupingHandler;
|
||||
import org.apache.activemq.artemis.core.server.impl.Activation;
|
||||
import org.apache.activemq.artemis.core.server.impl.AddressInfo;
|
||||
import org.apache.activemq.artemis.core.server.impl.ConnectorsService;
|
||||
import org.apache.activemq.artemis.core.server.management.ManagementService;
|
||||
import org.apache.activemq.artemis.core.server.reload.ReloadManager;
|
||||
|
@ -389,10 +390,12 @@ public interface ActiveMQServer extends ActiveMQComponent {
|
|||
|
||||
void stop(boolean failoverOnServerShutdown) throws Exception;
|
||||
|
||||
AddressInfo getAddressInfo(SimpleString address);
|
||||
|
||||
/*
|
||||
* add a ProtocolManagerFactory to be used. Note if @see Configuration#isResolveProtocols is tur then this factory will
|
||||
* replace any factories with the same protocol
|
||||
* */
|
||||
* add a ProtocolManagerFactory to be used. Note if @see Configuration#isResolveProtocols is tur then this factory will
|
||||
* replace any factories with the same protocol
|
||||
* */
|
||||
void addProtocolManagerFactory(ProtocolManagerFactory factory);
|
||||
|
||||
/*
|
||||
|
@ -421,4 +424,8 @@ public interface ActiveMQServer extends ActiveMQComponent {
|
|||
boolean addClientConnection(String clientId, boolean unique);
|
||||
|
||||
void removeClientConnection(String clientId);
|
||||
|
||||
AddressInfo addAddressInfo(AddressInfo addressInfo);
|
||||
|
||||
AddressInfo removeAddressInfo(SimpleString address);
|
||||
}
|
||||
|
|
|
@ -55,6 +55,7 @@ import org.apache.activemq.artemis.core.client.impl.ClientSessionFactoryImpl;
|
|||
import org.apache.activemq.artemis.core.config.BridgeConfiguration;
|
||||
import org.apache.activemq.artemis.core.config.Configuration;
|
||||
import org.apache.activemq.artemis.core.config.ConfigurationUtils;
|
||||
import org.apache.activemq.artemis.core.config.CoreAddressConfiguration;
|
||||
import org.apache.activemq.artemis.core.config.CoreQueueConfiguration;
|
||||
import org.apache.activemq.artemis.core.config.DivertConfiguration;
|
||||
import org.apache.activemq.artemis.core.config.StoreConfiguration;
|
||||
|
@ -2074,6 +2075,9 @@ public class ActiveMQServerImpl implements ActiveMQServer {
|
|||
|
||||
// Deploy the rest of the stuff
|
||||
|
||||
// Deploy predefined addresses
|
||||
deployAddressesFromConfiguration();
|
||||
|
||||
// Deploy any predefined queues
|
||||
deployQueuesFromConfiguration();
|
||||
|
||||
|
@ -2152,11 +2156,26 @@ public class ActiveMQServerImpl implements ActiveMQServer {
|
|||
}
|
||||
}
|
||||
|
||||
private void deployQueuesFromConfiguration() throws Exception {
|
||||
for (CoreQueueConfiguration config : configuration.getQueueConfigurations()) {
|
||||
private void deployAddressesFromConfiguration() throws Exception {
|
||||
for (CoreAddressConfiguration config : configuration.getAddressConfigurations()) {
|
||||
AddressInfo info = new AddressInfo(SimpleString.toSimpleString(config.getName()));
|
||||
info.setRoutingType(config.getRoutingType());
|
||||
info.setDefaultDeleteOnNoConsumers(config.getDefaultDeleteOnNoConsumers());
|
||||
info.setDefaultMaxConsumers(config.getDefaultMaxConsumers());
|
||||
|
||||
addAddressInfo(info);
|
||||
deployQueuesFromListCoreQueueConfiguration(config.getQueueConfigurations());
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
private void deployQueuesFromConfiguration() throws Exception {
|
||||
deployQueuesFromListCoreQueueConfiguration(configuration.getQueueConfigurations());
|
||||
}
|
||||
|
||||
private void checkForPotentialOOMEInAddressConfiguration() {
|
||||
long totalMaxSizeBytes = 0;
|
||||
|
@ -2247,7 +2266,22 @@ public class ActiveMQServerImpl implements ActiveMQServer {
|
|||
}
|
||||
}
|
||||
|
||||
private Queue createQueue(final SimpleString address,
|
||||
@Override
|
||||
public AddressInfo addAddressInfo(AddressInfo addressInfo) {
|
||||
return postOffice.addAddressInfo(addressInfo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AddressInfo removeAddressInfo(SimpleString address) {
|
||||
return postOffice.removeAddressInfo(address);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AddressInfo getAddressInfo(SimpleString address) {
|
||||
return postOffice.removeAddressInfo(address);
|
||||
}
|
||||
|
||||
private Queue createQueue(final SimpleString addressName,
|
||||
final SimpleString queueName,
|
||||
final SimpleString filterString,
|
||||
final SimpleString user,
|
||||
|
@ -2256,6 +2290,7 @@ public class ActiveMQServerImpl implements ActiveMQServer {
|
|||
final boolean ignoreIfExists,
|
||||
final boolean transientQueue,
|
||||
final boolean autoCreated) throws Exception {
|
||||
|
||||
final QueueBinding binding = (QueueBinding) postOffice.getBinding(queueName);
|
||||
if (binding != null) {
|
||||
if (ignoreIfExists) {
|
||||
|
@ -2271,14 +2306,16 @@ public class ActiveMQServerImpl implements ActiveMQServer {
|
|||
final long queueID = storageManager.generateID();
|
||||
|
||||
final QueueConfig.Builder queueConfigBuilder;
|
||||
if (address == null) {
|
||||
if (addressName == null) {
|
||||
queueConfigBuilder = QueueConfig.builderWith(queueID, queueName);
|
||||
} else {
|
||||
queueConfigBuilder = QueueConfig.builderWith(queueID, queueName, address);
|
||||
|
||||
queueConfigBuilder = QueueConfig.builderWith(queueID, queueName, addressName);
|
||||
}
|
||||
final QueueConfig queueConfig = queueConfigBuilder.filter(filter).pagingManager(pagingManager).user(user).durable(durable).temporary(temporary).autoCreated(autoCreated).build();
|
||||
final Queue queue = queueFactory.createQueueWith(queueConfig);
|
||||
|
||||
addAddressInfo(new AddressInfo(queue.getAddress()));
|
||||
|
||||
if (transientQueue) {
|
||||
queue.setConsumersRefCount(new TransientQueueManagerImpl(this, queue.getName()));
|
||||
} else if (queue.isAutoCreated()) {
|
||||
|
|
|
@ -0,0 +1,67 @@
|
|||
/*
|
||||
* 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.impl;
|
||||
|
||||
import org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration;
|
||||
import org.apache.activemq.artemis.api.core.SimpleString;
|
||||
|
||||
public class AddressInfo {
|
||||
|
||||
public enum RoutingType {
|
||||
MULTICAST, ANYCAST
|
||||
}
|
||||
|
||||
private final SimpleString name;
|
||||
|
||||
private RoutingType routingType = RoutingType.MULTICAST;
|
||||
|
||||
private boolean defaultDeleteOnNoConsumers;
|
||||
|
||||
private int defaultMaxConsumers;
|
||||
|
||||
public AddressInfo(SimpleString name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public RoutingType getRoutingType() {
|
||||
return routingType;
|
||||
}
|
||||
|
||||
public void setRoutingType(RoutingType routingType) {
|
||||
this.routingType = routingType;
|
||||
}
|
||||
|
||||
public boolean isDefaultDeleteOnNoConsumers() {
|
||||
return defaultDeleteOnNoConsumers;
|
||||
}
|
||||
|
||||
public void setDefaultDeleteOnNoConsumers(boolean defaultDeleteOnNoConsumers) {
|
||||
this.defaultDeleteOnNoConsumers = defaultDeleteOnNoConsumers;
|
||||
}
|
||||
|
||||
public int getDefaultMaxConsumers() {
|
||||
return defaultMaxConsumers;
|
||||
}
|
||||
|
||||
public void setDefaultMaxConsumers(int defaultMaxConsumers) {
|
||||
this.defaultMaxConsumers = defaultMaxConsumers;
|
||||
}
|
||||
|
||||
public SimpleString getName() {
|
||||
return name;
|
||||
}
|
||||
}
|
|
@ -438,7 +438,6 @@
|
|||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
|
||||
|
||||
<!-- QUEUES -->
|
||||
<xsd:element name="queues" maxOccurs="1" minOccurs="0">
|
||||
<xsd:annotation>
|
||||
|
@ -931,6 +930,8 @@
|
|||
</xsd:element>
|
||||
|
||||
|
||||
|
||||
<xsd:element name="addresses" type="addressesType" maxOccurs="1" minOccurs="0" />
|
||||
</xsd:all>
|
||||
</xsd:complexType>
|
||||
|
||||
|
@ -2588,4 +2589,79 @@
|
|||
</xsd:extension>
|
||||
</xsd:simpleContent>
|
||||
</xsd:complexType>
|
||||
|
||||
|
||||
<!-- 2.0 Addressing configuration -->
|
||||
<xsd:simpleType name="routingType">
|
||||
<xsd:restriction base="xsd:string">
|
||||
<xsd:enumeration value="multicast" />
|
||||
<xsd:enumeration value="anycast" />
|
||||
</xsd:restriction>
|
||||
</xsd:simpleType>
|
||||
|
||||
<xsd:complexType name="queueType">
|
||||
<xsd:all>
|
||||
<xsd:element ref="filter" maxOccurs="1" minOccurs="0"/>
|
||||
<xsd:element name="durable" type="xsd:boolean" default="true" maxOccurs="1" minOccurs="0" />
|
||||
</xsd:all>
|
||||
<xsd:attribute name="name" type="xsd:ID" use="required"/>
|
||||
<xsd:attribute name="max-consumers" type="xsd:integer" use="optional"/>
|
||||
<xsd:attribute name="delete-on-no-consumers" type="xsd:boolean" use="optional"/>
|
||||
</xsd:complexType>
|
||||
|
||||
<xsd:complexType name="addressType">
|
||||
<xsd:all>
|
||||
<xsd:element name="queues" maxOccurs="1" minOccurs="0">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
a list of pre configured queues to create
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="queue" type="queueType" maxOccurs="unbounded" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:all>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
The address name to matches incoming message addresses
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="type" type="routingType" use="required">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
The address name to matches incoming message addresses
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="default-max-consumers" type="xsd:int" use="optional" default="-1">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
The default value of max-consumers applied to all queues that are
|
||||
auto-created under this address. Also applies to any queues that do not
|
||||
specify a value for max-consumers.
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="default-delete-on-no-consumers" type="xsd:boolean" use="optional" default="false">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
The default value of delete-on-no-consumers applied to all queues that are
|
||||
auto-created under this address. Also applies to any queues that do not
|
||||
specify a value for delete-on-no-consumers.
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
</xsd:complexType>
|
||||
|
||||
<xsd:complexType name="addressesType">
|
||||
<xsd:sequence>
|
||||
<xsd:element name="address" type="addressType" maxOccurs="unbounded" minOccurs="0"/>
|
||||
</xsd:sequence>
|
||||
</xsd:complexType>
|
||||
|
||||
</xsd:schema>
|
||||
|
|
|
@ -64,6 +64,8 @@ public class DefaultsFileConfigurationTest extends ConfigurationImplTest {
|
|||
|
||||
Assert.assertEquals(Collections.emptyList(), conf.getQueueConfigurations());
|
||||
|
||||
Assert.assertEquals(Collections.emptyList(), conf.getAddressConfigurations());
|
||||
|
||||
Assert.assertEquals(ActiveMQDefaultConfiguration.getDefaultManagementAddress(), conf.getManagementAddress());
|
||||
|
||||
Assert.assertEquals(ActiveMQDefaultConfiguration.getDefaultManagementNotificationAddress(), conf.getManagementNotificationAddress());
|
||||
|
|
|
@ -35,6 +35,8 @@ import org.apache.activemq.artemis.api.core.UDPBroadcastEndpointFactory;
|
|||
import org.apache.activemq.artemis.core.config.BridgeConfiguration;
|
||||
import org.apache.activemq.artemis.core.config.ClusterConnectionConfiguration;
|
||||
import org.apache.activemq.artemis.core.config.Configuration;
|
||||
import org.apache.activemq.artemis.core.config.CoreAddressConfiguration;
|
||||
import org.apache.activemq.artemis.core.config.CoreQueueConfiguration;
|
||||
import org.apache.activemq.artemis.core.config.DivertConfiguration;
|
||||
import org.apache.activemq.artemis.core.config.FileDeploymentManager;
|
||||
import org.apache.activemq.artemis.core.config.HAPolicyConfiguration;
|
||||
|
@ -44,11 +46,15 @@ import org.apache.activemq.artemis.core.security.Role;
|
|||
import org.apache.activemq.artemis.core.server.JournalType;
|
||||
import org.apache.activemq.artemis.core.server.SecuritySettingPlugin;
|
||||
import org.apache.activemq.artemis.core.server.cluster.impl.MessageLoadBalancingType;
|
||||
import org.apache.activemq.artemis.core.server.impl.AddressInfo;
|
||||
import org.apache.activemq.artemis.core.server.impl.LegacyLDAPSecuritySettingPlugin;
|
||||
import org.apache.activemq.artemis.core.settings.impl.SlowConsumerPolicy;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.apache.activemq.artemis.core.server.impl.AddressInfo.RoutingType.ANYCAST;
|
||||
import static org.apache.activemq.artemis.core.server.impl.AddressInfo.RoutingType.MULTICAST;
|
||||
|
||||
public class FileConfigurationTest extends ConfigurationImplTest {
|
||||
|
||||
private final String fullConfigurationName = "ConfigurationTest-full-config.xml";
|
||||
|
@ -331,6 +337,8 @@ public class FileConfigurationTest extends ConfigurationImplTest {
|
|||
assertEquals("color='blue'", conf.getQueueConfigurations().get(1).getFilterString());
|
||||
assertEquals(false, conf.getQueueConfigurations().get(1).isDurable());
|
||||
|
||||
verifyAddresses();
|
||||
|
||||
Map<String, Set<Role>> roles = conf.getSecurityRoles();
|
||||
|
||||
assertEquals(2, roles.size());
|
||||
|
@ -365,6 +373,62 @@ public class FileConfigurationTest extends ConfigurationImplTest {
|
|||
assertEquals(false, conf.isJournalDatasync());
|
||||
}
|
||||
|
||||
private void verifyAddresses() {
|
||||
assertEquals(2, conf.getAddressConfigurations().size());
|
||||
|
||||
// Addr 1
|
||||
CoreAddressConfiguration addressConfiguration = conf.getAddressConfigurations().get(0);
|
||||
assertEquals("addr1", addressConfiguration.getName());
|
||||
assertEquals(ANYCAST, addressConfiguration.getRoutingType());
|
||||
assertEquals(2, addressConfiguration.getQueueConfigurations().size());
|
||||
|
||||
// Addr 1 Queue 1
|
||||
CoreQueueConfiguration queueConfiguration = addressConfiguration.getQueueConfigurations().get(0);
|
||||
|
||||
assertEquals("q1", queueConfiguration.getName());
|
||||
assertFalse(queueConfiguration.isDurable());
|
||||
assertEquals("color='blue'", queueConfiguration.getFilterString());
|
||||
assertEquals(addressConfiguration.getDefaultDeleteOnNoConsumers(), queueConfiguration.getDeleteOnNoConsumers());
|
||||
assertEquals("addr1", queueConfiguration.getAddress());
|
||||
assertEquals(addressConfiguration.getDefaultMaxConsumers(), queueConfiguration.getMaxConsumers());
|
||||
|
||||
// Addr 1 Queue 2
|
||||
queueConfiguration = addressConfiguration.getQueueConfigurations().get(1);
|
||||
|
||||
assertEquals("q2", queueConfiguration.getName());
|
||||
assertTrue(queueConfiguration.isDurable());
|
||||
assertEquals("color='green'", queueConfiguration.getFilterString());
|
||||
assertEquals(new Integer(-1), queueConfiguration.getMaxConsumers());
|
||||
assertFalse(queueConfiguration.getDeleteOnNoConsumers());
|
||||
assertEquals("addr1", queueConfiguration.getAddress());
|
||||
|
||||
// Addr 2
|
||||
addressConfiguration = conf.getAddressConfigurations().get(1);
|
||||
assertEquals("addr2", addressConfiguration.getName());
|
||||
assertEquals(MULTICAST, addressConfiguration.getRoutingType());
|
||||
assertEquals(2, addressConfiguration.getQueueConfigurations().size());
|
||||
|
||||
// Addr 2 Queue 1
|
||||
queueConfiguration = addressConfiguration.getQueueConfigurations().get(0);
|
||||
|
||||
assertEquals("q3", queueConfiguration.getName());
|
||||
assertTrue(queueConfiguration.isDurable());
|
||||
assertEquals("color='red'", queueConfiguration.getFilterString());
|
||||
assertEquals(new Integer(10), queueConfiguration.getMaxConsumers());
|
||||
assertEquals(addressConfiguration.getDefaultDeleteOnNoConsumers(), queueConfiguration.getDeleteOnNoConsumers());
|
||||
assertEquals("addr2", queueConfiguration.getAddress());
|
||||
|
||||
// Addr 2 Queue 2
|
||||
queueConfiguration = addressConfiguration.getQueueConfigurations().get(1);
|
||||
|
||||
assertEquals("q4", queueConfiguration.getName());
|
||||
assertTrue(queueConfiguration.isDurable());
|
||||
assertNull(queueConfiguration.getFilterString());
|
||||
assertEquals(addressConfiguration.getDefaultMaxConsumers(), queueConfiguration.getMaxConsumers());
|
||||
assertTrue(queueConfiguration.getDeleteOnNoConsumers());
|
||||
assertEquals("addr2", queueConfiguration.getAddress());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSecuritySettingPlugin() throws Exception {
|
||||
FileConfiguration fc = new FileConfiguration();
|
||||
|
|
|
@ -297,5 +297,31 @@
|
|||
<factory-class>org.foo</factory-class>
|
||||
</connector-service>
|
||||
</connector-services>
|
||||
|
||||
<addresses>
|
||||
<address name="addr1" type="anycast">
|
||||
<queues>
|
||||
<queue name="q1">
|
||||
<durable>false</durable>
|
||||
<filter string="color='blue'"/>
|
||||
</queue>
|
||||
<queue name="q2" max-consumers="-1" delete-on-no-consumers="false">
|
||||
<durable>true</durable>
|
||||
<filter string="color='green'"/>
|
||||
</queue>
|
||||
</queues>
|
||||
</address>
|
||||
<address name="addr2" type="multicast">
|
||||
<queues>
|
||||
<queue name="q3" max-consumers="10" >
|
||||
<filter string="color='red'"/>
|
||||
</queue>
|
||||
<queue name="q4" delete-on-no-consumers="true">
|
||||
<durable>true</durable>
|
||||
</queue>
|
||||
</queues>
|
||||
</address>
|
||||
</addresses>
|
||||
|
||||
</core>
|
||||
</configuration>
|
||||
|
|
|
@ -0,0 +1,56 @@
|
|||
<!--
|
||||
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.
|
||||
-->
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>org.apache.activemq</groupId>
|
||||
<artifactId>artemis-pom</artifactId>
|
||||
<version>1.5.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<name>ActiveMQ Artemis Tools</name>
|
||||
<groupId>org.apache.activemq.tools</groupId>
|
||||
<artifactId>artemis-tools</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<properties>
|
||||
<activemq.basedir>${project.basedir}/..</activemq.basedir>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<configuration>
|
||||
<archive>
|
||||
<manifestFile>src/main/resources/META-INF/MANIFEST.MF</manifestFile>
|
||||
</archive>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,237 @@
|
|||
/*
|
||||
* 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.tools.migrate.config;
|
||||
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.transform.OutputKeys;
|
||||
import javax.xml.transform.Transformer;
|
||||
import javax.xml.transform.TransformerException;
|
||||
import javax.xml.transform.TransformerFactory;
|
||||
import javax.xml.transform.dom.DOMSource;
|
||||
import javax.xml.transform.stream.StreamResult;
|
||||
import javax.xml.xpath.XPath;
|
||||
import javax.xml.xpath.XPathConstants;
|
||||
import javax.xml.xpath.XPathFactory;
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.apache.activemq.artemis.tools.migrate.config.addressing.Address;
|
||||
import org.apache.activemq.artemis.tools.migrate.config.addressing.Queue;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
|
||||
public class XMLConfigurationMigration {
|
||||
|
||||
private static XMLConfigurationMigration migration;
|
||||
|
||||
private final Document document;
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
|
||||
if (args.length == 0) {
|
||||
System.err.println("Invalid args");
|
||||
printUsage();
|
||||
}
|
||||
else {
|
||||
File input = new File(args[0]);
|
||||
if (input.isDirectory()) {
|
||||
System.out.println("Scanning directory: " + input.getAbsolutePath());
|
||||
recursiveTransform(input);
|
||||
}
|
||||
else {
|
||||
if (args.length != 2) {
|
||||
System.err.println("Invalid args");
|
||||
printUsage();
|
||||
}
|
||||
else {
|
||||
transform(input, new File(args[1]));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void recursiveTransform(File root) throws Exception {
|
||||
for ( File file : root.listFiles())
|
||||
{
|
||||
scanAndTransform(file);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void scanAndTransform(File pFile) throws Exception {
|
||||
try {
|
||||
for (File f : pFile.listFiles()) {
|
||||
if (f.isDirectory()) {
|
||||
scanAndTransform(f);
|
||||
} else {
|
||||
try {
|
||||
if (f.getName().endsWith("xml")) {
|
||||
File file = new File(f.getAbsolutePath() + ".new");
|
||||
if (transform(f, file)) {
|
||||
File r = new File(f.getAbsolutePath());
|
||||
|
||||
f.renameTo(new File(f.getAbsolutePath() + ".bk"));
|
||||
file.renameTo(r);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
//continue
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (NullPointerException e) {
|
||||
System.out.println(pFile.getAbsoluteFile());
|
||||
}
|
||||
}
|
||||
|
||||
public static void printUsage() {
|
||||
System.out.println("Please specify a directory to scan, or input and output file");
|
||||
}
|
||||
|
||||
public static boolean transform(File input, File output) throws Exception {
|
||||
|
||||
migration = new XMLConfigurationMigration(input);
|
||||
try {
|
||||
if (!input.exists()) {
|
||||
System.err.println("Input file not found: " + input);
|
||||
}
|
||||
|
||||
if (migration.convertQueuesToAddresses()) {
|
||||
Properties properties = new Properties();
|
||||
properties.put(OutputKeys.INDENT, "yes");
|
||||
properties.put("{http://xml.apache.org/xslt}indent-amount", "3");
|
||||
properties.put(OutputKeys.ENCODING, "UTF-8");
|
||||
migration.write(output, properties);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
System.err.println("Error tranforming document");
|
||||
e.printStackTrace();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public XMLConfigurationMigration(File input) throws Exception {
|
||||
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
|
||||
factory.setIgnoringElementContentWhitespace(true);
|
||||
|
||||
DocumentBuilder db = factory.newDocumentBuilder();
|
||||
this.document = db.parse(input);
|
||||
}
|
||||
|
||||
public boolean convertQueuesToAddresses() throws Exception {
|
||||
|
||||
Map<String, Address> addresses = new HashMap<>();
|
||||
|
||||
String xPathQueues = "/configuration/core/queues";
|
||||
String xPathQueue = "/configuration/core/queues/queue";
|
||||
String xPathAttrName = "@name";
|
||||
String xPathAddress = "address";
|
||||
String xPathFilter = "filter/@string";
|
||||
String xPathDurable = "durable";
|
||||
|
||||
XPath xPath = XPathFactory.newInstance().newXPath();
|
||||
|
||||
NodeList xpathResult = (NodeList) xPath.evaluate(xPathQueue, document, XPathConstants.NODESET);
|
||||
if (xpathResult == null || xpathResult.getLength() == 0) {
|
||||
// doesn't require change
|
||||
return false;
|
||||
}
|
||||
|
||||
for (int i = 0; i < xpathResult.getLength(); i++) {
|
||||
Node queueNode = xpathResult.item(i);
|
||||
|
||||
Queue queue = new Queue();
|
||||
queue.setName(xPath.evaluate(xPathAttrName, queueNode, XPathConstants.STRING).toString());
|
||||
queue.setDurable(xPath.evaluate(xPathDurable, queueNode, XPathConstants.STRING).toString());
|
||||
queue.setFilter(xPath.evaluate(xPathFilter, queueNode, XPathConstants.STRING).toString());
|
||||
|
||||
String addressName = xPath.evaluate(xPathAddress, queueNode, XPathConstants.STRING).toString();
|
||||
Address address;
|
||||
|
||||
if (addresses.containsKey(addressName)) {
|
||||
address = addresses.get(addressName);
|
||||
}
|
||||
else {
|
||||
address = new Address();
|
||||
address.setName(addressName);
|
||||
addresses.put(addressName, address);
|
||||
}
|
||||
address.getQueues().add(queue);
|
||||
}
|
||||
|
||||
Node queues = ((Node) xPath.evaluate(xPathQueues, document, XPathConstants.NODE));
|
||||
|
||||
if (queues != null) {
|
||||
Node core = queues.getParentNode();
|
||||
core.removeChild(queues);
|
||||
|
||||
Element a = document.createElement("addresses");
|
||||
for (Address addr : addresses.values()) {
|
||||
Element eAddr = document.createElement("address");
|
||||
eAddr.setAttribute("name", addr.getName());
|
||||
eAddr.setAttribute("type", addr.getRoutingType());
|
||||
|
||||
if (addr.getQueues().size() > 0) {
|
||||
Element eQueues = document.createElement("queues");
|
||||
for (Queue queue : addr.getQueues()) {
|
||||
Element eQueue = document.createElement("queue");
|
||||
eQueue.setAttribute("name", queue.getName());
|
||||
eQueue.setAttribute("max-consumers", addr.getDefaultMaxConsumers());
|
||||
eQueue.setAttribute("delete-on-no-consumers", addr.getDefaultDeleteOnNoConsumers());
|
||||
|
||||
if (queue.getDurable() != null && !queue.getDurable().isEmpty()) {
|
||||
Element eDurable = document.createElement("durable");
|
||||
eDurable.setTextContent(queue.getDurable());
|
||||
eQueue.appendChild(eDurable);
|
||||
}
|
||||
|
||||
if (queue.getFilter() != null && !queue.getFilter().isEmpty()) {
|
||||
Element eFilter = document.createElement("filter");
|
||||
eFilter.setAttribute("string", queue.getFilter());
|
||||
eQueue.appendChild(eFilter);
|
||||
}
|
||||
|
||||
eQueues.appendChild(eQueue);
|
||||
}
|
||||
eAddr.appendChild(eQueues);
|
||||
}
|
||||
a.appendChild(eAddr);
|
||||
}
|
||||
core.appendChild(a);
|
||||
}
|
||||
|
||||
document.normalize();
|
||||
return true;
|
||||
}
|
||||
|
||||
public void write(File output, Properties outputProperties) throws TransformerException {
|
||||
Transformer transformer = TransformerFactory.newInstance().newTransformer();
|
||||
transformer.setOutputProperties(outputProperties);
|
||||
StreamResult streamResult = new StreamResult(output);
|
||||
transformer.transform(new DOMSource(document), streamResult);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,73 @@
|
|||
/*
|
||||
* 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.tools.migrate.config.addressing;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Address {
|
||||
|
||||
private String name;
|
||||
|
||||
private String routingType = "multicast";
|
||||
|
||||
private String defaultMaxConsumers = "-1";
|
||||
|
||||
private String defaultDeleteOnNoConsumers = "false";
|
||||
|
||||
private List<Queue> queues = new ArrayList<>();
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getRoutingType() {
|
||||
return routingType;
|
||||
}
|
||||
|
||||
public void setRoutingType(String routingType) {
|
||||
this.routingType = routingType;
|
||||
}
|
||||
|
||||
public String getDefaultMaxConsumers() {
|
||||
return defaultMaxConsumers;
|
||||
}
|
||||
|
||||
public void setDefaultMaxConsumers(String defaultMaxConsumers) {
|
||||
this.defaultMaxConsumers = defaultMaxConsumers;
|
||||
}
|
||||
|
||||
public String getDefaultDeleteOnNoConsumers() {
|
||||
return defaultDeleteOnNoConsumers;
|
||||
}
|
||||
|
||||
public void setDefaultDeleteOnNoConsumers(String defaultDeleteOnNoConsumers) {
|
||||
this.defaultDeleteOnNoConsumers = defaultDeleteOnNoConsumers;
|
||||
}
|
||||
|
||||
public List<Queue> getQueues() {
|
||||
return queues;
|
||||
}
|
||||
|
||||
public void setQueues(List<Queue> queues) {
|
||||
this.queues = queues;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
* 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.tools.migrate.config.addressing;
|
||||
|
||||
public class Queue {
|
||||
|
||||
String name;
|
||||
|
||||
String filter;
|
||||
|
||||
String durable;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getFilter() {
|
||||
return filter;
|
||||
}
|
||||
|
||||
public void setFilter(String filter) {
|
||||
this.filter = filter;
|
||||
}
|
||||
|
||||
public String getDurable() {
|
||||
return durable;
|
||||
}
|
||||
|
||||
public void setDurable(String durable) {
|
||||
this.durable = durable;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,2 @@
|
|||
Manifest-Version: 1.0
|
||||
Main-Class: org.apache.activemq.artemis.tools.migrate.config.XMLConfigurationMigration
|
|
@ -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.activemq.artemis.tools.migrate.config;
|
||||
|
||||
import javax.xml.transform.OutputKeys;
|
||||
import java.io.File;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
public class XMLConfigurationMigrationTest {
|
||||
|
||||
@Test
|
||||
public void testQueuesReplacedWithAddresses() throws Exception {
|
||||
File brokerXml = new File(this.getClass().getClassLoader().getResource("broker.xml").toURI());
|
||||
XMLConfigurationMigration tool = new XMLConfigurationMigration(brokerXml);
|
||||
|
||||
File output = new File("target/out.xml");
|
||||
tool.convertQueuesToAddresses();
|
||||
|
||||
Properties properties = new Properties();
|
||||
properties.put(OutputKeys.INDENT, "yes");
|
||||
properties.put("{http://xml.apache.org/xslt}indent-amount", "3");
|
||||
properties.put(OutputKeys.ENCODING, "UTF-8");
|
||||
tool.write(output, properties);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void scanAndReplaceTest() throws Exception {
|
||||
File dir = new File(this.getClass().getClassLoader().getResource("replace").getPath());
|
||||
XMLConfigurationMigration.scanAndTransform(dir);
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,46 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
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.
|
||||
-->
|
||||
<xsd:schema xmlns="urn:activemq"
|
||||
targetNamespace="urn:activemq"
|
||||
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
||||
attributeFormDefault="unqualified"
|
||||
elementFormDefault="qualified"
|
||||
version="1.0">
|
||||
<xsd:element name="configuration">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
Root element for a document specifying the configuration
|
||||
of a single "standalone" server that does not operate
|
||||
as part of a domain.
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:choice minOccurs="1" maxOccurs="unbounded">
|
||||
<xsd:any namespace="##other">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>A profile declaration may include configuration
|
||||
elements from other namespaces for the subsystems that make up the profile.
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:any>
|
||||
</xsd:choice>
|
||||
</xsd:sequence>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
|
@ -0,0 +1,64 @@
|
|||
<!--
|
||||
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.
|
||||
-->
|
||||
<configuration xmlns="urn:activemq"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="urn:activemq /schema/artemis-server.xsd">
|
||||
<jms xmlns="urn:activemq:jms">
|
||||
<!--the queue used by the example-->
|
||||
<queue name="exampleQueue"/>
|
||||
</jms>
|
||||
|
||||
<core xmlns="urn:activemq:core">
|
||||
|
||||
<persistence-enabled>false</persistence-enabled>
|
||||
<!-- Connectors -->
|
||||
|
||||
<connectors>
|
||||
<connector name="in-vm">vm://0</connector>
|
||||
</connectors>
|
||||
|
||||
<acceptors>
|
||||
<acceptor name="in-vm">vm://0</acceptor>
|
||||
</acceptors>
|
||||
|
||||
<!-- Other config -->
|
||||
|
||||
<security-settings>
|
||||
<!--security for example queue-->
|
||||
<security-setting match="jms.queue.exampleQueue">
|
||||
<permission type="createDurableQueue" roles="guest"/>
|
||||
<permission type="deleteDurableQueue" roles="guest"/>
|
||||
<permission type="createNonDurableQueue" roles="guest"/>
|
||||
<permission type="deleteNonDurableQueue" roles="guest"/>
|
||||
<permission type="consume" roles="guest"/>
|
||||
<permission type="send" roles="guest"/>
|
||||
</security-setting>
|
||||
</security-settings>
|
||||
|
||||
<queues>
|
||||
<queue name="foo">
|
||||
<address>bar</address>
|
||||
</queue>
|
||||
<queue name="bar">
|
||||
<address>afar</address>
|
||||
<durable>true</durable>
|
||||
<filter string="name='car'" />
|
||||
</queue>
|
||||
</queues>
|
||||
</core>
|
||||
|
||||
</configuration>
|
|
@ -0,0 +1,64 @@
|
|||
<!--
|
||||
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.
|
||||
-->
|
||||
<configuration xmlns="urn:activemq"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="urn:activemq /schema/artemis-server.xsd">
|
||||
<jms xmlns="urn:activemq:jms">
|
||||
<!--the queue used by the example-->
|
||||
<queue name="exampleQueue"/>
|
||||
</jms>
|
||||
|
||||
<core xmlns="urn:activemq:core">
|
||||
|
||||
<persistence-enabled>false</persistence-enabled>
|
||||
<!-- Connectors -->
|
||||
|
||||
<connectors>
|
||||
<connector name="in-vm">vm://0</connector>
|
||||
</connectors>
|
||||
|
||||
<acceptors>
|
||||
<acceptor name="in-vm">vm://0</acceptor>
|
||||
</acceptors>
|
||||
|
||||
<!-- Other config -->
|
||||
|
||||
<security-settings>
|
||||
<!--security for example queue-->
|
||||
<security-setting match="jms.queue.exampleQueue">
|
||||
<permission type="createDurableQueue" roles="guest"/>
|
||||
<permission type="deleteDurableQueue" roles="guest"/>
|
||||
<permission type="createNonDurableQueue" roles="guest"/>
|
||||
<permission type="deleteNonDurableQueue" roles="guest"/>
|
||||
<permission type="consume" roles="guest"/>
|
||||
<permission type="send" roles="guest"/>
|
||||
</security-setting>
|
||||
</security-settings>
|
||||
|
||||
<queues>
|
||||
<queue name="foo">
|
||||
<address>bar</address>
|
||||
</queue>
|
||||
<queue name="bar">
|
||||
<address>afar</address>
|
||||
<durable>true</durable>
|
||||
<filter string="name='car'" />
|
||||
</queue>
|
||||
</queues>
|
||||
</core>
|
||||
|
||||
</configuration>
|
|
@ -0,0 +1,64 @@
|
|||
<!--
|
||||
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.
|
||||
-->
|
||||
<configuration xmlns="urn:activemq"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="urn:activemq /schema/artemis-server.xsd">
|
||||
<jms xmlns="urn:activemq:jms">
|
||||
<!--the queue used by the example-->
|
||||
<queue name="exampleQueue"/>
|
||||
</jms>
|
||||
|
||||
<core xmlns="urn:activemq:core">
|
||||
|
||||
<persistence-enabled>false</persistence-enabled>
|
||||
<!-- Connectors -->
|
||||
|
||||
<connectors>
|
||||
<connector name="in-vm">vm://0</connector>
|
||||
</connectors>
|
||||
|
||||
<acceptors>
|
||||
<acceptor name="in-vm">vm://0</acceptor>
|
||||
</acceptors>
|
||||
|
||||
<!-- Other config -->
|
||||
|
||||
<security-settings>
|
||||
<!--security for example queue-->
|
||||
<security-setting match="jms.queue.exampleQueue">
|
||||
<permission type="createDurableQueue" roles="guest"/>
|
||||
<permission type="deleteDurableQueue" roles="guest"/>
|
||||
<permission type="createNonDurableQueue" roles="guest"/>
|
||||
<permission type="deleteNonDurableQueue" roles="guest"/>
|
||||
<permission type="consume" roles="guest"/>
|
||||
<permission type="send" roles="guest"/>
|
||||
</security-setting>
|
||||
</security-settings>
|
||||
|
||||
<queues>
|
||||
<queue name="foo">
|
||||
<address>bar</address>
|
||||
</queue>
|
||||
<queue name="bar">
|
||||
<address>afar</address>
|
||||
<durable>true</durable>
|
||||
<filter string="name='car'" />
|
||||
</queue>
|
||||
</queues>
|
||||
</core>
|
||||
|
||||
</configuration>
|
1
pom.xml
1
pom.xml
|
@ -56,6 +56,7 @@
|
|||
<module>integration/activemq-aerogear-integration</module>
|
||||
<module>integration/activemq-vertx-integration</module>
|
||||
<module>artemis-distribution</module>
|
||||
<module>artemis-tools</module>
|
||||
<module>tests</module>
|
||||
<module>artemis-features</module>
|
||||
</modules>
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
/*
|
||||
* 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.tests.integration.addressing;
|
||||
|
||||
public class AddressingTest {
|
||||
|
||||
}
|
|
@ -33,6 +33,7 @@ import org.apache.activemq.artemis.core.server.Queue;
|
|||
import org.apache.activemq.artemis.core.server.QueueCreator;
|
||||
import org.apache.activemq.artemis.core.server.RoutingContext;
|
||||
import org.apache.activemq.artemis.core.server.ServerMessage;
|
||||
import org.apache.activemq.artemis.core.server.impl.AddressInfo;
|
||||
import org.apache.activemq.artemis.core.server.impl.MessageReferenceImpl;
|
||||
import org.apache.activemq.artemis.core.transaction.Transaction;
|
||||
|
||||
|
@ -59,6 +60,22 @@ public class FakePostOffice implements PostOffice {
|
|||
|
||||
}
|
||||
|
||||
@Override
|
||||
public AddressInfo addAddressInfo(AddressInfo addressInfo) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public AddressInfo removeAddressInfo(SimpleString address) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AddressInfo getAddressInfo(SimpleString addressName) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addBinding(final Binding binding) throws Exception {
|
||||
|
||||
|
|
Loading…
Reference in New Issue