ARTEMIS-780 Added ability to define 2 Routing Types on a single addres

This commit is contained in:
Martyn Taylor 2016-11-25 13:06:21 +00:00
parent 0861be14c1
commit 7a51491c32
95 changed files with 2091 additions and 829 deletions

View File

@ -17,12 +17,16 @@
package org.apache.activemq.artemis.cli.commands.address;
import java.util.HashSet;
import java.util.Set;
import io.airlift.airline.Command;
import io.airlift.airline.Option;
import org.apache.activemq.artemis.api.core.client.ClientMessage;
import org.apache.activemq.artemis.api.core.management.ManagementHelper;
import org.apache.activemq.artemis.cli.commands.AbstractAction;
import org.apache.activemq.artemis.cli.commands.ActionContext;
import org.apache.activemq.artemis.core.server.RoutingType;
@Command(name = "create", description = "create an address")
public class CreateAddress extends AbstractAction {
@ -30,8 +34,8 @@ public class CreateAddress extends AbstractAction {
@Option(name = "--name", description = "The name of this address")
String name;
@Option(name = "--routingType", description = "The routing type of the address, options are 'anycast' or 'multicast', defaults to 1 = 'multicast'")
String routingType = "multicast";
@Option(name = "--routingTypes", description = "The routing types supported by this address, options are 'anycast' or 'multicast', enter comma separated list, defaults to 'multicast' only")
Set<RoutingType> routingTypes = new HashSet<>();
@Option(name = "--defaultMaxConsumers", description = "Sets the default max consumers for any queues created under this address, default = -1 (no limit)")
int defaultMaxConsumers = -1;
@ -50,7 +54,7 @@ public class CreateAddress extends AbstractAction {
performCoreManagement(new ManagementCallback<ClientMessage>() {
@Override
public void setUpInvocation(ClientMessage message) throws Exception {
ManagementHelper.putOperationInvocation(message, "broker", "createAddress", getName(), routingType, defaultDeleteOnNoConsumers, defaultMaxConsumers);
ManagementHelper.putOperationInvocation(message, "broker", "createAddress", getName(), routingTypes, defaultDeleteOnNoConsumers, defaultMaxConsumers);
}
@Override
@ -74,12 +78,14 @@ public class CreateAddress extends AbstractAction {
return name;
}
public String getRoutingType() {
return routingType;
public Set<RoutingType> getRoutingTypes() {
return routingTypes;
}
public void setRoutingType(String routingType) {
this.routingType = routingType;
public void setRoutingTypes(String routingTypes) {
for (String s : routingTypes.split(",")) {
this.routingTypes.add(RoutingType.valueOf(s.trim()));
}
}
public int getDefaultMaxConsumers() {

View File

@ -18,6 +18,7 @@ package org.apache.activemq.artemis.api.config;
import org.apache.activemq.artemis.ArtemisConstants;
import org.apache.activemq.artemis.api.core.SimpleString;
import org.apache.activemq.artemis.core.server.RoutingType;
/**
* Default values of ActiveMQ Artemis configuration parameters.
@ -441,6 +442,8 @@ public final class ActiveMQDefaultConfiguration {
public static final boolean DEFAULT_DELETE_QUEUE_ON_NO_CONSUMERS = false;
public static final RoutingType DEFAULT_ROUTING_TYPE = RoutingType.MULTICAST;
public static final String DEFAULT_SYSTEM_PROPERTY_PREFIX = "brokerconfig.";
public static String DEFAULT_NETWORK_CHECK_LIST = null;
@ -1205,6 +1208,10 @@ public final class ActiveMQDefaultConfiguration {
return DEFAULT_INTERNAL_NAMING_PREFIX;
}
public static RoutingType getDefaultRoutingType() {
return DEFAULT_ROUTING_TYPE;
}
public static String getDefaultSystemPropertyPrefix() {
return DEFAULT_SYSTEM_PROPERTY_PREFIX;
}

View File

@ -18,9 +18,11 @@ package org.apache.activemq.artemis.api.core.client;
import javax.transaction.xa.XAResource;
import java.util.List;
import java.util.Set;
import org.apache.activemq.artemis.api.core.ActiveMQException;
import org.apache.activemq.artemis.api.core.SimpleString;
import org.apache.activemq.artemis.core.server.RoutingType;
/**
* A ClientSession is a single-thread object required for producing and consuming messages.
@ -198,7 +200,22 @@ public interface ClientSession extends XAResource, AutoCloseable {
*/
int getVersion();
void createAddress(final SimpleString address, final boolean multicast, final boolean autoCreated) throws ActiveMQException;
/**
* Create Address with a single initial routing type
* @param address
* @param autoCreated
* @throws ActiveMQException
*/
void createAddress(final SimpleString address, Set<RoutingType> routingTypes, final boolean autoCreated) throws ActiveMQException;
/**
* Create Address with a single initial routing type
* @param address
* @param routingType
* @param autoCreated
* @throws ActiveMQException
*/
void createAddress(final SimpleString address, RoutingType routingType, final boolean autoCreated) throws ActiveMQException;
// Queue Operations ----------------------------------------------
@ -210,6 +227,7 @@ public interface ClientSession extends XAResource, AutoCloseable {
* @param durable whether the queue is durable or not
* @throws ActiveMQException in an exception occurs while creating the queue
*/
@Deprecated
void createQueue(SimpleString address, SimpleString queueName, boolean durable) throws ActiveMQException;
/**
@ -222,6 +240,7 @@ public interface ClientSession extends XAResource, AutoCloseable {
* @param durable if the queue is durable
* @throws ActiveMQException in an exception occurs while creating the queue
*/
@Deprecated
void createSharedQueue(SimpleString address, SimpleString queueName, boolean durable) throws ActiveMQException;
/**
@ -235,6 +254,7 @@ public interface ClientSession extends XAResource, AutoCloseable {
* @param durable if the queue is durable
* @throws ActiveMQException in an exception occurs while creating the queue
*/
@Deprecated
void createSharedQueue(SimpleString address,
SimpleString queueName,
SimpleString filter,
@ -248,6 +268,7 @@ public interface ClientSession extends XAResource, AutoCloseable {
* @param durable whether the queue is durable or not
* @throws ActiveMQException in an exception occurs while creating the queue
*/
@Deprecated
void createQueue(String address, String queueName, boolean durable) throws ActiveMQException;
/**
@ -257,6 +278,7 @@ public interface ClientSession extends XAResource, AutoCloseable {
* @param queueName the name of the queue
* @throws ActiveMQException in an exception occurs while creating the queue
*/
@Deprecated
void createQueue(String address, String queueName) throws ActiveMQException;
/**
@ -266,6 +288,7 @@ public interface ClientSession extends XAResource, AutoCloseable {
* @param queueName the name of the queue
* @throws ActiveMQException in an exception occurs while creating the queue
*/
@Deprecated
void createQueue(SimpleString address, SimpleString queueName) throws ActiveMQException;
/**
@ -277,6 +300,7 @@ public interface ClientSession extends XAResource, AutoCloseable {
* @param durable whether the queue is durable or not
* @throws ActiveMQException in an exception occurs while creating the queue
*/
@Deprecated
void createQueue(SimpleString address,
SimpleString queueName,
SimpleString filter,
@ -291,6 +315,7 @@ public interface ClientSession extends XAResource, AutoCloseable {
* @param filter only messages which match this filter will be put in the queue
* @throws ActiveMQException in an exception occurs while creating the queue
*/
@Deprecated
void createQueue(String address, String queueName, String filter, boolean durable) throws ActiveMQException;
/**
@ -303,6 +328,7 @@ public interface ClientSession extends XAResource, AutoCloseable {
* @param autoCreated whether to mark this queue as autoCreated or not
* @throws ActiveMQException in an exception occurs while creating the queue
*/
@Deprecated
void createQueue(SimpleString address,
SimpleString queueName,
SimpleString filter,
@ -319,6 +345,7 @@ public interface ClientSession extends XAResource, AutoCloseable {
* @param autoCreated whether to mark this queue as autoCreated or not
* @throws ActiveMQException in an exception occurs while creating the queue
*/
@Deprecated
void createQueue(String address, String queueName, String filter, boolean durable, boolean autoCreated) throws ActiveMQException;
/**
@ -328,6 +355,7 @@ public interface ClientSession extends XAResource, AutoCloseable {
* @param queueName the name of the queue
* @throws ActiveMQException in an exception occurs while creating the queue
*/
@Deprecated
void createTemporaryQueue(SimpleString address, SimpleString queueName) throws ActiveMQException;
/**
@ -337,6 +365,7 @@ public interface ClientSession extends XAResource, AutoCloseable {
* @param queueName the name of the queue
* @throws ActiveMQException in an exception occurs while creating the queue
*/
@Deprecated
void createTemporaryQueue(String address, String queueName) throws ActiveMQException;
/**
@ -347,6 +376,7 @@ public interface ClientSession extends XAResource, AutoCloseable {
* @param filter only messages which match this filter will be put in the queue
* @throws ActiveMQException in an exception occurs while creating the queue
*/
@Deprecated
void createTemporaryQueue(SimpleString address,
SimpleString queueName,
SimpleString filter) throws ActiveMQException;
@ -359,8 +389,177 @@ public interface ClientSession extends XAResource, AutoCloseable {
* @param filter only messages which match this filter will be put in the queue
* @throws ActiveMQException in an exception occurs while creating the queue
*/
@Deprecated
void createTemporaryQueue(String address, String queueName, String filter) throws ActiveMQException;
/** Deprecate **/
/**
* Creates a <em>non-temporary</em> queue.
*
* @param address the queue will be bound to this address
* @param routingType the delivery mode for this queue, MULTICAST or ANYCAST
* @param queueName the name of the queue
* @param durable whether the queue is durable or not
* @throws ActiveMQException in an exception occurs while creating the queue
*/
void createQueue(SimpleString address, RoutingType routingType, SimpleString queueName, boolean durable) throws ActiveMQException;
/**
* Creates a transient queue. A queue that will exist as long as there are consumers. When the last consumer is closed the queue will be deleted
* <p>
* Notice: you will get an exception if the address or the filter doesn't match to an already existent queue
*
* @param address the queue will be bound to this address
* @param routingType the delivery mode for this queue, MULTICAST or ANYCAST
* @param queueName the name of the queue
* @param durable if the queue is durable
* @throws ActiveMQException in an exception occurs while creating the queue
*/
void createSharedQueue(SimpleString address, RoutingType routingType, SimpleString queueName, boolean durable) throws ActiveMQException;
/**
* Creates a transient queue. A queue that will exist as long as there are consumers. When the last consumer is closed the queue will be deleted
* <p>
* Notice: you will get an exception if the address or the filter doesn't match to an already existent queue
*
* @param address the queue will be bound to this address
* @param routingType the delivery mode for this queue, MULTICAST or ANYCAST
* @param queueName the name of the queue
* @param filter whether the queue is durable or not
* @param durable if the queue is durable
* @throws ActiveMQException in an exception occurs while creating the queue
*/
void createSharedQueue(SimpleString address, RoutingType routingType, SimpleString queueName, SimpleString filter,
boolean durable) throws ActiveMQException;
/**
* Creates a <em>non-temporary</em> queue.
*
* @param address the queue will be bound to this address
* @param routingType the delivery mode for this queue, MULTICAST or ANYCAST
* @param queueName the name of the queue
* @param durable whether the queue is durable or not
* @throws ActiveMQException in an exception occurs while creating the queue
*/
void createQueue(String address, RoutingType routingType, String queueName, boolean durable) throws ActiveMQException;
/**
* Creates a <em>non-temporary</em> queue <em>non-durable</em> queue.
*
* @param address the queue will be bound to this address
* @param routingType the delivery mode for this queue, MULTICAST or ANYCAST
* @param queueName the name of the queue
* @throws ActiveMQException in an exception occurs while creating the queue
*/
void createQueue(String address, RoutingType routingType, String queueName) throws ActiveMQException;
/**
* Creates a <em>non-temporary</em> queue <em>non-durable</em> queue.
*
* @param address the queue will be bound to this address
* @param routingType the delivery mode for this queue, MULTICAST or ANYCAST
* @param queueName the name of the queue
* @throws ActiveMQException in an exception occurs while creating the queue
*/
void createQueue(SimpleString address, RoutingType routingType, SimpleString queueName) throws ActiveMQException;
/**
* Creates a <em>non-temporary</em> queue.
*
* @param address the queue will be bound to this address
* @param routingType the delivery mode for this queue, MULTICAST or ANYCAST
* @param queueName the name of the queue
* @param filter only messages which match this filter will be put in the queue
* @param durable whether the queue is durable or not
* @throws ActiveMQException in an exception occurs while creating the queue
*/
void createQueue(SimpleString address, RoutingType routingType, SimpleString queueName, SimpleString filter,
boolean durable) throws ActiveMQException;
/**
* Creates a <em>non-temporary</em>queue.
*
* @param address the queue will be bound to this address
* @param routingType the delivery mode for this queue, MULTICAST or ANYCAST
* @param queueName the name of the queue
* @param filter only messages which match this filter will be put in the queue
* @param durable whether the queue is durable or not
* @throws ActiveMQException in an exception occurs while creating the queue
*/
void createQueue(String address, RoutingType routingType, String queueName, String filter, boolean durable) throws ActiveMQException;
/**
* Creates a <em>non-temporary</em> queue.
*
* @param address the queue will be bound to this address
* @param routingType the delivery mode for this queue, MULTICAST or ANYCAST
* @param queueName the name of the queue
* @param filter only messages which match this filter will be put in the queue
* @param durable whether the queue is durable or not
* @param autoCreated whether to mark this queue as autoCreated or not
* @throws ActiveMQException in an exception occurs while creating the queue
*/
void createQueue(SimpleString address, RoutingType routingType, SimpleString queueName, SimpleString filter,
boolean durable,
boolean autoCreated) throws ActiveMQException;
/**
* Creates a <em>non-temporary</em>queue.
*
* @param address the queue will be bound to this address
* @param routingType the delivery mode for this queue, MULTICAST or ANYCAST
* @param queueName the name of the queue
* @param filter only messages which match this filter will be put in the queue
* @param durable whether the queue is durable or not
* @param autoCreated whether to mark this queue as autoCreated or not
* @throws ActiveMQException in an exception occurs while creating the queue
*/
void createQueue(String address, RoutingType routingType, String queueName, String filter, boolean durable, boolean autoCreated) throws ActiveMQException;
/**
* Creates a <em>temporary</em> queue.
*
* @param address the queue will be bound to this address
* @param routingType the delivery mode for this queue, MULTICAST or ANYCAST
* @param queueName the name of the queue
* @throws ActiveMQException in an exception occurs while creating the queue
*/
void createTemporaryQueue(SimpleString address, RoutingType routingType, SimpleString queueName) throws ActiveMQException;
/**
* Creates a <em>temporary</em> queue.
*
* @param address the queue will be bound to this address
* @param routingType the delivery mode for this queue, MULTICAST or ANYCAST
* @param queueName the name of the queue
* @throws ActiveMQException in an exception occurs while creating the queue
*/
void createTemporaryQueue(String address, RoutingType routingType, String queueName) throws ActiveMQException;
/**
* Creates a <em>temporary</em> queue with a filter.
*
* @param address the queue will be bound to this address
* @param routingType the delivery mode for this queue, MULTICAST or ANYCAST
* @param queueName the name of the queue
* @param filter only messages which match this filter will be put in the queue
* @throws ActiveMQException in an exception occurs while creating the queue
*/
void createTemporaryQueue(SimpleString address, RoutingType routingType, SimpleString queueName, SimpleString filter) throws ActiveMQException;
/**
* Creates a <em>temporary</em> queue with a filter.
*
* @param address the queue will be bound to this address
* @param routingType the delivery mode for this queue, MULTICAST or ANYCAST
* @param queueName the name of the queue
* @param filter only messages which match this filter will be put in the queue
* @throws ActiveMQException in an exception occurs while creating the queue
*/
void createTemporaryQueue(String address, RoutingType routingType, String queueName, String filter) throws ActiveMQException;
/**
* Deletes the queue.
*

View File

@ -18,8 +18,10 @@ package org.apache.activemq.artemis.api.core.management;
import javax.management.MBeanOperationInfo;
import java.util.Map;
import java.util.Set;
import org.apache.activemq.artemis.api.core.ActiveMQAddressDoesNotExistException;
import org.apache.activemq.artemis.core.server.RoutingType;
/**
* An ActiveMQServerControl is used to manage ActiveMQ Artemis servers.
@ -434,18 +436,9 @@ public interface ActiveMQServerControl {
// Operations ----------------------------------------------------
@Operation(desc = "create an address", impact = MBeanOperationInfo.ACTION)
@Operation(desc = "delete an address", impact = MBeanOperationInfo.ACTION)
void createAddress(@Parameter(name = "name", desc = "The name of the address") String name,
@Parameter(name = "routingType", desc = "the routing type of the address either 0 for multicast or 1 for anycast") int routingType,
@Parameter(name = "defaultDeleteOnNoConsumers", desc = "Whether or not a queue with this address is deleted when it has no consumers") boolean defaultDeleteOnNoConsumers,
@Parameter(name = "defaultMaxConsumers", desc = "The maximim number of consumer a queue with this address can have") int defaultMaxConsumers) throws Exception;
@Operation(desc = "create an address", impact = MBeanOperationInfo.ACTION)
void createAddress(@Parameter(name = "name", desc = "The name of the address") String name,
@Parameter(name = "routingType", desc = "The routing type for the address either 'MULTICAST' or 'ANYCAST'") String routingType,
@Parameter(name = "defaultDeleteOnNoConsumers", desc = "Whether or not a queue with this address is deleted when it has no consumers") boolean defaultDeleteOnNoConsumers,
@Parameter(name = "defaultMaxConsumers", desc = "The maximim number of consumer a queue with this address can have") int defaultMaxConsumers) throws Exception;
@Parameter(name = "deliveryMode", desc = "The delivery modes enabled for this address'") Set<RoutingType> routingTypes) throws Exception;
@Operation(desc = "delete an address", impact = MBeanOperationInfo.ACTION)
void deleteAddress(@Parameter(name = "name", desc = "The name of the address") String name) throws Exception;
@ -464,6 +457,14 @@ public interface ActiveMQServerControl {
void createQueue(@Parameter(name = "address", desc = "Address of the queue") String address,
@Parameter(name = "name", desc = "Name of the queue") String name) throws Exception;
void createQueue(@Parameter(name = "address", desc = "Address of the queue") String address,
@Parameter(name = "routingType", desc = "The routing type used for this address, 0=multicast, 1=anycast") RoutingType routingType,
@Parameter(name = "name", desc = "Name of the queue") String name,
@Parameter(name = "filter", desc = "Filter of the queue") String filterStr,
@Parameter(name = "durable", desc = "Is the queue durable?") boolean durable,
@Parameter(name = "maxConsumers", desc = "The maximum number of consumers allowed on this queue at any one time") int maxConsumers,
@Parameter(name = "deleteOnNoConsumers", desc = "Delete this queue when the last consumer disconnects") boolean deleteOnNoConsumers,
@Parameter(name = "autoCreateAddress", desc = "Create an address with default values should a matching address not be found") boolean autoCreateAddress) throws Exception;
/**
* Create a queue.
@ -499,25 +500,6 @@ public interface ActiveMQServerControl {
@Parameter(name = "name", desc = "Name of the queue") String name,
@Parameter(name = "durable", desc = "Is the queue durable?") boolean durable) throws Exception;
/**
* Create a queue.
* <br>
* If {@code address} is {@code null} it will be defaulted to {@code name}.
* <br>
* This method throws a {@link org.apache.activemq.artemis.api.core.ActiveMQQueueExistsException}) exception if the queue already exits.
*
* @param address address to bind the queue to
* @param name name of the queue
* @param durable whether the queue is durable
*/
@Operation(desc = "Create a queue with the specified address, name and durability", impact = MBeanOperationInfo.ACTION)
void createQueue(@Parameter(name = "address", desc = "Address of the queue") String address,
@Parameter(name = "name", desc = "Name of the queue") String name,
@Parameter(name = "filter", desc = "Filter of the queue") String filter,
@Parameter(name = "durable", desc = "Is the queue durable?") boolean durable,
@Parameter(name = "maxConsumers", desc = "The maximum number of consumers allowed on this queue at any one time") int maxConsumers,
@Parameter(name = "deleteOnNoConsumers", desc = "Delete this queue when the last consumer disconnects") boolean deleteOnNoConsumers,
@Parameter(name = "autoCreateAddress", desc = "Create an address with default values should a matching address not be found") boolean autoCreateAddress) throws Exception;
/**
* Deploy a durable queue.
* <br>

View File

@ -18,6 +18,9 @@ package org.apache.activemq.artemis.api.core.management;
import javax.management.MBeanOperationInfo;
import java.util.Map;
import java.util.Set;
import org.apache.activemq.artemis.core.server.RoutingType;
/**
* An AddressControl is used to manage an address.
@ -31,10 +34,10 @@ public interface AddressControl {
String getAddress();
/*
* The routing type of this address, either multicast (topic subscriptions) or anycast (queue semantics).
* Whether multicast routing is enabled for this address
* */
@Attribute(desc = "The routing type of this address")
String getRoutingType();
@Attribute(desc = "Get the delivery modes enabled on this address")
Set<RoutingType> getDeliveryModes();
/**
* Returns the roles (name and permissions) associated with this address.

View File

@ -27,6 +27,7 @@ import java.util.Set;
import java.util.concurrent.Executor;
import java.util.concurrent.atomic.AtomicInteger;
import org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration;
import org.apache.activemq.artemis.api.core.ActiveMQBuffer;
import org.apache.activemq.artemis.api.core.ActiveMQBuffers;
import org.apache.activemq.artemis.api.core.ActiveMQException;
@ -43,6 +44,7 @@ import org.apache.activemq.artemis.api.core.client.SessionFailureListener;
import org.apache.activemq.artemis.core.client.ActiveMQClientLogger;
import org.apache.activemq.artemis.core.client.ActiveMQClientMessageBundle;
import org.apache.activemq.artemis.core.remoting.FailureListener;
import org.apache.activemq.artemis.core.server.RoutingType;
import org.apache.activemq.artemis.spi.core.protocol.RemotingConnection;
import org.apache.activemq.artemis.spi.core.remoting.ConsumerContext;
import org.apache.activemq.artemis.spi.core.remoting.ReadyListener;
@ -237,14 +239,14 @@ public final class ClientSessionImpl implements ClientSessionInternal, FailureLi
@Override
public void createQueue(final SimpleString address, final SimpleString queueName) throws ActiveMQException {
internalCreateQueue(address, queueName, null, false, false, false);
createQueue(address, ActiveMQDefaultConfiguration.getDefaultRoutingType(), queueName);
}
@Override
public void createQueue(final SimpleString address,
final SimpleString queueName,
final boolean durable) throws ActiveMQException {
internalCreateQueue(address, queueName, null, durable, false, false);
createQueue(address, ActiveMQDefaultConfiguration.getDefaultRoutingType(), queueName, durable);
}
@Override
@ -258,7 +260,7 @@ public final class ClientSessionImpl implements ClientSessionInternal, FailureLi
public void createSharedQueue(SimpleString address,
SimpleString queueName,
boolean durable) throws ActiveMQException {
createSharedQueue(address, queueName, null, durable);
createSharedQueue(address, ActiveMQDefaultConfiguration.getDefaultRoutingType(), queueName, null, durable);
}
@Override
@ -266,36 +268,35 @@ public final class ClientSessionImpl implements ClientSessionInternal, FailureLi
SimpleString queueName,
SimpleString filterString,
boolean durable) throws ActiveMQException {
checkClosed();
startCall();
try {
sessionContext.createSharedQueue(address, queueName, filterString, durable);
} finally {
endCall();
}
createSharedQueue(address, ActiveMQDefaultConfiguration.getDefaultRoutingType(), queueName, filterString, durable);
}
@Override
public void createAddress(final SimpleString address, final boolean multicast, boolean autoCreated) throws ActiveMQException {
public void createAddress(final SimpleString address, Set<RoutingType> routingTypes, boolean autoCreated) throws ActiveMQException {
checkClosed();
startCall();
try {
sessionContext.createAddress(address, multicast, autoCreated);
sessionContext.createAddress(address, routingTypes, autoCreated);
} finally {
endCall();
}
}
@Override
public void createAddress(final SimpleString address, RoutingType routingType, boolean autoCreated) throws ActiveMQException {
Set<RoutingType> routingTypes = new HashSet<>();
routingTypes.add(routingType);
createAddress(address, routingTypes, autoCreated);
}
@Override
public void createQueue(final SimpleString address,
final SimpleString queueName,
final SimpleString filterString,
final boolean durable) throws ActiveMQException {
internalCreateQueue(address, queueName, filterString, durable, false, false);
createQueue(address, ActiveMQDefaultConfiguration.getDefaultRoutingType(), queueName, filterString,
durable);
}
@Override
@ -303,7 +304,10 @@ public final class ClientSessionImpl implements ClientSessionInternal, FailureLi
final String queueName,
final String filterString,
final boolean durable) throws ActiveMQException {
createQueue(SimpleString.toSimpleString(address), SimpleString.toSimpleString(queueName), SimpleString.toSimpleString(filterString), durable);
createQueue(SimpleString.toSimpleString(address),
SimpleString.toSimpleString(queueName),
SimpleString.toSimpleString(filterString),
durable);
}
@Override
@ -312,7 +316,9 @@ public final class ClientSessionImpl implements ClientSessionInternal, FailureLi
final SimpleString filterString,
final boolean durable,
final boolean autoCreated) throws ActiveMQException {
internalCreateQueue(address, queueName, filterString, durable, false, autoCreated);
createQueue(address, ActiveMQDefaultConfiguration.getDefaultRoutingType(), queueName, filterString,
durable,
autoCreated);
}
@Override
@ -326,28 +332,257 @@ public final class ClientSessionImpl implements ClientSessionInternal, FailureLi
@Override
public void createTemporaryQueue(final SimpleString address, final SimpleString queueName) throws ActiveMQException {
internalCreateQueue(address, queueName, null, false, true, false);
createTemporaryQueue(address, ActiveMQDefaultConfiguration.getDefaultRoutingType(), queueName);
}
@Override
public void createTemporaryQueue(final String address, final String queueName) throws ActiveMQException {
internalCreateQueue(SimpleString.toSimpleString(address), SimpleString.toSimpleString(queueName), null, false, true, false);
createTemporaryQueue(SimpleString.toSimpleString(address), SimpleString.toSimpleString(queueName));
}
@Override
public void createTemporaryQueue(final SimpleString address,
final SimpleString queueName,
final SimpleString filter) throws ActiveMQException {
internalCreateQueue(address, queueName, filter, false, true, false);
createTemporaryQueue(address, ActiveMQDefaultConfiguration.getDefaultRoutingType(), queueName, filter);
}
@Override
public void createTemporaryQueue(final String address,
final String queueName,
final String filter) throws ActiveMQException {
internalCreateQueue(SimpleString.toSimpleString(address), SimpleString.toSimpleString(queueName), SimpleString.toSimpleString(filter), false, true, false);
createTemporaryQueue(address, ActiveMQDefaultConfiguration.getDefaultRoutingType(), queueName, filter);
}
/** New Queue API **/
@Override
public void createQueue(final SimpleString address,
final RoutingType routingType,
final SimpleString queueName,
final SimpleString filterString,
final boolean durable,
final boolean autoCreated) throws ActiveMQException {
internalCreateQueue(address,
queueName, routingType,
filterString,
durable,
false,
ActiveMQDefaultConfiguration.getDefaultMaxQueueConsumers(),
ActiveMQDefaultConfiguration.getDefaultDeleteQueueOnNoConsumers(),
autoCreated);
}
@Override
public void createQueue(final String address, final RoutingType routingType, final String queueName, final String filterString,
final boolean durable,
final boolean autoCreated) throws ActiveMQException {
createQueue(SimpleString.toSimpleString(address),
SimpleString.toSimpleString(queueName),
SimpleString.toSimpleString(filterString),
durable,
autoCreated);
}
@Override
public void createTemporaryQueue(final SimpleString address,
final RoutingType routingType,
final SimpleString queueName) throws ActiveMQException {
internalCreateQueue(address,
queueName, routingType,
null,
false,
true,
ActiveMQDefaultConfiguration.getDefaultMaxQueueConsumers(),
ActiveMQDefaultConfiguration.getDefaultDeleteQueueOnNoConsumers(),
false);
}
@Override
public void createTemporaryQueue(final String address, final RoutingType routingType, final String queueName) throws ActiveMQException {
createTemporaryQueue(SimpleString.toSimpleString(address), routingType, SimpleString.toSimpleString(queueName));
}
@Override
public void createTemporaryQueue(final SimpleString address,
final RoutingType routingType,
final SimpleString queueName,
final SimpleString filter) throws ActiveMQException {
internalCreateQueue(address,
queueName, routingType,
filter,
false,
true,
ActiveMQDefaultConfiguration.getDefaultMaxQueueConsumers(),
ActiveMQDefaultConfiguration.getDefaultDeleteQueueOnNoConsumers(),
false);
}
@Override
public void createTemporaryQueue(final String address, final RoutingType routingType, final String queueName, final String filter) throws ActiveMQException {
createTemporaryQueue(SimpleString.toSimpleString(address), routingType, SimpleString.toSimpleString(queueName));
}
/**
* Creates a <em>non-temporary</em> queue.
*
* @param address the queue will be bound to this address
* @param routingType the delivery mode for this queue, MULTICAST or ANYCAST
* @param queueName the name of the queue
* @param durable whether the queue is durable or not
* @throws ActiveMQException in an exception occurs while creating the queue
*/
@Override
public void createQueue(SimpleString address, RoutingType routingType, SimpleString queueName, boolean durable) throws ActiveMQException {
internalCreateQueue(address,
queueName, routingType,
null,
durable,
false,
ActiveMQDefaultConfiguration.getDefaultMaxQueueConsumers(),
ActiveMQDefaultConfiguration.getDefaultDeleteQueueOnNoConsumers(),
false);
}
/**
* Creates a transient queue. A queue that will exist as long as there are consumers. When the last consumer is closed the queue will be deleted
* <p>
* Notice: you will get an exception if the address or the filter doesn't match to an already existent queue
*
* @param address the queue will be bound to this address
* @param routingType the delivery mode for this queue, MULTICAST or ANYCAST
* @param queueName the name of the queue
* @param durable if the queue is durable
* @throws ActiveMQException in an exception occurs while creating the queue
*/
@Override
public void createSharedQueue(SimpleString address, RoutingType routingType, SimpleString queueName, boolean durable) throws ActiveMQException {
createSharedQueue(address, routingType, queueName, null, durable);
}
/**
* Creates a transient queue. A queue that will exist as long as there are consumers. When the last consumer is closed the queue will be deleted
* <p>
* Notice: you will get an exception if the address or the filter doesn't match to an already existent queue
*
* @param address the queue will be bound to this address
* @param routingType the delivery mode for this queue, MULTICAST or ANYCAST
* @param queueName the name of the queue
* @param filter whether the queue is durable or not
* @param durable if the queue is durable
* @throws ActiveMQException in an exception occurs while creating the queue
*/
@Override
public void createSharedQueue(SimpleString address, RoutingType routingType, SimpleString queueName, SimpleString filter,
boolean durable) throws ActiveMQException {
checkClosed();
startCall();
try {
sessionContext.createSharedQueue(address, queueName, routingType, filter, durable);
} finally {
endCall();
}
}
/**
* Creates a <em>non-temporary</em> queue.
*
* @param address the queue will be bound to this address
* @param routingType the delivery mode for this queue, MULTICAST or ANYCAST
* @param queueName the name of the queue
* @param durable whether the queue is durable or not
* @throws ActiveMQException in an exception occurs while creating the queue
*/
@Override
public void createQueue(String address, RoutingType routingType, String queueName, boolean durable) throws ActiveMQException {
createQueue(SimpleString.toSimpleString(address), routingType, SimpleString.toSimpleString(queueName), durable);
}
/**
* Creates a <em>non-temporary</em> queue <em>non-durable</em> queue.
*
* @param address the queue will be bound to this address
* @param routingType the delivery mode for this queue, MULTICAST or ANYCAST
* @param queueName the name of the queue
* @throws ActiveMQException in an exception occurs while creating the queue
*/
@Override
public void createQueue(String address, RoutingType routingType, String queueName) throws ActiveMQException {
internalCreateQueue(SimpleString.toSimpleString(address),
SimpleString.toSimpleString(queueName), routingType,
null,
false,
true,
ActiveMQDefaultConfiguration.getDefaultMaxQueueConsumers(),
ActiveMQDefaultConfiguration.getDefaultDeleteQueueOnNoConsumers(),
false);
}
/**
* Creates a <em>non-temporary</em> queue <em>non-durable</em> queue.
*
* @param address the queue will be bound to this address
* @param routingType the delivery mode for this queue, MULTICAST or ANYCAST
* @param queueName the name of the queue
* @throws ActiveMQException in an exception occurs while creating the queue
*/
@Override
public void createQueue(SimpleString address, RoutingType routingType, SimpleString queueName) throws ActiveMQException {
internalCreateQueue(address,
queueName,
routingType,
null,
true,
false,
ActiveMQDefaultConfiguration.getDefaultMaxQueueConsumers(),
ActiveMQDefaultConfiguration.getDefaultDeleteQueueOnNoConsumers(),
false);
}
/**
* Creates a <em>non-temporary</em> queue.
*
* @param address the queue will be bound to this address
* @param routingType the delivery mode for this queue, MULTICAST or ANYCAST
* @param queueName the name of the queue
* @param filter only messages which match this filter will be put in the queue
* @param durable whether the queue is durable or not
* @throws ActiveMQException in an exception occurs while creating the queue
*/
@Override
public void createQueue(SimpleString address, RoutingType routingType, SimpleString queueName, SimpleString filter,
boolean durable) throws ActiveMQException {
internalCreateQueue(address,
queueName,
routingType,
filter,
durable,
!durable,
ActiveMQDefaultConfiguration.getDefaultMaxQueueConsumers(),
ActiveMQDefaultConfiguration.getDefaultDeleteQueueOnNoConsumers(),
false);
}
/**
* Creates a <em>non-temporary</em>queue.
*
* @param address the queue will be bound to this address
* @param routingType the delivery mode for this queue, MULTICAST or ANYCAST
* @param queueName the name of the queue
* @param filter only messages which match this filter will be put in the queue
* @param durable whether the queue is durable or not
* @throws ActiveMQException in an exception occurs while creating the queue
*/
@Override
public void createQueue(String address, RoutingType routingType, String queueName, String filter, boolean durable) throws ActiveMQException {
createQueue(SimpleString.toSimpleString(address), routingType, SimpleString.toSimpleString(queueName), SimpleString.toSimpleString(filter),
durable);
}
@Override
public void deleteQueue(final SimpleString queueName) throws ActiveMQException {
checkClosed();
@ -1567,9 +1802,12 @@ public final class ClientSessionImpl implements ClientSessionInternal, FailureLi
private void internalCreateQueue(final SimpleString address,
final SimpleString queueName,
final RoutingType routingType,
final SimpleString filterString,
final boolean durable,
final boolean temp,
final int maxConsumers,
final boolean deleteOnNoConsumers,
final boolean autoCreated) throws ActiveMQException {
checkClosed();
@ -1579,7 +1817,15 @@ public final class ClientSessionImpl implements ClientSessionInternal, FailureLi
startCall();
try {
sessionContext.createQueue(address, queueName, filterString, durable, temp, autoCreated);
sessionContext.createQueue(address,
routingType,
queueName,
filterString,
durable,
temp,
ActiveMQDefaultConfiguration.getDefaultMaxQueueConsumers(),
ActiveMQDefaultConfiguration.getDefaultDeleteQueueOnNoConsumers(),
autoCreated);
} finally {
endCall();
}

View File

@ -24,8 +24,10 @@ import java.security.PrivilegedAction;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.Executor;
import org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration;
import org.apache.activemq.artemis.api.core.ActiveMQBuffer;
import org.apache.activemq.artemis.api.core.ActiveMQException;
import org.apache.activemq.artemis.api.core.ActiveMQExceptionType;
@ -52,9 +54,9 @@ import org.apache.activemq.artemis.core.protocol.core.Packet;
import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.ActiveMQExceptionMessage;
import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.CreateAddressMessage;
import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.CreateQueueMessage;
import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.CreateQueueMessage_V2;
import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.CreateQueueMessage_V3;
import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.CreateSessionMessage;
import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.CreateSharedQueueMessage;
import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.CreateSharedQueueMessage_V2;
import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.DisconnectConsumerMessage;
import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.DisconnectConsumerWithKillMessage;
import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.ReattachSessionMessage;
@ -100,6 +102,7 @@ import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.SessionXAR
import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.SessionXASetTimeoutMessage;
import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.SessionXASetTimeoutResponseMessage;
import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.SessionXAStartMessage;
import org.apache.activemq.artemis.core.server.RoutingType;
import org.apache.activemq.artemis.spi.core.protocol.RemotingConnection;
import org.apache.activemq.artemis.spi.core.remoting.Connection;
import org.apache.activemq.artemis.spi.core.remoting.ReadyListener;
@ -240,9 +243,18 @@ public class ActiveMQSessionContext extends SessionContext {
@Override
public void createSharedQueue(SimpleString address,
SimpleString queueName,
RoutingType routingType,
SimpleString filterString,
boolean durable) throws ActiveMQException {
sessionChannel.sendBlocking(new CreateSharedQueueMessage(address, queueName, filterString, durable, true), PacketImpl.NULL_RESPONSE);
sessionChannel.sendBlocking(new CreateSharedQueueMessage_V2(address, queueName, routingType, filterString, durable, true), PacketImpl.NULL_RESPONSE);
}
@Override
public void createSharedQueue(SimpleString address,
SimpleString queueName,
SimpleString filterString,
boolean durable) throws ActiveMQException {
createSharedQueue(address, queueName, null, filterString, durable);
}
@Override
@ -585,11 +597,14 @@ public class ActiveMQSessionContext extends SessionContext {
}
@Override
public void createAddress(SimpleString address, final boolean multicast, final boolean autoCreated) throws ActiveMQException {
CreateAddressMessage request = new CreateAddressMessage(address, multicast, autoCreated, true);
public void createAddress(SimpleString address,
Set<RoutingType> routingTypes,
final boolean autoCreated) throws ActiveMQException {
CreateAddressMessage request = new CreateAddressMessage(address, routingTypes, autoCreated, true);
sessionChannel.sendBlocking(request, PacketImpl.NULL_RESPONSE);
}
@Deprecated
@Override
public void createQueue(SimpleString address,
SimpleString queueName,
@ -597,7 +612,20 @@ public class ActiveMQSessionContext extends SessionContext {
boolean durable,
boolean temp,
boolean autoCreated) throws ActiveMQException {
CreateQueueMessage request = new CreateQueueMessage_V2(address, queueName, filterString, durable, temp, autoCreated, true);
createQueue(address, ActiveMQDefaultConfiguration.getDefaultRoutingType(), queueName, filterString, durable, temp, ActiveMQDefaultConfiguration.getDefaultMaxQueueConsumers(), ActiveMQDefaultConfiguration.getDefaultDeleteQueueOnNoConsumers(), autoCreated);
}
@Override
public void createQueue(SimpleString address,
RoutingType routingType,
SimpleString queueName,
SimpleString filterString,
boolean durable,
boolean temp,
int maxConsumers,
boolean deleteOnNoConsumers,
boolean autoCreated) throws ActiveMQException {
CreateQueueMessage request = new CreateQueueMessage_V3(address, queueName, routingType, filterString, durable, temp, maxConsumers, deleteOnNoConsumers, autoCreated, true);
sessionChannel.sendBlocking(request, PacketImpl.NULL_RESPONSE);
}
@ -682,6 +710,7 @@ public class ActiveMQSessionContext extends SessionContext {
// they are defined in broker.xml
// This allows e.g. JMS non durable subs and temporary queues to continue to be used after failover
if (!queueInfo.isDurable()) {
// TODO (mtaylor) QueueInfo needs updating to include new parameters, this method should pass in del mode
CreateQueueMessage createQueueRequest = new CreateQueueMessage(queueInfo.getAddress(), queueInfo.getName(), queueInfo.getFilterString(), false, queueInfo.isTemporary(), false);
sendPacketWithoutLock(sessionChannel, createQueueRequest);

View File

@ -30,9 +30,11 @@ import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.ClusterTop
import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.CreateAddressMessage;
import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.CreateQueueMessage;
import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.CreateQueueMessage_V2;
import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.CreateQueueMessage_V3;
import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.CreateSessionMessage;
import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.CreateSessionResponseMessage;
import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.CreateSharedQueueMessage;
import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.CreateSharedQueueMessage_V2;
import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.DisconnectConsumerMessage;
import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.DisconnectMessage;
import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.DisconnectMessage_V2;
@ -93,7 +95,9 @@ import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.CRE
import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.CREATE_ADDRESS;
import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.CREATE_QUEUE;
import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.CREATE_QUEUE_V2;
import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.CREATE_QUEUE_V3;
import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.CREATE_SHARED_QUEUE;
import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.CREATE_SHARED_QUEUE_V2;
import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.DELETE_QUEUE;
import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.DISCONNECT;
import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.DISCONNECT_CONSUMER;
@ -251,10 +255,18 @@ public abstract class PacketDecoder implements Serializable {
packet = new CreateQueueMessage_V2();
break;
}
case CREATE_QUEUE_V3: {
packet = new CreateQueueMessage_V3();
break;
}
case CREATE_SHARED_QUEUE: {
packet = new CreateSharedQueueMessage();
break;
}
case CREATE_SHARED_QUEUE_V2: {
packet = new CreateSharedQueueMessage_V2();
break;
}
case DELETE_QUEUE: {
packet = new SessionDeleteQueueMessage();
break;

View File

@ -253,6 +253,10 @@ public class PacketImpl implements Packet {
public static final byte CREATE_QUEUE_V2 = -12;
public static final byte CREATE_QUEUE_V3 = -13;
public static final byte CREATE_SHARED_QUEUE_V2 = -14;
// Static --------------------------------------------------------
public PacketImpl(final byte type) {

View File

@ -16,28 +16,32 @@
*/
package org.apache.activemq.artemis.core.protocol.core.impl.wireformat;
import java.util.HashSet;
import java.util.Set;
import org.apache.activemq.artemis.api.core.ActiveMQBuffer;
import org.apache.activemq.artemis.api.core.SimpleString;
import org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl;
import org.apache.activemq.artemis.core.server.RoutingType;
public class CreateAddressMessage extends PacketImpl {
private SimpleString address;
private boolean multicast;
private Set<RoutingType> routingTypes;
private boolean autoCreated;
private boolean requiresResponse;
public CreateAddressMessage(final SimpleString address,
final boolean multicast,
Set<RoutingType> routingTypes,
final boolean autoCreated,
final boolean requiresResponse) {
this();
this.address = address;
this.multicast = multicast;
this.routingTypes = routingTypes;
this.autoCreated = autoCreated;
this.requiresResponse = requiresResponse;
}
@ -52,7 +56,7 @@ public class CreateAddressMessage extends PacketImpl {
public String toString() {
StringBuffer buff = new StringBuffer(getParentString());
buff.append(", address=" + address);
buff.append(", multicast=" + multicast);
buff.append(", routingTypes=" + routingTypes);
buff.append(", autoCreated=" + autoCreated);
buff.append("]");
return buff.toString();
@ -62,10 +66,6 @@ public class CreateAddressMessage extends PacketImpl {
return address;
}
public boolean isMulticast() {
return multicast;
}
public boolean isRequiresResponse() {
return requiresResponse;
}
@ -78,10 +78,21 @@ public class CreateAddressMessage extends PacketImpl {
this.address = address;
}
public Set<RoutingType> getRoutingTypes() {
return routingTypes;
}
public void setRoutingTypes(Set<RoutingType> routingTypes) {
this.routingTypes = routingTypes;
}
@Override
public void encodeRest(final ActiveMQBuffer buffer) {
buffer.writeSimpleString(address);
buffer.writeBoolean(multicast);
buffer.writeInt(routingTypes.size());
for (RoutingType routingType : routingTypes) {
buffer.writeByte(routingType.getType());
}
buffer.writeBoolean(requiresResponse);
buffer.writeBoolean(autoCreated);
}
@ -89,7 +100,11 @@ public class CreateAddressMessage extends PacketImpl {
@Override
public void decodeRest(final ActiveMQBuffer buffer) {
address = buffer.readSimpleString();
multicast = buffer.readBoolean();
int routingTypeSetSize = buffer.readInt();
routingTypes = new HashSet<>(routingTypeSetSize);
for (int i = 0; i < routingTypeSetSize; i++) {
routingTypes.add(RoutingType.getType(buffer.readByte()));
}
requiresResponse = buffer.readBoolean();
autoCreated = buffer.readBoolean();
}
@ -99,7 +114,7 @@ public class CreateAddressMessage extends PacketImpl {
final int prime = 31;
int result = super.hashCode();
result = prime * result + ((address == null) ? 0 : address.hashCode());
result = prime * result + (multicast ? 1231 : 1237);
result = prime * result + (routingTypes.hashCode());
result = prime * result + (autoCreated ? 1231 : 1237);
result = prime * result + (requiresResponse ? 1231 : 1237);
return result;
@ -119,7 +134,7 @@ public class CreateAddressMessage extends PacketImpl {
return false;
} else if (!address.equals(other.address))
return false;
if (multicast != other.multicast)
if (routingTypes.equals(other.routingTypes))
return false;
if (autoCreated != other.autoCreated)
return false;

View File

@ -21,7 +21,7 @@ import org.apache.activemq.artemis.api.core.SimpleString;
public class CreateQueueMessage_V2 extends CreateQueueMessage {
private boolean autoCreated;
protected boolean autoCreated;
public CreateQueueMessage_V2(final SimpleString address,
final SimpleString queueName,
@ -45,6 +45,10 @@ public class CreateQueueMessage_V2 extends CreateQueueMessage {
super(CREATE_QUEUE_V2);
}
public CreateQueueMessage_V2(byte packet) {
super(packet);
}
// Public --------------------------------------------------------
@Override

View File

@ -0,0 +1,134 @@
/*
* 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.protocol.core.impl.wireformat;
import org.apache.activemq.artemis.api.core.ActiveMQBuffer;
import org.apache.activemq.artemis.api.core.SimpleString;
import org.apache.activemq.artemis.core.server.RoutingType;
public class CreateQueueMessage_V3 extends CreateQueueMessage_V2 {
private RoutingType routingType;
private int maxConsumers;
private boolean deleteOnNoConsumers;
public CreateQueueMessage_V3(final SimpleString address,
final SimpleString queueName,
final RoutingType routingType,
final SimpleString filterString,
final boolean durable,
final boolean temporary,
final int maxConsumers,
final boolean deleteOnNoConsumers,
final boolean autoCreated,
final boolean requiresResponse) {
this();
this.address = address;
this.queueName = queueName;
this.filterString = filterString;
this.durable = durable;
this.temporary = temporary;
this.autoCreated = autoCreated;
this.requiresResponse = requiresResponse;
this.routingType = routingType;
this.maxConsumers = maxConsumers;
this.deleteOnNoConsumers = deleteOnNoConsumers;
}
public CreateQueueMessage_V3() {
super(CREATE_QUEUE_V3);
}
// Public --------------------------------------------------------
@Override
public String toString() {
StringBuffer buff = new StringBuffer(super.getParentString());
buff.append(", routingType=" + routingType);
buff.append(", maxConsumers=" + maxConsumers);
buff.append(", deleteOnNoConsumers=" + deleteOnNoConsumers);
buff.append("]");
return buff.toString();
}
public RoutingType getRoutingType() {
return routingType;
}
public void setRoutingType(RoutingType routingType) {
this.routingType = routingType;
}
public int getMaxConsumers() {
return maxConsumers;
}
public void setMaxConsumers(int maxConsumers) {
this.maxConsumers = maxConsumers;
}
public boolean isDeleteOnNoConsumers() {
return deleteOnNoConsumers;
}
public void setDeleteOnNoConsumers(boolean deleteOnNoConsumers) {
this.deleteOnNoConsumers = deleteOnNoConsumers;
}
@Override
public void encodeRest(final ActiveMQBuffer buffer) {
super.encodeRest(buffer);
buffer.writeByte(routingType.getType());
buffer.writeInt(maxConsumers);
buffer.writeBoolean(deleteOnNoConsumers);
}
@Override
public void decodeRest(final ActiveMQBuffer buffer) {
super.decodeRest(buffer);
routingType = RoutingType.getType(buffer.readByte());
maxConsumers = buffer.readInt();
deleteOnNoConsumers = buffer.readBoolean();
}
@Override
public int hashCode() {
final int prime = 31;
int result = super.hashCode();
result = prime * result + (routingType.getType());
result = prime * result + (maxConsumers);
result = prime * result + (deleteOnNoConsumers ? 1231 : 1237);
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (!super.equals(obj))
return false;
if (!(obj instanceof CreateQueueMessage_V3))
return false;
CreateQueueMessage_V3 other = (CreateQueueMessage_V3) obj;
if (autoCreated != other.autoCreated)
return false;
return true;
}
}

View File

@ -22,15 +22,15 @@ import org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl;
public class CreateSharedQueueMessage extends PacketImpl {
private SimpleString address;
protected SimpleString address;
private SimpleString queueName;
protected SimpleString queueName;
private SimpleString filterString;
protected SimpleString filterString;
private boolean durable;
protected boolean durable;
private boolean requiresResponse;
protected boolean requiresResponse;
public CreateSharedQueueMessage(final SimpleString address,
final SimpleString queueName,
@ -47,7 +47,11 @@ public class CreateSharedQueueMessage extends PacketImpl {
}
public CreateSharedQueueMessage() {
super(CREATE_SHARED_QUEUE);
this(CREATE_SHARED_QUEUE);
}
public CreateSharedQueueMessage(byte packetType) {
super(packetType);
}
// Public --------------------------------------------------------

View File

@ -0,0 +1,134 @@
/*
* 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.protocol.core.impl.wireformat;
import org.apache.activemq.artemis.api.core.ActiveMQBuffer;
import org.apache.activemq.artemis.api.core.SimpleString;
import org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl;
import org.apache.activemq.artemis.core.server.RoutingType;
public class CreateSharedQueueMessage_V2 extends CreateSharedQueueMessage {
private RoutingType routingType;
public CreateSharedQueueMessage_V2(final SimpleString address,
final SimpleString queueName,
final RoutingType routingType,
final SimpleString filterString,
final boolean durable,
final boolean requiresResponse) {
this();
this.address = address;
this.queueName = queueName;
this.filterString = filterString;
this.durable = durable;
this.requiresResponse = requiresResponse;
this.routingType = routingType;
}
public CreateSharedQueueMessage_V2() {
super(CREATE_SHARED_QUEUE_V2);
}
public RoutingType getRoutingType() {
return routingType;
}
public void setRoutingType(RoutingType routingType) {
this.routingType = routingType;
}
@Override
public String toString() {
StringBuffer buff = new StringBuffer(getParentString());
buff.append(", address=" + address);
buff.append(", queueName=" + queueName);
buff.append(", filterString=" + filterString);
buff.append(", durable=" + durable);
buff.append(", requiresResponse=" + requiresResponse);
buff.append("]");
return buff.toString();
}
@Override
public void encodeRest(final ActiveMQBuffer buffer) {
buffer.writeSimpleString(address);
buffer.writeSimpleString(queueName);
buffer.writeNullableSimpleString(filterString);
buffer.writeBoolean(durable);
buffer.writeByte(routingType.getType());
buffer.writeBoolean(requiresResponse);
}
@Override
public void decodeRest(final ActiveMQBuffer buffer) {
address = buffer.readSimpleString();
queueName = buffer.readSimpleString();
filterString = buffer.readNullableSimpleString();
durable = buffer.readBoolean();
routingType = RoutingType.getType(buffer.readByte());
requiresResponse = buffer.readBoolean();
}
@Override
public int hashCode() {
final int prime = 31;
int result = super.hashCode();
result = prime * result + ((address == null) ? 0 : address.hashCode());
result = prime * result + ((filterString == null) ? 0 : filterString.hashCode());
result = prime * result + ((queueName == null) ? 0 : queueName.hashCode());
result = prime * result + (durable ? 1231 : 1237);
result = prime * result + routingType.getType();
result = prime * result + (requiresResponse ? 1231 : 1237);
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (!super.equals(obj))
return false;
if (!(obj instanceof CreateSharedQueueMessage_V2))
return false;
CreateSharedQueueMessage_V2 other = (CreateSharedQueueMessage_V2) obj;
if (address == null) {
if (other.address != null)
return false;
} else if (!address.equals(other.address))
return false;
if (filterString == null) {
if (other.filterString != null)
return false;
} else if (!filterString.equals(other.filterString))
return false;
if (queueName == null) {
if (other.queueName != null)
return false;
} else if (!queueName.equals(other.queueName))
return false;
if (durable != other.durable)
return false;
if (routingType != other.routingType)
return false;
if (requiresResponse != other.requiresResponse)
return false;
return true;
}
}

View File

@ -0,0 +1,44 @@
/*
* 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;
public enum RoutingType {
MULTICAST, ANYCAST;
public byte getType() {
switch (this) {
case MULTICAST:
return 0;
case ANYCAST:
return 1;
default:
return -1;
}
}
public static RoutingType getType(byte type) {
switch (type) {
case 0:
return MULTICAST;
case 1:
return ANYCAST;
default:
return null;
}
}
}

View File

@ -19,6 +19,7 @@ package org.apache.activemq.artemis.spi.core.remoting;
import javax.transaction.xa.XAException;
import javax.transaction.xa.Xid;
import java.util.HashMap;
import java.util.Set;
import java.util.concurrent.Executor;
import org.apache.activemq.artemis.api.core.ActiveMQException;
@ -33,6 +34,7 @@ import org.apache.activemq.artemis.core.client.impl.ClientMessageInternal;
import org.apache.activemq.artemis.core.client.impl.ClientProducerCreditsImpl;
import org.apache.activemq.artemis.core.client.impl.ClientSessionInternal;
import org.apache.activemq.artemis.core.message.impl.MessageInternal;
import org.apache.activemq.artemis.core.server.RoutingType;
import org.apache.activemq.artemis.spi.core.protocol.RemotingConnection;
import org.apache.activemq.artemis.utils.IDGenerator;
import org.apache.activemq.artemis.utils.SimpleIDGenerator;
@ -64,7 +66,7 @@ public abstract class SessionContext {
public abstract int getReconnectID();
/**
* it will eather reattach or reconnect, preferably reattaching it.
* it will either reattach or reconnect, preferably reattaching it.
*
* @param newConnection
* @return true if it was possible to reattach
@ -159,15 +161,34 @@ public abstract class SessionContext {
public abstract void setSendAcknowledgementHandler(final SendAcknowledgementHandler handler);
/**
* Creates a shared queue using the routing type set by the Address. If the Address supports more than one type of delivery
* then the default delivery mode (MULTICAST) is used.
*
* @param address
* @param queueName
* @param routingType
* @param filterString
* @param durable
* @throws ActiveMQException
*/
public abstract void createSharedQueue(SimpleString address,
SimpleString queueName,
RoutingType routingType,
SimpleString filterString,
boolean durable) throws ActiveMQException;
public abstract void createSharedQueue(SimpleString address,
SimpleString queueName,
SimpleString filterString,
boolean durable) throws ActiveMQException;
public abstract void deleteQueue(SimpleString queueName) throws ActiveMQException;
public abstract void createAddress(SimpleString address, boolean multicast, boolean autoCreated) throws ActiveMQException;
public abstract void createAddress(SimpleString address, Set<RoutingType> routingTypes, boolean autoCreated) throws ActiveMQException;
@Deprecated
public abstract void createQueue(SimpleString address,
SimpleString queueName,
SimpleString filterString,
@ -175,6 +196,16 @@ public abstract class SessionContext {
boolean temp,
boolean autoCreated) throws ActiveMQException;
public abstract void createQueue(SimpleString address,
RoutingType routingType,
SimpleString queueName,
SimpleString filterString,
boolean durable,
boolean temp,
int maxConsumers,
boolean deleteOnNoConsumers,
boolean autoCreated) throws ActiveMQException;
public abstract ClientSession.QueueQuery queueQuery(SimpleString queueName) throws ActiveMQException;
public abstract void forceDelivery(ClientConsumer consumer, long sequence) throws ActiveMQException;

View File

@ -41,6 +41,7 @@ import org.apache.activemq.artemis.api.core.client.ClientMessage;
import org.apache.activemq.artemis.api.core.client.ClientProducer;
import org.apache.activemq.artemis.api.core.client.ClientSession;
import org.apache.activemq.artemis.api.core.client.SendAcknowledgementHandler;
import org.apache.activemq.artemis.core.server.RoutingType;
import org.apache.activemq.artemis.utils.UUID;
import org.apache.activemq.artemis.utils.UUIDGenerator;
@ -405,15 +406,15 @@ public class ActiveMQMessageProducer implements MessageProducer, QueueSender, To
if (!query.isExists()) {
if (destination.isQueue() && query.isAutoCreateJmsQueues()) {
clientSession.createAddress(address, false, true);
clientSession.createAddress(address, RoutingType.ANYCAST, true);
if (destination.isTemporary()) {
// TODO is it right to use the address for the queue name here?
clientSession.createTemporaryQueue(address, address);
clientSession.createTemporaryQueue(address, RoutingType.ANYCAST, address);
} else {
clientSession.createQueue(address, address, null, true, true);
clientSession.createQueue(address, RoutingType.ANYCAST, address, null, true, true);
}
} else if (!destination.isQueue() && query.isAutoCreateJmsTopics()) {
clientSession.createAddress(address, true, true);
clientSession.createAddress(address, RoutingType.MULTICAST, true);
} else if ((destination.isQueue() && !query.isAutoCreateJmsQueues()) || (!destination.isQueue() && !query.isAutoCreateJmsTopics())) {
throw new InvalidDestinationException("Destination " + address + " does not exist");
}

View File

@ -56,6 +56,7 @@ import org.apache.activemq.artemis.api.core.client.ClientProducer;
import org.apache.activemq.artemis.api.core.client.ClientSession;
import org.apache.activemq.artemis.api.core.client.ClientSession.AddressQuery;
import org.apache.activemq.artemis.api.core.client.ClientSession.QueueQuery;
import org.apache.activemq.artemis.core.server.RoutingType;
import org.apache.activemq.artemis.selector.filter.FilterException;
import org.apache.activemq.artemis.selector.impl.SelectorParser;
import org.apache.activemq.artemis.utils.SelectorTranslator;
@ -302,10 +303,10 @@ public class ActiveMQSession implements QueueSession, TopicSession {
if (!response.isExists()) {
if (jbd.isQueue() && response.isAutoCreateJmsQueues()) {
// perhaps just relying on the broker to do it is simplest (i.e. deleteOnNoConsumers)
session.createAddress(jbd.getSimpleAddress(), false, true);
session.createQueue(jbd.getSimpleAddress(), jbd.getSimpleAddress(), null, true, true);
session.createAddress(jbd.getSimpleAddress(), RoutingType.ANYCAST, true);
session.createQueue(jbd.getSimpleAddress(), RoutingType.ANYCAST, jbd.getSimpleAddress(), null, true, true);
} else if (!jbd.isQueue() && response.isAutoCreateJmsTopics()) {
session.createAddress(jbd.getSimpleAddress(), true, true);
session.createAddress(jbd.getSimpleAddress(), RoutingType.MULTICAST, true);
} else {
throw new InvalidDestinationException("Destination " + jbd.getName() + " does not exist");
}
@ -579,7 +580,7 @@ public class ActiveMQSession implements QueueSession, TopicSession {
if (durability == ConsumerDurability.DURABLE) {
try {
session.createSharedQueue(dest.getSimpleAddress(), queueName, coreFilterString, true);
session.createSharedQueue(dest.getSimpleAddress(), RoutingType.MULTICAST, queueName, coreFilterString, true);
} catch (ActiveMQQueueExistsException ignored) {
// We ignore this because querying and then creating the queue wouldn't be idempotent
// we could also add a parameter to ignore existence what would require a bigger work around to avoid
@ -646,7 +647,7 @@ public class ActiveMQSession implements QueueSession, TopicSession {
*/
if (!response.isExists() || !response.getQueueNames().contains(dest.getSimpleAddress())) {
if (response.isAutoCreateJmsQueues()) {
session.createQueue(dest.getSimpleAddress(), dest.getSimpleAddress(), null, true, true);
session.createQueue(dest.getSimpleAddress(), RoutingType.ANYCAST, dest.getSimpleAddress(), null, true, true);
} else {
throw new InvalidDestinationException("Destination " + dest.getName() + " does not exist");
}
@ -660,7 +661,7 @@ public class ActiveMQSession implements QueueSession, TopicSession {
if (!response.isExists()) {
if (response.isAutoCreateJmsTopics()) {
session.createAddress(dest.getSimpleAddress(), true, true);
session.createAddress(dest.getSimpleAddress(), RoutingType.MULTICAST, true);
} else {
throw new InvalidDestinationException("Topic " + dest.getName() + " does not exist");
}
@ -677,7 +678,7 @@ public class ActiveMQSession implements QueueSession, TopicSession {
queueName = new SimpleString(UUID.randomUUID().toString());
session.createTemporaryQueue(dest.getSimpleAddress(), queueName, coreFilterString);
session.createTemporaryQueue(dest.getSimpleAddress(), RoutingType.MULTICAST, queueName, coreFilterString);
consumer = session.createConsumer(queueName, null, false);
@ -699,7 +700,7 @@ public class ActiveMQSession implements QueueSession, TopicSession {
QueueQuery subResponse = session.queueQuery(queueName);
if (!subResponse.isExists()) {
session.createQueue(dest.getSimpleAddress(), queueName, coreFilterString, true);
session.createQueue(dest.getSimpleAddress(), RoutingType.MULTICAST, queueName, coreFilterString, true);
} else {
// Already exists
if (subResponse.getConsumerCount() > 0) {

View File

@ -56,7 +56,7 @@ import org.apache.activemq.artemis.core.security.Role;
import org.apache.activemq.artemis.core.server.ActivateCallback;
import org.apache.activemq.artemis.core.server.ActiveMQServer;
import org.apache.activemq.artemis.core.server.ActiveMQServerLogger;
import org.apache.activemq.artemis.core.server.Queue;
import org.apache.activemq.artemis.core.server.RoutingType;
import org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl;
import org.apache.activemq.artemis.core.server.impl.AddressInfo;
import org.apache.activemq.artemis.core.server.management.Notification;
@ -1070,9 +1070,9 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback
coreFilterString = SelectorTranslator.convertToActiveMQFilterString(selectorString);
}
server.createOrUpdateAddressInfo(new AddressInfo(SimpleString.toSimpleString(activeMQQueue.getName())).setRoutingType(AddressInfo.RoutingType.ANYCAST).setDefaultMaxQueueConsumers(-1));
server.createOrUpdateAddressInfo(new AddressInfo(SimpleString.toSimpleString(activeMQQueue.getName())).addRoutingType(RoutingType.ANYCAST));
Queue queue = server.deployQueue(SimpleString.toSimpleString(activeMQQueue.getAddress()), SimpleString.toSimpleString(activeMQQueue.getAddress()), SimpleString.toSimpleString(coreFilterString), durable, false, autoCreated);
server.deployQueue(SimpleString.toSimpleString(activeMQQueue.getAddress()), RoutingType.ANYCAST, SimpleString.toSimpleString(activeMQQueue.getAddress()), SimpleString.toSimpleString(coreFilterString), durable, false, autoCreated);
queues.put(queueName, activeMQQueue);
@ -1106,7 +1106,7 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback
// does not exist - otherwise we would not be able to distinguish from a non existent topic and one with no
// subscriptions - core has no notion of a topic
// server.deployQueue(SimpleString.toSimpleString(activeMQTopic.getAddress()), SimpleString.toSimpleString(activeMQTopic.getAddress()), SimpleString.toSimpleString(JMSServerManagerImpl.REJECT_FILTER), true, false, autoCreated);
server.createOrUpdateAddressInfo(new AddressInfo(SimpleString.toSimpleString(activeMQTopic.getAddress())));
server.createOrUpdateAddressInfo(new AddressInfo(SimpleString.toSimpleString(activeMQTopic.getAddress()), RoutingType.MULTICAST));
topics.put(topicName, activeMQTopic);

View File

@ -16,11 +16,16 @@
*/
package org.apache.activemq.artemis.junit;
import java.util.Collections;
import java.util.HashSet;
import org.apache.activemq.artemis.api.core.ActiveMQException;
import org.apache.activemq.artemis.api.core.SimpleString;
import org.apache.activemq.artemis.api.core.client.ClientConsumer;
import org.apache.activemq.artemis.api.core.client.ClientMessage;
import org.apache.activemq.artemis.api.core.client.ServerLocator;
import org.apache.activemq.artemis.core.server.RoutingType;
import org.apache.activemq.artemis.core.server.impl.AddressInfo;
/**
* A JUnit Rule that embeds an ActiveMQ Artemis ClientConsumer into a test.
@ -85,6 +90,7 @@ public class ActiveMQConsumerResource extends AbstractActiveMQClientResource {
try {
if (!session.queueQuery(queueName).isExists() && autoCreateQueue) {
log.warn("{}: queue does not exist - creating queue: address = {}, name = {}", this.getClass().getSimpleName(), queueName.toString(), queueName.toString());
session.createAddress(queueName, RoutingType.MULTICAST, true);
session.createQueue(queueName, queueName);
}
consumer = session.createConsumer(queueName, browseOnly);

View File

@ -20,6 +20,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration;
import org.apache.activemq.artemis.api.core.ActiveMQException;
import org.apache.activemq.artemis.api.core.SimpleString;
import org.apache.activemq.artemis.api.core.TransportConfiguration;
@ -39,6 +40,7 @@ import org.apache.activemq.artemis.core.remoting.impl.invm.TransportConstants;
import org.apache.activemq.artemis.core.server.ActiveMQServer;
import org.apache.activemq.artemis.core.server.BindingQueryResult;
import org.apache.activemq.artemis.core.server.Queue;
import org.apache.activemq.artemis.core.server.RoutingType;
import org.apache.activemq.artemis.core.server.embedded.EmbeddedActiveMQ;
import org.junit.rules.ExternalResource;
import org.slf4j.Logger;
@ -360,7 +362,7 @@ public class EmbeddedActiveMQResource extends ExternalResource {
boolean temporary = false;
Queue queue = null;
try {
queue = server.getActiveMQServer().createQueue(address, name, filter, isUseDurableQueue(), temporary);
queue = server.getActiveMQServer().createQueue(address, RoutingType.MULTICAST, name, filter, isUseDurableQueue(), temporary, ActiveMQDefaultConfiguration.getDefaultMaxQueueConsumers(), ActiveMQDefaultConfiguration.getDefaultDeleteQueueOnNoConsumers(), true);
} catch (Exception ex) {
throw new EmbeddedActiveMQResourceException(String.format("Failed to create queue: queueName = %s, name = %s", address.toString(), name.toString()), ex);
}
@ -379,7 +381,7 @@ public class EmbeddedActiveMQResource extends ExternalResource {
public void createSharedQueue(SimpleString address, SimpleString name, SimpleString user) {
SimpleString filter = null;
try {
server.getActiveMQServer().createSharedQueue(address, name, filter, user, isUseDurableQueue());
server.getActiveMQServer().createSharedQueue(address, RoutingType.MULTICAST, name, filter, user, isUseDurableQueue());
} catch (Exception ex) {
throw new EmbeddedActiveMQResourceException(String.format("Failed to create shared queue: queueName = %s, name = %s, user = %s", address.toString(), name.toString(), user.toString()), ex);
}

View File

@ -26,6 +26,7 @@ import io.netty.handler.codec.mqtt.MqttTopicSubscription;
import org.apache.activemq.artemis.api.core.FilterConstants;
import org.apache.activemq.artemis.api.core.SimpleString;
import org.apache.activemq.artemis.core.server.ActiveMQMessageBundle;
import org.apache.activemq.artemis.core.server.RoutingType;
import org.apache.activemq.artemis.core.server.Queue;
import org.apache.activemq.artemis.core.server.ServerConsumer;
import org.apache.activemq.artemis.core.server.impl.AddressInfo;
@ -93,7 +94,7 @@ public class MQTTSubscriptionManager {
Queue q = session.getServer().locateQueue(queue);
if (q == null) {
q = session.getServerSession().createQueue(new SimpleString(address), queue, managementFilter, false, MQTTUtil.DURABLE_MESSAGES && qos >= 0, -1, false, true);
q = session.getServerSession().createQueue(new SimpleString(address), queue, RoutingType.MULTICAST, managementFilter, false, MQTTUtil.DURABLE_MESSAGES && qos >= 0, true);
} else {
if (q.isDeleteOnNoConsumers()) {
throw ActiveMQMessageBundle.BUNDLE.invalidQueueConfiguration(q.getAddress(), q.getName(), "deleteOnNoConsumers", false, true);
@ -122,8 +123,8 @@ public class MQTTSubscriptionManager {
String coreAddress = MQTTUtil.convertMQTTAddressFilterToCore(topic);
AddressInfo addressInfo = session.getServer().getAddressInfo(new SimpleString(coreAddress));
if (addressInfo != null && addressInfo.getRoutingType() != AddressInfo.RoutingType.MULTICAST) {
throw ActiveMQMessageBundle.BUNDLE.unexpectedRoutingTypeForAddress(new SimpleString(coreAddress), AddressInfo.RoutingType.MULTICAST, addressInfo.getRoutingType());
if (addressInfo != null && !addressInfo.getRoutingTypes().contains(RoutingType.MULTICAST)) {
throw ActiveMQMessageBundle.BUNDLE.unexpectedRoutingTypeForAddress(new SimpleString(coreAddress), RoutingType.MULTICAST, addressInfo.getRoutingTypes());
}
session.getSessionState().addSubscription(subscription);

View File

@ -721,7 +721,7 @@ public class OpenWireConnection extends AbstractRemotingConnection implements Se
CheckType checkType = dest.isTemporary() ? CheckType.CREATE_NON_DURABLE_QUEUE : CheckType.CREATE_DURABLE_QUEUE;
server.getSecurityStore().check(qName, checkType, this);
server.checkQueueCreationLimit(getUsername());
server.createQueue(qName, qName, null, connInfo == null ? null : SimpleString.toSimpleString(connInfo.getUserName()), true, false);
server.createQueue(qName, null, qName, connInfo == null ? null : SimpleString.toSimpleString(connInfo.getUserName()), true, false);
}
}
}

View File

@ -33,6 +33,7 @@ import org.apache.activemq.artemis.core.protocol.openwire.util.OpenWireUtil;
import org.apache.activemq.artemis.core.server.ActiveMQServerLogger;
import org.apache.activemq.artemis.core.server.MessageReference;
import org.apache.activemq.artemis.core.server.QueueQueryResult;
import org.apache.activemq.artemis.core.server.RoutingType;
import org.apache.activemq.artemis.core.server.ServerConsumer;
import org.apache.activemq.artemis.core.server.ServerMessage;
import org.apache.activemq.artemis.core.server.SlowConsumerDetectionListener;
@ -97,7 +98,7 @@ public class AMQConsumer {
} else {
SimpleString queueName = new SimpleString(openwireDestination.getPhysicalName());
try {
session.getCoreServer().createQueue(queueName, queueName, null, true, false);
session.getCoreServer().createQueue(queueName, RoutingType.ANYCAST, queueName, null, true, false);
} catch (ActiveMQQueueExistsException e) {
// ignore
}
@ -151,10 +152,10 @@ public class AMQConsumer {
session.getCoreSession().deleteQueue(queueName);
// Create the new one
session.getCoreSession().createQueue(address, queueName, selector, false, true);
session.getCoreSession().createQueue(address, queueName, RoutingType.MULTICAST, selector, false, true);
}
} else {
session.getCoreSession().createQueue(address, queueName, selector, false, true);
session.getCoreSession().createQueue(address, queueName, RoutingType.MULTICAST, selector, false, true);
}
} else {
queueName = new SimpleString(UUID.randomUUID().toString());

View File

@ -172,7 +172,7 @@ public class AMQSession implements SessionCallback {
if (!queueBinding.isExists()) {
if (isAutoCreate) {
server.createQueue(queueName, queueName, null, true, isTemporary);
server.createQueue(queueName, null, queueName, null, true, isTemporary);
connection.addKnownDestination(queueName);
} else {
hasQueue = false;

View File

@ -38,9 +38,9 @@ import org.apache.activemq.artemis.core.remoting.CloseListener;
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.RoutingType;
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;
@ -260,23 +260,23 @@ public final class StompConnection implements RemotingConnection {
}
}
public boolean autoCreateDestinationIfPossible(String queue, AddressInfo.RoutingType routingType) throws ActiveMQStompException {
public boolean autoCreateDestinationIfPossible(String queue, RoutingType routingType) throws ActiveMQStompException {
boolean result = false;
ServerSession session = getSession().getSession();
try {
if (manager.getServer().getAddressInfo(SimpleString.toSimpleString(queue)) == null) {
AddressSettings addressSettings = manager.getServer().getAddressSettingsRepository().getMatch(queue);
if (routingType != null && routingType.equals(AddressInfo.RoutingType.MULTICAST) && addressSettings.isAutoCreateAddresses()) {
session.createAddress(SimpleString.toSimpleString(queue), true, true);
if (routingType != null && routingType == RoutingType.MULTICAST && addressSettings.isAutoCreateAddresses()) {
session.createAddress(SimpleString.toSimpleString(queue), RoutingType.MULTICAST, true);
result = true;
} else {
if (addressSettings.isAutoCreateAddresses()) {
session.createAddress(SimpleString.toSimpleString(queue), false, true);
session.createAddress(SimpleString.toSimpleString(queue), RoutingType.ANYCAST, true);
result = true;
}
if (addressSettings.isAutoCreateQueues()) {
session.createQueue(SimpleString.toSimpleString(queue), SimpleString.toSimpleString(queue), null, false, true, null, null, true);
session.createQueue(SimpleString.toSimpleString(queue), SimpleString.toSimpleString(queue), RoutingType.ANYCAST, null, false, true, true);
result = true;
}
}
@ -290,10 +290,10 @@ public final class StompConnection implements RemotingConnection {
return result;
}
public void checkRoutingSemantics(String destination, AddressInfo.RoutingType routingType) throws ActiveMQStompException {
AddressInfo.RoutingType actualRoutingTypeOfAddress = manager.getServer().getAddressInfo(SimpleString.toSimpleString(destination)).getRoutingType();
if (routingType != null && !routingType.equals(actualRoutingTypeOfAddress)) {
throw BUNDLE.illegalSemantics(routingType.toString(), actualRoutingTypeOfAddress.toString());
public void checkRoutingSemantics(String destination, RoutingType routingType) throws ActiveMQStompException {
Set<RoutingType> actualDeliveryModesOfAddres = manager.getServer().getAddressInfo(SimpleString.toSimpleString(destination)).getRoutingTypes();
if (routingType != null && !actualDeliveryModesOfAddres.contains(routingType)) {
throw BUNDLE.illegalSemantics(routingType.toString(), actualDeliveryModesOfAddres.toString());
}
}
@ -654,7 +654,7 @@ public final class StompConnection implements RemotingConnection {
String id,
String durableSubscriptionName,
boolean noLocal,
AddressInfo.RoutingType subscriptionType) throws ActiveMQStompException {
RoutingType subscriptionType) throws ActiveMQStompException {
autoCreateDestinationIfPossible(destination, subscriptionType);
checkDestination(destination);
checkRoutingSemantics(destination, subscriptionType);

View File

@ -19,6 +19,7 @@ package org.apache.activemq.artemis.core.protocol.stomp;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.concurrent.BlockingDeque;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.LinkedBlockingDeque;
@ -34,12 +35,12 @@ import org.apache.activemq.artemis.core.persistence.OperationContext;
import org.apache.activemq.artemis.core.persistence.StorageManager;
import org.apache.activemq.artemis.core.persistence.impl.journal.LargeServerMessageImpl;
import org.apache.activemq.artemis.core.remoting.impl.netty.TransportConstants;
import org.apache.activemq.artemis.core.server.RoutingType;
import org.apache.activemq.artemis.core.server.LargeServerMessage;
import org.apache.activemq.artemis.core.server.MessageReference;
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.impl.AddressInfo;
import org.apache.activemq.artemis.core.server.impl.ServerMessageImpl;
import org.apache.activemq.artemis.core.server.impl.ServerSessionImpl;
import org.apache.activemq.artemis.spi.core.protocol.RemotingConnection;
@ -286,7 +287,8 @@ public class StompSession implements SessionCallback {
receiveCredits = -1;
}
if (manager.getServer().getAddressInfo(SimpleString.toSimpleString(destination)).getRoutingType().equals(AddressInfo.RoutingType.MULTICAST)) {
Set<RoutingType> routingTypes = manager.getServer().getAddressInfo(SimpleString.toSimpleString(destination)).getRoutingTypes();
if (routingTypes.size() == 1 && routingTypes.contains(RoutingType.MULTICAST)) {
// subscribes to a topic
pubSub = true;
if (durableSubscriptionName != null) {

View File

@ -27,8 +27,8 @@ import org.apache.activemq.artemis.core.protocol.stomp.Stomp.Headers;
import org.apache.activemq.artemis.core.protocol.stomp.v10.StompFrameHandlerV10;
import org.apache.activemq.artemis.core.protocol.stomp.v11.StompFrameHandlerV11;
import org.apache.activemq.artemis.core.protocol.stomp.v12.StompFrameHandlerV12;
import org.apache.activemq.artemis.core.server.RoutingType;
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.ServerMessageImpl;
import org.apache.activemq.artemis.utils.DataConstants;
import org.apache.activemq.artemis.utils.ExecutorFactory;
@ -169,7 +169,7 @@ public abstract class VersionedStompFrameHandler {
try {
connection.validate();
String destination = getDestination(frame);
AddressInfo.RoutingType routingType = getRoutingType(frame.getHeader(Headers.Send.DESTINATION_TYPE), frame.getHeader(Headers.Send.DESTINATION));
RoutingType routingType = getRoutingType(frame.getHeader(Headers.Send.DESTINATION_TYPE), frame.getHeader(Headers.Send.DESTINATION));
connection.autoCreateDestinationIfPossible(destination, routingType);
connection.checkDestination(destination);
connection.checkRoutingSemantics(destination, routingType);
@ -247,7 +247,7 @@ public abstract class VersionedStompFrameHandler {
if (durableSubscriptionName == null) {
durableSubscriptionName = request.getHeader(Stomp.Headers.Subscribe.DURABLE_SUBSCRIPTION_NAME);
}
AddressInfo.RoutingType routingType = getRoutingType(request.getHeader(Headers.Subscribe.SUBSCRIPTION_TYPE), request.getHeader(Headers.Subscribe.DESTINATION));
RoutingType routingType = getRoutingType(request.getHeader(Headers.Subscribe.SUBSCRIPTION_TYPE), request.getHeader(Headers.Subscribe.DESTINATION));
boolean noLocal = false;
if (request.hasHeader(Stomp.Headers.Subscribe.NO_LOCAL)) {
@ -344,16 +344,16 @@ public abstract class VersionedStompFrameHandler {
connection.destroy();
}
private AddressInfo.RoutingType getRoutingType(String typeHeader, String destination) {
private RoutingType getRoutingType(String typeHeader, String destination) {
// null is valid to return here so we know when the user didn't provide any routing info
AddressInfo.RoutingType routingType = null;
RoutingType routingType = null;
if (typeHeader != null) {
routingType = AddressInfo.RoutingType.valueOf(typeHeader);
routingType = RoutingType.valueOf(typeHeader);
} else if (destination != null && !connection.getAnycastPrefix().equals(connection.getMulticastPrefix())) {
if (connection.getMulticastPrefix().length() > 0 && destination.startsWith(connection.getMulticastPrefix())) {
routingType = AddressInfo.RoutingType.MULTICAST;
routingType = RoutingType.MULTICAST;
} else if (connection.getAnycastPrefix().length() > 0 && destination.startsWith(connection.getAnycastPrefix())) {
routingType = AddressInfo.RoutingType.ANYCAST;
routingType = RoutingType.ANYCAST;
}
}
return routingType;

View File

@ -224,7 +224,7 @@ public class ActiveMQRAMessageProducer implements MessageProducer {
@Override
public int getDeliveryMode() throws JMSException {
if (ActiveMQRAMessageProducer.trace) {
ActiveMQRALogger.LOGGER.trace("getDeliveryMode()");
ActiveMQRALogger.LOGGER.trace("getRoutingType()");
}
return producer.getDeliveryMode();
@ -314,7 +314,7 @@ public class ActiveMQRAMessageProducer implements MessageProducer {
@Override
public void setDeliveryMode(final int deliveryMode) throws JMSException {
if (ActiveMQRAMessageProducer.trace) {
ActiveMQRALogger.LOGGER.trace("setDeliveryMode(" + deliveryMode + ")");
ActiveMQRALogger.LOGGER.trace("setRoutingType(" + deliveryMode + ")");
}
producer.setDeliveryMode(deliveryMode);

View File

@ -17,6 +17,7 @@
package org.apache.activemq.artemis.rest.test;
import org.apache.activemq.artemis.api.core.SimpleString;
import org.apache.activemq.artemis.core.server.RoutingType;
import org.jboss.resteasy.client.ClientRequest;
import org.jboss.resteasy.client.ClientResponse;
import org.jboss.resteasy.spi.Link;
@ -29,7 +30,7 @@ public class FindDestinationTest extends MessageTestBase {
@Test
public void testFindQueue() throws Exception {
String testName = "testFindQueue";
server.getActiveMQServer().createQueue(new SimpleString(testName), new SimpleString(testName), null, false, false);
server.getActiveMQServer().createQueue(new SimpleString(testName), RoutingType.MULTICAST, new SimpleString(testName), null, false, false);
ClientRequest request = new ClientRequest(TestPortProvider.generateURL("/queues/" + testName));
@ -59,7 +60,7 @@ public class FindDestinationTest extends MessageTestBase {
@Test
public void testFindTopic() throws Exception {
server.getActiveMQServer().createQueue(new SimpleString("testTopic"), new SimpleString("testTopic"), null, false, false);
server.getActiveMQServer().createQueue(new SimpleString("testTopic"), RoutingType.MULTICAST, new SimpleString("testTopic"), null, false, false);
ClientRequest request = new ClientRequest(TestPortProvider.generateURL("/topics/testTopic"));
ClientResponse<?> response = request.head();

View File

@ -34,6 +34,8 @@ import org.apache.activemq.artemis.core.remoting.impl.invm.InVMAcceptorFactory;
import org.apache.activemq.artemis.core.remoting.impl.invm.InVMConnectorFactory;
import org.apache.activemq.artemis.core.server.ActiveMQServer;
import org.apache.activemq.artemis.core.server.ActiveMQServers;
import org.apache.activemq.artemis.core.server.RoutingType;
import org.apache.activemq.artemis.core.server.impl.AddressInfo;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.BeforeClass;
@ -64,9 +66,11 @@ public class RawAckTest {
sessionFactory = serverLocator.createSessionFactory();
consumerSessionFactory = serverLocator.createSessionFactory();
activeMQServer.createQueue(new SimpleString("testQueue"), new SimpleString("testQueue"), null, false, false);
SimpleString addr = SimpleString.toSimpleString("testQueue");
activeMQServer.createAddressInfo(new AddressInfo(addr, RoutingType.MULTICAST));
activeMQServer.createQueue(addr, RoutingType.MULTICAST, addr, null, false, false);
session = sessionFactory.createSession(true, true);
producer = session.createProducer("testQueue");
producer = session.createProducer(addr);
session.start();
}

View File

@ -18,20 +18,17 @@ package org.apache.activemq.artemis.core.config;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration;
import org.apache.activemq.artemis.core.server.impl.AddressInfo;
import org.apache.activemq.artemis.core.server.RoutingType;
public class CoreAddressConfiguration implements Serializable {
private String name = null;
private AddressInfo.RoutingType routingType = null;
private Integer defaultMaxConsumers = ActiveMQDefaultConfiguration.getDefaultMaxQueueConsumers();
private Boolean defaultDeleteOnNoConsumers = ActiveMQDefaultConfiguration.getDefaultDeleteQueueOnNoConsumers();
private Set<RoutingType> routingTypes = new HashSet<>();
private List<CoreQueueConfiguration> queueConfigurations = new ArrayList<>();
@ -47,12 +44,12 @@ public class CoreAddressConfiguration implements Serializable {
return this;
}
public AddressInfo.RoutingType getRoutingType() {
return routingType;
public Set<RoutingType> getRoutingTypes() {
return routingTypes;
}
public CoreAddressConfiguration setRoutingType(AddressInfo.RoutingType routingType) {
this.routingType = routingType;
public CoreAddressConfiguration addDeliveryMode(RoutingType routingType) {
routingTypes.add(routingType);
return this;
}
@ -69,73 +66,4 @@ public class CoreAddressConfiguration implements Serializable {
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;
}
}

View File

@ -18,6 +18,9 @@ package org.apache.activemq.artemis.core.config;
import java.io.Serializable;
import org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration;
import org.apache.activemq.artemis.core.server.RoutingType;
public class CoreQueueConfiguration implements Serializable {
private static final long serialVersionUID = 650404974977490254L;
@ -30,9 +33,11 @@ public class CoreQueueConfiguration implements Serializable {
private boolean durable = true;
private Integer maxConsumers = null;
private Integer maxConsumers = ActiveMQDefaultConfiguration.getDefaultMaxQueueConsumers();
private Boolean deleteOnNoConsumers = null;
private Boolean deleteOnNoConsumers = ActiveMQDefaultConfiguration.getDefaultDeleteQueueOnNoConsumers();
private RoutingType routingType = ActiveMQDefaultConfiguration.getDefaultRoutingType();
public CoreQueueConfiguration() {
}
@ -53,8 +58,6 @@ public class CoreQueueConfiguration implements Serializable {
return durable;
}
/**
* @param address the address to set
*/
@ -103,14 +106,22 @@ public class CoreQueueConfiguration implements Serializable {
return this;
}
public Boolean getDeleteOnNoConsumers() {
public boolean getDeleteOnNoConsumers() {
return deleteOnNoConsumers;
}
public Integer getMaxConsumers() {
public int getMaxConsumers() {
return maxConsumers;
}
public RoutingType getRoutingType() {
return routingType;
}
public void setRoutingType(RoutingType routingType) {
this.routingType = routingType;
}
@Override
public int hashCode() {
final int prime = 31;

View File

@ -163,4 +163,14 @@ public final class Validators {
}
}
};
public static final Validator MAX_QUEUE_CONSUMERS = new Validator() {
@Override
public void validate(String name, Object value) {
int val = (Integer) value;
if (val < -1) {
throw ActiveMQMessageBundle.BUNDLE.invalidMaxConsumers(name, val);
}
}
};
}

View File

@ -60,11 +60,11 @@ import org.apache.activemq.artemis.core.config.storage.FileStorageConfiguration;
import org.apache.activemq.artemis.core.io.aio.AIOSequentialFileFactory;
import org.apache.activemq.artemis.core.security.Role;
import org.apache.activemq.artemis.core.server.ActiveMQServerLogger;
import org.apache.activemq.artemis.core.server.RoutingType;
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;
@ -625,15 +625,16 @@ public final class FileConfigurationParser extends XMLConfigurationUtil {
NodeList elements = e.getElementsByTagName("queues");
if (elements.getLength() != 0) {
Element node = (Element) elements.item(0);
config.setQueueConfigurations(parseQueueConfigurations(node));
config.setQueueConfigurations(parseQueueConfigurations(node, ActiveMQDefaultConfiguration.DEFAULT_ROUTING_TYPE));
}
}
private List<CoreQueueConfiguration> parseQueueConfigurations(final Element node) {
private List<CoreQueueConfiguration> parseQueueConfigurations(final Element node, RoutingType routingType) {
List<CoreQueueConfiguration> queueConfigurations = new ArrayList<>();
NodeList list = node.getElementsByTagName("queue");
for (int i = 0; i < list.getLength(); i++) {
CoreQueueConfiguration queueConfig = parseQueueConfiguration(list.item(i));
queueConfig.setRoutingType(routingType);
queueConfigurations.add(queueConfig);
}
return queueConfigurations;
@ -903,14 +904,15 @@ public final class FileConfigurationParser extends XMLConfigurationUtil {
String address = null;
String filterString = null;
boolean durable = true;
Integer maxConsumers = null;
Boolean deleteOnNoConsumers = null;
int maxConsumers = ActiveMQDefaultConfiguration.getDefaultMaxQueueConsumers();
boolean deleteOnNoConsumers = ActiveMQDefaultConfiguration.getDefaultDeleteQueueOnNoConsumers();
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());
Validators.MAX_QUEUE_CONSUMERS.validate(name, maxConsumers);
} else if (item.getNodeName().equals("delete-on-no-consumers")) {
deleteOnNoConsumers = Boolean.parseBoolean(item.getNodeValue());
}
@ -929,40 +931,33 @@ public final class FileConfigurationParser extends XMLConfigurationUtil {
}
}
return new CoreQueueConfiguration()
.setAddress(address)
.setName(name)
.setFilterString(filterString)
.setDurable(durable)
.setMaxConsumers(maxConsumers)
.setDeleteOnNoConsumers(deleteOnNoConsumers);
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()));
String name = getAttributeValue(node, "name");
addressConfiguration.setName(name);
List<CoreQueueConfiguration> queueConfigurations = new ArrayList<>();
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));
if (child.getNodeName().equals("multicast")) {
addressConfiguration.addDeliveryMode(RoutingType.MULTICAST);
queueConfigurations.addAll(parseQueueConfigurations((Element) child, RoutingType.MULTICAST));
} else if (child.getNodeName().equals("anycast")) {
addressConfiguration.addDeliveryMode(RoutingType.ANYCAST);
queueConfigurations.addAll(parseQueueConfigurations((Element) child, RoutingType.ANYCAST));
}
}
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());
}
for (CoreQueueConfiguration coreQueueConfiguration : queueConfigurations) {
coreQueueConfiguration.setAddress(name);
}
addressConfiguration.setQueueConfigurations(queueConfigurations);
return addressConfiguration;
}

View File

@ -42,6 +42,7 @@ import java.util.Map.Entry;
import java.util.Set;
import java.util.concurrent.atomic.AtomicLong;
import org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration;
import org.apache.activemq.artemis.api.core.ActiveMQAddressDoesNotExistException;
import org.apache.activemq.artemis.api.core.SimpleString;
import org.apache.activemq.artemis.api.core.TransportConfiguration;
@ -76,6 +77,7 @@ import org.apache.activemq.artemis.core.server.ActiveMQServer;
import org.apache.activemq.artemis.core.server.ActiveMQServerLogger;
import org.apache.activemq.artemis.core.server.ConnectorServiceFactory;
import org.apache.activemq.artemis.core.server.Consumer;
import org.apache.activemq.artemis.core.server.RoutingType;
import org.apache.activemq.artemis.core.server.JournalType;
import org.apache.activemq.artemis.core.server.Queue;
import org.apache.activemq.artemis.core.server.ServerConsumer;
@ -560,26 +562,18 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active
}
@Override
public void createAddress(String name, int routingType, boolean defaultDeleteOnNoConsumers, int defaultMaxConsumers) throws Exception {
public void createAddress(@Parameter(name = "name", desc = "The name of the address") String name,
@Parameter(name = "deliveryMode", desc = "The delivery modes enabled for this address'") Set<RoutingType> routingTypes) throws Exception {
checkStarted();
clearIO();
try {
server.createAddressInfo(new AddressInfo(new SimpleString(name), AddressInfo.RoutingType.getType((byte) routingType), defaultDeleteOnNoConsumers, defaultMaxConsumers));
server.createAddressInfo(new AddressInfo(new SimpleString(name), routingTypes));
} finally {
blockOnIO();
}
}
@Override
public void createAddress(@Parameter(name = "name", desc = "The name of the address") String name,
@Parameter(name = "routingType", desc = "The routing type for the address either 'MULTICAST' or 'ANYCAST'") String routingType,
@Parameter(name = "defaultDeleteOnNoConsumers", desc = "Whether or not a queue with this address is deleted when it has no consumers") boolean defaultDeleteOnNoConsumers,
@Parameter(name = "defaultMaxConsumers", desc = "The maximim number of consumer a queue with this address can have") int defaultMaxConsumers) throws Exception {
AddressInfo.RoutingType rt = AddressInfo.RoutingType.valueOf(routingType.toUpperCase());
createAddress(name, rt.ordinal(), defaultDeleteOnNoConsumers, defaultMaxConsumers);
}
@Override
public void deleteAddress(String name) throws Exception {
checkStarted();
@ -592,18 +586,20 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active
}
}
@Deprecated
@Override
public void deployQueue(final String address, final String name, final String filterString) throws Exception {
checkStarted();
clearIO();
try {
server.deployQueue(SimpleString.toSimpleString(address), new SimpleString(name), new SimpleString(filterString), true, false);
server.deployQueue(SimpleString.toSimpleString(address), ActiveMQDefaultConfiguration.getDefaultRoutingType(), new SimpleString(name), new SimpleString(filterString), true, false);
} finally {
blockOnIO();
}
}
@Deprecated
@Override
public void deployQueue(final String address,
final String name,
@ -614,19 +610,20 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active
SimpleString filter = filterStr == null ? null : new SimpleString(filterStr);
clearIO();
try {
server.deployQueue(SimpleString.toSimpleString(address), new SimpleString(name), filter, durable, false);
server.deployQueue(SimpleString.toSimpleString(address), ActiveMQDefaultConfiguration.getDefaultRoutingType(), new SimpleString(name), filter, durable, false);
} finally {
blockOnIO();
}
}
@Deprecated
@Override
public void createQueue(final String address, final String name) throws Exception {
checkStarted();
clearIO();
try {
server.createQueue(SimpleString.toSimpleString(address), new SimpleString(name), null, true, false);
server.createQueue(SimpleString.toSimpleString(address), ActiveMQDefaultConfiguration.getDefaultRoutingType(), new SimpleString(name), null, true, false);
} finally {
blockOnIO();
}
@ -638,7 +635,7 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active
clearIO();
try {
server.createQueue(SimpleString.toSimpleString(address), new SimpleString(name), null, durable, false);
server.createQueue(SimpleString.toSimpleString(address), ActiveMQDefaultConfiguration.getDefaultRoutingType(), new SimpleString(name), null, durable, false);
} finally {
blockOnIO();
}
@ -646,12 +643,13 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active
@Override
public void createQueue(@Parameter(name = "address", desc = "Address of the queue") String address,
@Parameter(name = "routingType", desc = "The routing type used for this address, 0=multicast, 1=anycast") RoutingType routingType,
@Parameter(name = "name", desc = "Name of the queue") String name,
@Parameter(name = "filter", desc = "Filter of the queue") String filterStr,
@Parameter(name = "durable", desc = "Is the queue durable?") boolean durable,
@Parameter(name = "maxConsumers", desc = "The maximum number of consumers allowed on this queue at any one time") int maxConsumers,
@Parameter(name = "deleteOnNoConsumers", desc = "Delete this queue when the last consumer disconnects") boolean deleteOnNoConsumers,
@Parameter(name = "autoCreateAddress", desc = "Create an address with default values if one does not exist") boolean autoCreateAddress) throws Exception {
@Parameter(name = "autoCreateAddress", desc = "Create an address with default values should a matching address not be found") boolean autoCreateAddress) throws Exception {
checkStarted();
clearIO();
@ -662,7 +660,7 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active
filter = new SimpleString(filterStr);
}
server.createQueue(SimpleString.toSimpleString(address), new SimpleString(name), filter, durable, false, maxConsumers, deleteOnNoConsumers, autoCreateAddress);
server.createQueue(SimpleString.toSimpleString(address), routingType, new SimpleString(name), filter, durable, false, maxConsumers, deleteOnNoConsumers, autoCreateAddress);
} finally {
blockOnIO();
}
@ -682,7 +680,7 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active
filter = new SimpleString(filterStr);
}
server.createQueue(SimpleString.toSimpleString(address), new SimpleString(name), filter, durable, false);
server.createQueue(SimpleString.toSimpleString(address), ActiveMQDefaultConfiguration.getDefaultRoutingType(), new SimpleString(name), filter, durable, false);
} finally {
blockOnIO();
}

View File

@ -40,6 +40,7 @@ import org.apache.activemq.artemis.core.security.CheckType;
import org.apache.activemq.artemis.core.security.Role;
import org.apache.activemq.artemis.core.security.SecurityAuth;
import org.apache.activemq.artemis.core.security.SecurityStore;
import org.apache.activemq.artemis.core.server.RoutingType;
import org.apache.activemq.artemis.core.server.impl.AddressInfo;
import org.apache.activemq.artemis.core.server.impl.ServerMessageImpl;
import org.apache.activemq.artemis.core.server.management.ManagementService;
@ -96,8 +97,8 @@ public class AddressControlImpl extends AbstractControl implements AddressContro
}
@Override
public String getRoutingType() {
return addressInfo.getRoutingType().toString();
public Set<RoutingType> getDeliveryModes() {
return addressInfo.getRoutingTypes();
}
@Override

View File

@ -16,8 +16,10 @@
*/
package org.apache.activemq.artemis.core.persistence;
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.server.RoutingType;
public interface AddressBindingInfo {
@ -25,8 +27,5 @@ public interface AddressBindingInfo {
SimpleString getName();
AddressInfo.RoutingType getRoutingType();
int getDefaultMaxConsumers();
Set<RoutingType> getRoutingTypes();
}

View File

@ -1269,9 +1269,7 @@ public abstract class AbstractJournalStorageManager implements StorageManager {
@Override
public void addAddressBinding(final long tx, final AddressInfo addressInfo) throws Exception {
PersistentAddressBindingEncoding bindingEncoding = new PersistentAddressBindingEncoding(addressInfo.getName(),
addressInfo.getRoutingType(),
addressInfo.getDefaultMaxQueueConsumers(),
addressInfo.isDefaultDeleteOnNoConsumers(),
addressInfo.getRoutingTypes(),
addressInfo.isAutoCreated());
readLock();

View File

@ -16,11 +16,14 @@
*/
package org.apache.activemq.artemis.core.persistence.impl.journal.codec;
import java.util.HashSet;
import java.util.Set;
import org.apache.activemq.artemis.api.core.ActiveMQBuffer;
import org.apache.activemq.artemis.api.core.SimpleString;
import org.apache.activemq.artemis.core.journal.EncodingSupport;
import org.apache.activemq.artemis.core.persistence.AddressBindingInfo;
import org.apache.activemq.artemis.core.server.impl.AddressInfo;
import org.apache.activemq.artemis.core.server.RoutingType;
import org.apache.activemq.artemis.utils.DataConstants;
public class PersistentAddressBindingEncoding implements EncodingSupport, AddressBindingInfo {
@ -29,42 +32,31 @@ public class PersistentAddressBindingEncoding implements EncodingSupport, Addres
public SimpleString name;
public int defaultMaxConsumers;
public boolean defaultDeleteOnNoConsumers;
public boolean autoCreated;
public AddressInfo.RoutingType routingType;
public Set<RoutingType> routingTypes;
public PersistentAddressBindingEncoding() {
routingTypes = new HashSet<>();
}
@Override
public String toString() {
return "PersistentAddressBindingEncoding [id=" + id +
", name=" +
name +
", routingType=" +
routingType +
", defaultMaxConsumers=" +
defaultMaxConsumers +
", defaultDeleteOnNoConsumers=" +
defaultDeleteOnNoConsumers +
", autoCreated=" +
autoCreated +
"]";
StringBuilder sb = new StringBuilder("PersistentAddressBindingEncoding [id=" + id);
sb.append(", name=" + name);
sb.append(", routingTypes={");
for (RoutingType routingType : routingTypes) {
sb.append(routingType.toString() + ",");
}
sb.append(", autoCreated=" + autoCreated + "]");
return sb.toString();
}
public PersistentAddressBindingEncoding(final SimpleString name,
final AddressInfo.RoutingType routingType,
final int defaultMaxConsumers,
final boolean defaultDeleteOnNoConsumers,
final Set<RoutingType> routingTypes,
final boolean autoCreated) {
this.name = name;
this.routingType = routingType;
this.defaultMaxConsumers = defaultMaxConsumers;
this.defaultDeleteOnNoConsumers = defaultDeleteOnNoConsumers;
this.routingTypes = routingTypes;
this.autoCreated = autoCreated;
}
@ -83,35 +75,35 @@ public class PersistentAddressBindingEncoding implements EncodingSupport, Addres
}
@Override
public AddressInfo.RoutingType getRoutingType() {
return routingType;
}
@Override
public int getDefaultMaxConsumers() {
return defaultMaxConsumers;
public Set<RoutingType> getRoutingTypes() {
return routingTypes;
}
@Override
public void decode(final ActiveMQBuffer buffer) {
name = buffer.readSimpleString();
routingType = AddressInfo.RoutingType.getType(buffer.readByte());
defaultMaxConsumers = buffer.readInt();
defaultDeleteOnNoConsumers = buffer.readBoolean();
int size = buffer.readInt();
for (int i = 0; i < size; i++) {
routingTypes.add(RoutingType.getType(buffer.readByte()));
}
autoCreated = buffer.readBoolean();
}
@Override
public void encode(final ActiveMQBuffer buffer) {
buffer.writeSimpleString(name);
buffer.writeByte(routingType.getType());
buffer.writeInt(defaultMaxConsumers);
buffer.writeBoolean(defaultDeleteOnNoConsumers);
buffer.writeInt(routingTypes.size());
for (RoutingType d : routingTypes) {
buffer.writeByte(d.getType());
}
buffer.writeBoolean(autoCreated);
}
@Override
public int getEncodeSize() {
return SimpleString.sizeofString(name) + DataConstants.SIZE_BYTE + DataConstants.SIZE_INT + DataConstants.SIZE_BOOLEAN + DataConstants.SIZE_BOOLEAN;
return SimpleString.sizeofString(name) +
DataConstants.SIZE_INT +
(DataConstants.SIZE_BYTE * routingTypes.size()) +
DataConstants.SIZE_BOOLEAN;
}
}

View File

@ -21,33 +21,33 @@ import org.apache.activemq.artemis.core.filter.Filter;
import org.apache.activemq.artemis.core.postoffice.BindingType;
import org.apache.activemq.artemis.core.postoffice.QueueBinding;
import org.apache.activemq.artemis.core.server.Bindable;
import org.apache.activemq.artemis.core.server.RoutingType;
import org.apache.activemq.artemis.core.server.Queue;
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;
public class LocalQueueBinding implements QueueBinding {
private final AddressInfo address;
private final SimpleString address;
private final Queue queue;
private final Filter filter;
private final SimpleString name;
private final SimpleString clusterName;
public LocalQueueBinding(final AddressInfo address, final Queue queue, final SimpleString nodeID) {
private SimpleString name;
public LocalQueueBinding(final SimpleString address, final Queue queue, final SimpleString nodeID) {
this.address = address;
this.queue = queue;
this.name = queue.getName();
filter = queue.getFilter();
name = queue.getName();
clusterName = name.concat(nodeID);
clusterName = queue.getName().concat(nodeID);
}
@Override
@ -62,7 +62,7 @@ public class LocalQueueBinding implements QueueBinding {
@Override
public SimpleString getAddress() {
return address.getName();
return address;
}
@Override
@ -77,12 +77,15 @@ public class LocalQueueBinding implements QueueBinding {
@Override
public SimpleString getRoutingName() {
return (address.getRoutingType() == AddressInfo.RoutingType.MULTICAST) ? name : address.getName();
if (queue.getRoutingType() == RoutingType.ANYCAST) {
return address;
}
return name;
}
@Override
public SimpleString getUniqueName() {
return name;
return queue.getName();
}
@Override

View File

@ -29,6 +29,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.RoutingType;
import org.apache.activemq.artemis.core.server.impl.AddressInfo;
import org.apache.activemq.artemis.core.transaction.Transaction;
import org.jboss.logging.Logger;
@ -194,9 +195,9 @@ public class SimpleAddressManager implements AddressManager {
private AddressInfo updateAddressInfo(AddressInfo from, AddressInfo to) {
synchronized (from) {
from.setRoutingType(to.getRoutingType());
from.setDefaultMaxQueueConsumers(to.getDefaultMaxQueueConsumers());
from.setDefaultDeleteOnNoConsumers(to.isDefaultDeleteOnNoConsumers());
for (RoutingType routingType : to.getRoutingTypes()) {
from.addRoutingType(routingType);
}
return from;
}
}

View File

@ -33,7 +33,9 @@ import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.ActiveMQEx
import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.CreateAddressMessage;
import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.CreateQueueMessage;
import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.CreateQueueMessage_V2;
import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.CreateQueueMessage_V3;
import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.CreateSharedQueueMessage;
import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.CreateSharedQueueMessage_V2;
import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.NullResponseMessage;
import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.RollbackMessage;
import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.SessionAcknowledgeMessage;
@ -78,7 +80,9 @@ import org.apache.activemq.artemis.core.remoting.impl.netty.NettyConnection;
import org.apache.activemq.artemis.core.server.ActiveMQMessageBundle;
import org.apache.activemq.artemis.core.server.ActiveMQServerLogger;
import org.apache.activemq.artemis.core.server.BindingQueryResult;
import org.apache.activemq.artemis.core.server.Queue;
import org.apache.activemq.artemis.core.server.QueueQueryResult;
import org.apache.activemq.artemis.core.server.RoutingType;
import org.apache.activemq.artemis.core.server.ServerMessage;
import org.apache.activemq.artemis.core.server.ServerSession;
import org.apache.activemq.artemis.spi.core.remoting.Connection;
@ -87,7 +91,9 @@ import org.jboss.logging.Logger;
import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.CREATE_ADDRESS;
import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.CREATE_QUEUE;
import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.CREATE_QUEUE_V2;
import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.CREATE_QUEUE_V3;
import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.CREATE_SHARED_QUEUE;
import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.CREATE_SHARED_QUEUE_V2;
import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.DELETE_QUEUE;
import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.SESS_ACKNOWLEDGE;
import static org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl.SESS_BINDINGQUERY;
@ -227,7 +233,7 @@ public class ServerSessionPacketHandler implements ChannelHandler {
case CREATE_ADDRESS: {
CreateAddressMessage request = (CreateAddressMessage) packet;
requiresResponse = request.isRequiresResponse();
session.createAddress(request.getAddress(), request.isMulticast(), request.isAutoCreated());
session.createAddress(request.getAddress(), request.getRoutingTypes(), request.isAutoCreated());
if (requiresResponse) {
response = new NullResponseMessage();
}
@ -236,7 +242,7 @@ public class ServerSessionPacketHandler implements ChannelHandler {
case CREATE_QUEUE: {
CreateQueueMessage request = (CreateQueueMessage) packet;
requiresResponse = request.isRequiresResponse();
session.createQueue(request.getAddress(), request.getQueueName(), request.getFilterString(), request.isTemporary(), request.isDurable());
session.createQueue(request.getAddress(), request.getQueueName(), RoutingType.MULTICAST, request.getFilterString(), request.isTemporary(), request.isDurable());
if (requiresResponse) {
response = new NullResponseMessage();
}
@ -245,7 +251,25 @@ public class ServerSessionPacketHandler implements ChannelHandler {
case CREATE_QUEUE_V2: {
CreateQueueMessage_V2 request = (CreateQueueMessage_V2) packet;
requiresResponse = request.isRequiresResponse();
session.createQueue(request.getAddress(), request.getQueueName(), request.getFilterString(), request.isTemporary(), request.isDurable(), null, null, request.isAutoCreated());
session.createQueue(request.getAddress(),
request.getQueueName(),
RoutingType.MULTICAST,
request.getFilterString(),
request.isTemporary(),
request.isDurable(),
Queue.MAX_CONSUMERS_UNLIMITED,
false,
request.isAutoCreated());
if (requiresResponse) {
response = new NullResponseMessage();
}
break;
}
case CREATE_QUEUE_V3: {
CreateQueueMessage_V3 request = (CreateQueueMessage_V3) packet;
requiresResponse = request.isRequiresResponse();
session.createQueue(request.getAddress(), request.getQueueName(), request.getRoutingType(), request.getFilterString(), request.isTemporary(), request.isDurable(), request.getMaxConsumers(), request.isDeleteOnNoConsumers(),
request.isAutoCreated());
if (requiresResponse) {
response = new NullResponseMessage();
}
@ -260,6 +284,15 @@ public class ServerSessionPacketHandler implements ChannelHandler {
}
break;
}
case CREATE_SHARED_QUEUE_V2: {
CreateSharedQueueMessage_V2 request = (CreateSharedQueueMessage_V2) packet;
requiresResponse = request.isRequiresResponse();
session.createSharedQueue(request.getAddress(), request.getQueueName(), request.getRoutingType(), request.isDurable(), request.getFilterString());
if (requiresResponse) {
response = new NullResponseMessage();
}
break;
}
case DELETE_QUEUE: {
requiresResponse = true;
SessionDeleteQueueMessage request = (SessionDeleteQueueMessage) packet;

View File

@ -233,7 +233,7 @@ public class ActiveMQPacketHandler implements ChannelHandler {
private void handleCreateQueue(final CreateQueueMessage request) {
try {
server.createQueue(request.getAddress(), request.getQueueName(), request.getFilterString(), request.isDurable(), request.isTemporary());
server.createQueue(request.getAddress(), null, request.getQueueName(), request.getFilterString(), request.isDurable(), request.isTemporary());
} catch (Exception e) {
ActiveMQServerLogger.LOGGER.failedToHandleCreateQueue(e);
}

View File

@ -17,6 +17,7 @@
package org.apache.activemq.artemis.core.server;
import java.io.File;
import java.util.Set;
import org.apache.activemq.artemis.api.core.ActiveMQAddressDoesNotExistException;
import org.apache.activemq.artemis.api.core.ActiveMQAddressExistsException;
@ -45,7 +46,6 @@ import org.apache.activemq.artemis.api.core.SimpleString;
import org.apache.activemq.artemis.core.postoffice.Binding;
import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.ReplicationSyncFileMessage;
import org.apache.activemq.artemis.core.security.CheckType;
import org.apache.activemq.artemis.core.server.impl.AddressInfo;
import org.jboss.logging.Messages;
import org.jboss.logging.annotations.Cause;
import org.jboss.logging.annotations.Message;
@ -389,7 +389,7 @@ public interface ActiveMQMessageBundle {
ActiveMQQueueMaxConsumerLimitReached maxConsumerLimitReachedForQueue(SimpleString address, SimpleString queueName);
@Message(id = 119201, value = "Expected Routing Type {1} but found {2} for address {0}", format = Message.Format.MESSAGE_FORMAT)
ActiveMQUnexpectedRoutingTypeForAddress unexpectedRoutingTypeForAddress(SimpleString address, AddressInfo.RoutingType expectedRoutingType, AddressInfo.RoutingType actualRoutingType);
ActiveMQUnexpectedRoutingTypeForAddress unexpectedRoutingTypeForAddress(SimpleString address, RoutingType expectedRoutingType, Set<RoutingType> supportedRoutingTypes);
@Message(id = 119202, value = "Invalid Queue Configuration for Queue {0}, Address {1}. Expected {2} to be {3} but was {4}", format = Message.Format.MESSAGE_FORMAT)
ActiveMQInvalidQueueConfiguration invalidQueueConfiguration(SimpleString address, SimpleString queueName, String queuePropertyName, Object expectedValue, Object actualValue);
@ -402,4 +402,12 @@ public interface ActiveMQMessageBundle {
@Message(id = 119205, value = "Address {0} has bindings", format = Message.Format.MESSAGE_FORMAT)
ActiveMQDeleteAddressException addressHasBindings(SimpleString address);
@Message(id = 119206, value = "Queue {0} has invalid max consumer setting: {1}", format = Message.Format.MESSAGE_FORMAT)
IllegalArgumentException invalidMaxConsumers(String queueName, int value);
@Message(id = 119207, value = "Can not create queue with delivery mode: {0}, Supported delivery modes for address: {1} are {2}", format = Message.Format.MESSAGE_FORMAT)
IllegalArgumentException invalidRoutingTypeForAddress(RoutingType routingType,
String address,
Set<RoutingType> supportedRoutingTypes);
}

View File

@ -264,6 +264,15 @@ public interface ActiveMQServer extends ActiveMQComponent {
*/
boolean waitForActivation(long timeout, TimeUnit unit) throws InterruptedException;
Queue createQueue(SimpleString address, RoutingType routingType, SimpleString queueName, SimpleString filter,
SimpleString user,
boolean durable,
boolean temporary,
boolean autoCreated,
Integer maxConsumers,
Boolean deleteOnNoConsumers,
boolean autoCreateAddress) throws Exception;
/**
* Creates a transient queue. A queue that will exist as long as there are consumers.
* The queue will be deleted as soon as all the consumers are removed.
@ -277,72 +286,54 @@ public interface ActiveMQServer extends ActiveMQComponent {
* @throws org.apache.activemq.artemis.api.core.ActiveMQInvalidTransientQueueUseException if the shared queue already exists with a different {@code address} or {@code filterString}
* @throws NullPointerException if {@code address} is {@code null}
*/
void createSharedQueue(final SimpleString address,
final SimpleString name,
final SimpleString filterString,
void createSharedQueue(final SimpleString address, final RoutingType routingType, final SimpleString name, final SimpleString filterString,
final SimpleString user,
boolean durable) throws Exception;
Queue createQueue(SimpleString address,
SimpleString queueName,
SimpleString filter,
Queue createQueue(SimpleString address, RoutingType routingType, SimpleString queueName, SimpleString filter,
boolean durable,
boolean temporary) throws Exception;
Queue createQueue(SimpleString address,
SimpleString queueName,
SimpleString filterString,
@Deprecated
Queue createQueue(SimpleString address, SimpleString queueName, SimpleString filter, boolean durable, boolean temporary) throws Exception;
Queue createQueue(SimpleString address, RoutingType routingType, SimpleString queueName, SimpleString filterString,
boolean durable,
boolean temporary,
Integer maxConsumers,
Boolean deleteOnNoConsumers,
int maxConsumers,
boolean deleteOnNoConsumers,
boolean autoCreateAddress) throws Exception;
Queue createQueue(SimpleString address,
SimpleString queueName,
SimpleString filter,
Queue createQueue(SimpleString address, RoutingType routingType, SimpleString queueName, SimpleString filter,
SimpleString user,
boolean durable,
boolean temporary) throws Exception;
Queue createQueue(SimpleString address,
SimpleString queueName,
SimpleString filter,
Queue createQueue(SimpleString address, RoutingType routingType, SimpleString queueName, SimpleString filter,
SimpleString user,
boolean durable,
boolean temporary,
Integer maxConsumers,
Boolean deleteOnNoConsumers,
int maxConsumers,
boolean deleteOnNoConsumers,
boolean autoCreateAddress) throws Exception;
Queue createQueue(SimpleString address,
SimpleString queueName,
SimpleString filter,
Queue createQueue(SimpleString address, RoutingType routingType, SimpleString queueName, SimpleString filter,
SimpleString user,
boolean durable,
boolean temporary,
boolean autoCreated) throws Exception;
Queue createQueue(SimpleString address,
SimpleString queueName,
SimpleString filter,
SimpleString user,
boolean durable,
boolean temporary,
boolean autoCreated,
Integer maxConsumers,
Boolean deleteOnNoConsumers,
boolean autoCreateAddress) throws Exception;
@Deprecated
Queue deployQueue(String address, String queue, String filter, boolean durable, boolean temporary) throws Exception;
Queue deployQueue(SimpleString address,
SimpleString queueName,
SimpleString filterString,
@Deprecated
Queue deployQueue(SimpleString address, SimpleString queue, SimpleString filter, boolean durable, boolean temporary) throws Exception;
Queue deployQueue(SimpleString address, RoutingType routingType, SimpleString resourceName, SimpleString filterString,
boolean durable,
boolean temporary) throws Exception;
Queue deployQueue(SimpleString address,
SimpleString queueName,
SimpleString filterString,
Queue deployQueue(SimpleString address, RoutingType routingType, SimpleString queueName, SimpleString filterString,
boolean durable,
boolean temporary,
boolean autoCreated) throws Exception;
@ -353,14 +344,12 @@ public interface ActiveMQServer extends ActiveMQComponent {
QueueQueryResult queueQuery(SimpleString name) throws Exception;
Queue deployQueue(SimpleString address,
SimpleString queueName,
SimpleString filterString,
Queue deployQueue(SimpleString address, RoutingType routingType, SimpleString queueName, SimpleString filterString,
boolean durable,
boolean temporary,
boolean autoCreated,
Integer maxConsumers,
Boolean deleteOnNoConsumers,
int maxConsumers,
boolean deleteOnNoConsumers,
boolean autoCreateAddress) throws Exception;
void destroyQueue(SimpleString queueName) throws Exception;
@ -416,6 +405,7 @@ public interface ActiveMQServer extends ActiveMQComponent {
Queue createQueue(SimpleString addressName,
SimpleString queueName,
RoutingType routingType,
SimpleString filterString,
SimpleString user,
boolean durable,
@ -423,14 +413,14 @@ public interface ActiveMQServer extends ActiveMQComponent {
boolean ignoreIfExists,
boolean transientQueue,
boolean autoCreated,
Integer maxConsumers,
Boolean deleteOnNoConsumers,
int maxConsumers,
boolean deleteOnNoConsumers,
boolean autoCreateAddress) throws Exception;
/*
* 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);
/*

View File

@ -32,6 +32,8 @@ import org.apache.activemq.artemis.utils.ReferenceCounter;
public interface Queue extends Bindable {
int MAX_CONSUMERS_UNLIMITED = -1;
SimpleString getName();
long getID();
@ -40,6 +42,10 @@ public interface Queue extends Bindable {
PageSubscription getPageSubscription();
RoutingType getRoutingType();
void setRoutingType(RoutingType routingType);
boolean isDurable();
boolean isTemporary();
@ -233,6 +239,7 @@ public interface Queue extends Bindable {
/**
* if the pause was persisted
*
* @return
*/
boolean isPersistedPause();
@ -283,4 +290,5 @@ public interface Queue extends Bindable {
SimpleString getUser();
void decDelivering(int size);
}

View File

@ -16,6 +16,7 @@
*/
package org.apache.activemq.artemis.core.server;
import org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration;
import org.apache.activemq.artemis.api.core.SimpleString;
import org.apache.activemq.artemis.core.filter.Filter;
import org.apache.activemq.artemis.core.filter.FilterUtils;
@ -33,7 +34,8 @@ public final class QueueConfig {
private final boolean durable;
private final boolean temporary;
private final boolean autoCreated;
private final Integer maxConsumers;
private final RoutingType routingType;
private final int maxConsumers;
private final boolean deleteOnNoConsumers;
public static final class Builder {
@ -47,7 +49,8 @@ public final class QueueConfig {
private boolean durable;
private boolean temporary;
private boolean autoCreated;
private Integer maxConsumers;
private RoutingType routingType;
private int maxConsumers;
private boolean deleteOnNoConsumers;
private Builder(final long id, final SimpleString name) {
@ -64,8 +67,9 @@ public final class QueueConfig {
this.durable = true;
this.temporary = false;
this.autoCreated = true;
this.maxConsumers = -1;
this.deleteOnNoConsumers = false;
this.routingType = ActiveMQDefaultConfiguration.getDefaultRoutingType();
this.maxConsumers = ActiveMQDefaultConfiguration.getDefaultMaxQueueConsumers();
this.deleteOnNoConsumers = ActiveMQDefaultConfiguration.getDefaultDeleteQueueOnNoConsumers();
validateState();
}
@ -112,7 +116,7 @@ public final class QueueConfig {
return this;
}
public Builder maxConsumers(final Integer maxConsumers) {
public Builder maxConsumers(final int maxConsumers) {
this.maxConsumers = maxConsumers;
return this;
}
@ -122,6 +126,11 @@ public final class QueueConfig {
return this;
}
public Builder deliveryMode(RoutingType routingType) {
this.routingType = routingType;
return this;
}
/**
* Returns a new {@link QueueConfig} using the parameters configured on the {@link Builder}.
* <br>
@ -143,7 +152,7 @@ public final class QueueConfig {
} else {
pageSubscription = null;
}
return new QueueConfig(id, address, name, filter, pageSubscription, user, durable, temporary, autoCreated, maxConsumers, deleteOnNoConsumers);
return new QueueConfig(id, address, name, filter, pageSubscription, user, durable, temporary, autoCreated, routingType, maxConsumers, deleteOnNoConsumers);
}
}
@ -185,7 +194,8 @@ public final class QueueConfig {
final boolean durable,
final boolean temporary,
final boolean autoCreated,
final Integer maxConsumers,
final RoutingType routingType,
final int maxConsumers,
final boolean deleteOnNoConsumers) {
this.id = id;
this.address = address;
@ -196,6 +206,7 @@ public final class QueueConfig {
this.durable = durable;
this.temporary = temporary;
this.autoCreated = autoCreated;
this.routingType = routingType;
this.deleteOnNoConsumers = deleteOnNoConsumers;
this.maxConsumers = maxConsumers;
}
@ -240,10 +251,14 @@ public final class QueueConfig {
return deleteOnNoConsumers;
}
public Integer maxConsumers() {
public int maxConsumers() {
return maxConsumers;
}
public RoutingType deliveryMode() {
return routingType;
}
@Override
public boolean equals(Object o) {
if (this == o)
@ -269,6 +284,8 @@ public final class QueueConfig {
return false;
if (pageSubscription != null ? !pageSubscription.equals(that.pageSubscription) : that.pageSubscription != null)
return false;
if (routingType != that.routingType)
return false;
if (maxConsumers != that.maxConsumers)
return false;
if (deleteOnNoConsumers != that.deleteOnNoConsumers)
@ -288,6 +305,7 @@ public final class QueueConfig {
result = 31 * result + (durable ? 1 : 0);
result = 31 * result + (temporary ? 1 : 0);
result = 31 * result + (autoCreated ? 1 : 0);
result = 31 * result + routingType.getType();
result = 31 * result + maxConsumers;
result = 31 * result + (deleteOnNoConsumers ? 1 : 0);
return result;
@ -305,6 +323,7 @@ public final class QueueConfig {
+ ", durable=" + durable
+ ", temporary=" + temporary
+ ", autoCreated=" + autoCreated
+ ", routingType=" + routingType
+ ", maxConsumers=" + maxConsumers
+ ", deleteOnNoConsumers=" + deleteOnNoConsumers + '}';
}

View File

@ -104,11 +104,48 @@ public interface ServerSession extends SecurityAuth {
Queue createQueue(SimpleString address,
SimpleString name,
RoutingType routingType,
SimpleString filterString,
boolean temporary,
boolean durable) throws Exception;
AddressInfo createAddress(final SimpleString address, final boolean multicast, final boolean autoCreated) throws Exception;
/** Create queue with default delivery mode
*
* @param address
* @param name
* @param filterString
* @param temporary
* @param durable
* @return
* @throws Exception
*/
Queue createQueue(SimpleString address,
SimpleString name,
SimpleString filterString,
boolean temporary,
boolean durable) throws Exception;
Queue createQueue(SimpleString address,
SimpleString name,
RoutingType routingType,
SimpleString filterString,
boolean temporary,
boolean durable,
int maxConsumers,
boolean deleteOnNoConsumers,
boolean autoCreated) throws Exception;
Queue createQueue(SimpleString address,
SimpleString name,
RoutingType routingType,
SimpleString filterString,
boolean temporary,
boolean durable,
boolean autoCreated) throws Exception;
AddressInfo createAddress(final SimpleString address, Set<RoutingType> routingTypes, final boolean autoCreated) throws Exception;
AddressInfo createAddress(final SimpleString address, RoutingType routingType, final boolean autoCreated) throws Exception;
void deleteQueue(SimpleString name) throws Exception;
@ -186,14 +223,11 @@ public interface ServerSession extends SecurityAuth {
boolean isClosed();
Queue createQueue(SimpleString address,
SimpleString name,
SimpleString filterString,
boolean temporary,
boolean durable,
Integer maxConsumers,
Boolean deleteOnNoConsumers,
final Boolean autoCreated) throws Exception;
void createSharedQueue(SimpleString address,
SimpleString name,
final RoutingType routingType,
boolean durable,
SimpleString filterString) throws Exception;
void createSharedQueue(SimpleString address,
SimpleString name,

View File

@ -52,6 +52,7 @@ import org.apache.activemq.artemis.core.postoffice.impl.PostOfficeImpl;
import org.apache.activemq.artemis.core.server.ActiveMQMessageBundle;
import org.apache.activemq.artemis.core.server.ActiveMQServer;
import org.apache.activemq.artemis.core.server.ActiveMQServerLogger;
import org.apache.activemq.artemis.core.server.RoutingType;
import org.apache.activemq.artemis.core.server.NodeManager;
import org.apache.activemq.artemis.core.server.Queue;
import org.apache.activemq.artemis.core.server.cluster.ActiveMQServerSideProtocolManagerFactory;
@ -719,7 +720,7 @@ public final class ClusterConnectionImpl implements ClusterConnection, AfterConn
} else {
// Add binding in storage so the queue will get reloaded on startup and we can find it - it's never
// actually routed to at that address though
queue = server.createQueue(queueName, queueName, null, true, false);
queue = server.createQueue(queueName, RoutingType.MULTICAST, queueName, null, true, false);
}
// There are a few things that will behave differently when it's an internal queue

View File

@ -110,6 +110,7 @@ import org.apache.activemq.artemis.core.server.ActiveMQServer;
import org.apache.activemq.artemis.core.server.ActiveMQServerLogger;
import org.apache.activemq.artemis.core.server.Bindable;
import org.apache.activemq.artemis.core.server.BindingQueryResult;
import org.apache.activemq.artemis.core.server.RoutingType;
import org.apache.activemq.artemis.core.server.Divert;
import org.apache.activemq.artemis.core.server.JournalType;
import org.apache.activemq.artemis.core.server.LargeServerMessage;
@ -1462,11 +1463,12 @@ public class ActiveMQServerImpl implements ActiveMQServer {
@Override
public Queue createQueue(final SimpleString address,
final RoutingType routingType,
final SimpleString queueName,
final SimpleString filterString,
final boolean durable,
final boolean temporary) throws Exception {
return createQueue(address, queueName, filterString, null, durable, temporary, false, false, false);
return createQueue(address, routingType, queueName, filterString, null, durable, temporary, ActiveMQDefaultConfiguration.getDefaultMaxQueueConsumers(), ActiveMQDefaultConfiguration.getDefaultDeleteQueueOnNoConsumers(), true);
}
@Override
@ -1474,51 +1476,61 @@ public class ActiveMQServerImpl implements ActiveMQServer {
final SimpleString queueName,
final SimpleString filterString,
final boolean durable,
final boolean temporary,
final Integer maxConsumers,
final Boolean deleteOnNoConsumers,
final boolean autoCreateAddress) throws Exception {
return createQueue(address, queueName, filterString, null, durable, temporary, false, false, false, maxConsumers, deleteOnNoConsumers, autoCreateAddress);
final boolean temporary) throws Exception {
return createQueue(address, ActiveMQDefaultConfiguration.getDefaultRoutingType(), queueName, filterString, durable, temporary);
}
@Override
public Queue createQueue(final SimpleString address,
final RoutingType routingType,
final SimpleString queueName,
final SimpleString filterString,
final boolean durable,
final boolean temporary,
final int maxConsumers,
final boolean deleteOnNoConsumers,
final boolean autoCreateAddress) throws Exception {
return createQueue(address, queueName, routingType, filterString, null, durable, temporary, false, false, false, maxConsumers, deleteOnNoConsumers, autoCreateAddress);
}
@Override
public Queue createQueue(final SimpleString address,
final RoutingType routingType,
final SimpleString queueName,
final SimpleString filterString,
final SimpleString user,
final boolean durable,
final boolean temporary) throws Exception {
return createQueue(address, queueName, filterString, user, durable, temporary, false, false, false);
return createQueue(address, routingType, queueName, filterString, user, durable, temporary, ActiveMQDefaultConfiguration.getDefaultMaxQueueConsumers(), ActiveMQDefaultConfiguration.getDefaultDeleteQueueOnNoConsumers(), true);
}
@Override
public Queue createQueue(SimpleString address,
SimpleString queueName,
SimpleString filter,
public Queue createQueue(SimpleString address, RoutingType routingType, SimpleString queueName, SimpleString filter,
SimpleString user,
boolean durable,
boolean temporary,
Integer maxConsumers,
Boolean deleteOnNoConsumers,
int maxConsumers,
boolean deleteOnNoConsumers,
boolean autoCreateAddress) throws Exception {
return createQueue(address, queueName, filter, user, durable, temporary, false, false, false, maxConsumers, deleteOnNoConsumers, autoCreateAddress);
return createQueue(address, queueName, routingType, filter, user, durable, temporary, false, false, false, maxConsumers, deleteOnNoConsumers, autoCreateAddress);
}
@Override
public Queue createQueue(final SimpleString address,
final RoutingType routingType,
final SimpleString queueName,
final SimpleString filterString,
final SimpleString user,
final boolean durable,
final boolean temporary,
final boolean autoCreated) throws Exception {
return createQueue(address, queueName, filterString, user, durable, temporary, false, false, autoCreated);
return createQueue(address, routingType, queueName, filterString, user, durable, temporary,
ActiveMQDefaultConfiguration.getDefaultMaxQueueConsumers(),
ActiveMQDefaultConfiguration.getDefaultDeleteQueueOnNoConsumers(), autoCreated);
}
@Override
public Queue createQueue(SimpleString address,
SimpleString queueName,
SimpleString filter,
public Queue createQueue(SimpleString address, RoutingType routingType, SimpleString queueName, SimpleString filter,
SimpleString user,
boolean durable,
boolean temporary,
@ -1526,20 +1538,27 @@ public class ActiveMQServerImpl implements ActiveMQServer {
Integer maxConsumers,
Boolean deleteOnNoConsumers,
boolean autoCreateAddress) throws Exception {
return createQueue(address, queueName, filter, user, durable, temporary, false, false, autoCreated, maxConsumers, deleteOnNoConsumers, autoCreateAddress);
return createQueue(address, queueName, routingType, filter, user, durable, temporary, false, false, autoCreated, maxConsumers, deleteOnNoConsumers, autoCreateAddress);
}
@Override
public void createSharedQueue(final SimpleString address,
final SimpleString name,
final SimpleString filterString,
public void createSharedQueue(final SimpleString address, RoutingType routingType, final SimpleString name, final SimpleString filterString,
final SimpleString user,
boolean durable) throws Exception {
//force the old contract about address
if (address == null) {
throw new NullPointerException("address can't be null!");
}
final Queue queue = createQueue(address, name, filterString, user, durable, !durable, true, !durable, false);
if (routingType == null) {
AddressInfo addressInfo = getAddressInfo(address);
routingType = addressInfo.getRoutingTypes().size() == 1 ? addressInfo.getRoutingType() : ActiveMQDefaultConfiguration.getDefaultRoutingType();
if (routingType == null) {
// TODO (mtaylor) throw exception Can not determine routing type info from address
}
}
final Queue queue = createQueue(address, routingType, name, filterString, user, durable, !durable, false);
if (!queue.getAddress().equals(address)) {
throw ActiveMQMessageBundle.BUNDLE.queueSubscriptionBelongsToDifferentAddress(name);
@ -1578,34 +1597,55 @@ public class ActiveMQServerImpl implements ActiveMQServer {
final SimpleString filterString,
final boolean durable,
final boolean temporary) throws Exception {
return deployQueue(address, resourceName, filterString, durable, temporary, false);
return deployQueue(address, ActiveMQDefaultConfiguration.getDefaultRoutingType(), resourceName, filterString, durable, temporary, false);
}
@Override
public Queue deployQueue(final String address,
final String resourceName,
final String filterString,
final boolean durable,
final boolean temporary) throws Exception {
return deployQueue(SimpleString.toSimpleString(address), SimpleString.toSimpleString(resourceName), SimpleString.toSimpleString(filterString), durable, temporary);
}
@Override
public Queue deployQueue(final SimpleString address,
final RoutingType routingType,
final SimpleString resourceName,
final SimpleString filterString,
final boolean durable,
final boolean temporary) throws Exception {
return deployQueue(address, routingType, resourceName, filterString, durable, temporary, false);
}
@Override
public Queue deployQueue(final SimpleString address,
final RoutingType routingType,
final SimpleString queueName,
final SimpleString filterString,
final boolean durable,
final boolean temporary,
final boolean autoCreated) throws Exception {
return deployQueue(address, queueName, filterString, durable, temporary, autoCreated, null, null, true);
return deployQueue(address, routingType, queueName, filterString, durable, temporary, autoCreated, ActiveMQDefaultConfiguration.getDefaultMaxQueueConsumers(), ActiveMQDefaultConfiguration.getDefaultDeleteQueueOnNoConsumers(), true);
}
@Override
public Queue deployQueue(final SimpleString address,
final RoutingType routingType,
final SimpleString queueName,
final SimpleString filterString,
final boolean durable,
final boolean temporary,
final boolean autoCreated,
final Integer maxConsumers,
final Boolean deleteOnNoConsumers,
final int maxConsumers,
final boolean deleteOnNoConsumers,
final boolean autoCreateAddress) throws Exception {
// TODO: fix logging here as this could be for a topic or queue
ActiveMQServerLogger.LOGGER.deployQueue(queueName);
return createQueue(address, queueName, filterString, null, durable, temporary, true, false, autoCreated, maxConsumers, deleteOnNoConsumers, autoCreateAddress);
return createQueue(address, queueName, routingType, filterString, null, durable, temporary, true, false, autoCreated, maxConsumers, deleteOnNoConsumers, autoCreateAddress);
}
@Override
@ -2209,11 +2249,7 @@ public class ActiveMQServerImpl implements ActiveMQServer {
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.setDefaultMaxQueueConsumers(config.getDefaultMaxConsumers());
AddressInfo info = new AddressInfo(SimpleString.toSimpleString(config.getName()), config.getRoutingTypes());
createOrUpdateAddressInfo(info);
deployQueuesFromListCoreQueueConfiguration(config.getQueueConfigurations());
}
@ -2221,7 +2257,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(), true);
deployQueue(SimpleString.toSimpleString(config.getAddress()), config.getRoutingType(), SimpleString.toSimpleString(config.getName()), SimpleString.toSimpleString(config.getFilterString()), config.isDurable(), false, false, config.getMaxConsumers(), config.getDeleteOnNoConsumers(), true);
}
}
@ -2378,21 +2414,10 @@ public class ActiveMQServerImpl implements ActiveMQServer {
return postOffice.getAddressInfo(address);
}
private Queue createQueue(final SimpleString addressName,
final SimpleString queueName,
final SimpleString filterString,
final SimpleString user,
final boolean durable,
final boolean temporary,
final boolean ignoreIfExists,
final boolean transientQueue,
final boolean autoCreated) throws Exception {
return createQueue(addressName, queueName, filterString, user, durable, temporary, ignoreIfExists, transientQueue, autoCreated, null, null, true);
}
@Override
public Queue createQueue(final SimpleString addressName,
final SimpleString queueName,
final RoutingType routingType,
final SimpleString filterString,
final SimpleString user,
final boolean durable,
@ -2400,8 +2425,8 @@ public class ActiveMQServerImpl implements ActiveMQServer {
final boolean ignoreIfExists,
final boolean transientQueue,
final boolean autoCreated,
final Integer maxConsumers,
final Boolean deleteOnNoConsumers,
final int maxConsumers,
final boolean deleteOnNoConsumers,
final boolean autoCreateAddress) throws Exception {
final QueueBinding binding = (QueueBinding) postOffice.getBinding(queueName);
@ -2426,27 +2451,32 @@ public class ActiveMQServerImpl implements ActiveMQServer {
}
AddressInfo defaultAddressInfo = new AddressInfo(addressName);
defaultAddressInfo.addRoutingType(ActiveMQDefaultConfiguration.getDefaultRoutingType());
AddressInfo info = postOffice.getAddressInfo(addressName);
if (info == null) {
if (autoCreateAddress) {
info = defaultAddressInfo;
postOffice.addAddressInfo(defaultAddressInfo);
info = postOffice.getAddressInfo(addressName);
} else {
throw ActiveMQMessageBundle.BUNDLE.addressDoesNotExist(addressName);
}
}
final boolean isDeleteOnNoConsumers = deleteOnNoConsumers == null ? info.isDefaultDeleteOnNoConsumers() : deleteOnNoConsumers;
final int noMaxConsumers = maxConsumers == null ? info.getDefaultMaxQueueConsumers() : maxConsumers;
final QueueConfig queueConfig = queueConfigBuilder.filter(filter).pagingManager(pagingManager).user(user).durable(durable).temporary(temporary).autoCreated(autoCreated).deliveryMode(routingType).maxConsumers(maxConsumers).deleteOnNoConsumers(deleteOnNoConsumers).build();
final QueueConfig queueConfig = queueConfigBuilder.filter(filter).pagingManager(pagingManager).user(user).durable(durable).temporary(temporary).autoCreated(autoCreated).deleteOnNoConsumers(isDeleteOnNoConsumers).maxConsumers(noMaxConsumers).build();
final Queue queue = queueFactory.createQueueWith(queueConfig);
boolean addressAlreadyExists = true;
if (postOffice.getAddressInfo(queue.getAddress()) == null) {
postOffice.addAddressInfo(new AddressInfo(queue.getAddress()).setRoutingType(AddressInfo.RoutingType.MULTICAST).setDefaultMaxQueueConsumers(maxConsumers == null ? ActiveMQDefaultConfiguration.getDefaultMaxQueueConsumers() : maxConsumers));
AddressInfo addressInfo = postOffice.getAddressInfo(queue.getAddress());
if (addressInfo == null) {
postOffice.addAddressInfo(new AddressInfo(queue.getAddress()));
addressAlreadyExists = false;
} else {
if (!addressInfo.getRoutingTypes().contains(routingType)) {
throw ActiveMQMessageBundle.BUNDLE.invalidRoutingTypeForAddress(routingType, addressInfo.getName().toString(), addressInfo.getRoutingTypes());
}
}
if (transientQueue) {
@ -2455,7 +2485,7 @@ public class ActiveMQServerImpl implements ActiveMQServer {
queue.setConsumersRefCount(new AutoCreatedQueueManagerImpl(this, queue.getName()));
}
final QueueBinding localQueueBinding = new LocalQueueBinding(getAddressInfo(queue.getAddress()), queue, nodeManager.getNodeId());
final QueueBinding localQueueBinding = new LocalQueueBinding(queue.getAddress(), queue, nodeManager.getNodeId());
if (queue.isDurable()) {
storageManager.addQueueBinding(txID, localQueueBinding);

View File

@ -16,8 +16,12 @@
*/
package org.apache.activemq.artemis.core.server.impl;
import org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import org.apache.activemq.artemis.api.core.SimpleString;
import org.apache.activemq.artemis.core.server.RoutingType;
public class AddressInfo {
@ -25,52 +29,36 @@ public class AddressInfo {
private final SimpleString name;
private RoutingType routingType = RoutingType.MULTICAST;
private boolean defaultDeleteOnNoConsumers = ActiveMQDefaultConfiguration.getDefaultDeleteQueueOnNoConsumers();
private int defaultMaxQueueConsumers = ActiveMQDefaultConfiguration.getDefaultMaxQueueConsumers();
private boolean autoCreated = false;
private boolean deletable = false;
private Set<RoutingType> routingTypes;
public AddressInfo(SimpleString name) {
this.name = name;
routingTypes = new HashSet<>();
}
public AddressInfo(SimpleString name, RoutingType routingType, boolean defaultDeleteOnNoConsumers, int defaultMaxConsumers) {
this(name);
this.routingType = routingType;
this.defaultDeleteOnNoConsumers = defaultDeleteOnNoConsumers;
this.defaultMaxQueueConsumers = defaultMaxConsumers;
/**
* Creates an AddressInfo object with a Set of routing types
* @param name
* @param routingTypes
*/
public AddressInfo(SimpleString name, Set<RoutingType> routingTypes) {
this.name = name;
this.routingTypes = routingTypes;
}
public RoutingType getRoutingType() {
return routingType;
}
public AddressInfo setRoutingType(RoutingType routingType) {
this.routingType = routingType;
return this;
}
public boolean isDefaultDeleteOnNoConsumers() {
return defaultDeleteOnNoConsumers;
}
public AddressInfo setDefaultDeleteOnNoConsumers(boolean defaultDeleteOnNoConsumers) {
this.defaultDeleteOnNoConsumers = defaultDeleteOnNoConsumers;
return this;
}
public int getDefaultMaxQueueConsumers() {
return defaultMaxQueueConsumers;
}
public AddressInfo setDefaultMaxQueueConsumers(int defaultMaxQueueConsumers) {
this.defaultMaxQueueConsumers = defaultMaxQueueConsumers;
return this;
/**
* Creates an AddressInfo object with a single RoutingType associated with it.
* @param name
* @param routingType
*/
public AddressInfo(SimpleString name, RoutingType routingType) {
this.name = name;
this.routingTypes = new HashSet<>();
routingTypes.add(routingType);
}
public boolean isAutoCreated() {
@ -94,42 +82,47 @@ public class AddressInfo {
return id;
}
public Set<RoutingType> getRoutingTypes() {
return routingTypes;
}
public AddressInfo setRoutingTypes(Set<RoutingType> routingTypes) {
this.routingTypes = routingTypes;
return this;
}
public AddressInfo addRoutingType(RoutingType routingType) {
if (routingTypes == null) {
routingTypes = new HashSet<>();
}
routingTypes.add(routingType);
return this;
}
public RoutingType getRoutingType() {
/* We want to use a Set to guarantee only a single entry for ANYCAST, MULTICAST can be added to routing types.
There are cases where we also want to get any routing type (when a queue doesn't specifyc it's routing type for
example. For this reason we return the first element in the Set.
*/
// TODO There must be a better way of doing this. This creates an iterator on each lookup.
for (RoutingType routingType : routingTypes) {
return routingType;
}
return null;
}
@Override
public String toString() {
StringBuffer buff = new StringBuffer();
buff.append("Address [name=" + name);
buff.append(", id=" + id);
buff.append(", routingType=" + routingType);
buff.append(", defaultMaxQueueConsumers=" + defaultMaxQueueConsumers);
buff.append(", defaultDeleteOnNoConsumers=" + defaultDeleteOnNoConsumers);
buff.append(", routingTypes={");
for (RoutingType routingType : routingTypes) {
buff.append(routingType.toString() + ",");
}
buff.append(", autoCreated=" + autoCreated);
buff.append("]");
return buff.toString();
}
public enum RoutingType {
MULTICAST, ANYCAST;
public byte getType() {
switch (this) {
case MULTICAST:
return 0;
case ANYCAST:
return 1;
default:
return -1;
}
}
public static RoutingType getType(byte type) {
switch (type) {
case 0:
return MULTICAST;
case 1:
return ANYCAST;
default:
return null;
}
}
}
}

View File

@ -28,6 +28,7 @@ import org.apache.activemq.artemis.core.paging.cursor.PageSubscription;
import org.apache.activemq.artemis.core.persistence.StorageManager;
import org.apache.activemq.artemis.core.postoffice.PostOffice;
import org.apache.activemq.artemis.core.server.ActiveMQServerLogger;
import org.apache.activemq.artemis.core.server.RoutingType;
import org.apache.activemq.artemis.core.server.MessageReference;
import org.apache.activemq.artemis.core.server.Queue;
import org.apache.activemq.artemis.core.server.ServerMessage;
@ -56,6 +57,7 @@ public class LastValueQueue extends QueueImpl {
final boolean durable,
final boolean temporary,
final boolean autoCreated,
final RoutingType routingType,
final Integer maxConsumers,
final Boolean deleteOnNoConsumers,
final ScheduledExecutorService scheduledExecutor,
@ -63,7 +65,7 @@ public class LastValueQueue extends QueueImpl {
final StorageManager storageManager,
final HierarchicalRepository<AddressSettings> addressSettingsRepository,
final Executor executor) {
super(persistenceID, address, name, filter, pageSubscription, user, durable, temporary, autoCreated, maxConsumers, deleteOnNoConsumers, scheduledExecutor, postOffice, storageManager, addressSettingsRepository, executor);
super(persistenceID, address, name, filter, pageSubscription, user, durable, temporary, autoCreated, routingType, maxConsumers, deleteOnNoConsumers, scheduledExecutor, postOffice, storageManager, addressSettingsRepository, executor);
new Exception("LastValueQeue " + this).toString();
}

View File

@ -160,7 +160,7 @@ public class PostOfficeJournalLoader implements JournalLoader {
}
}
final Binding binding = new LocalQueueBinding(postOffice.getAddressInfo(queue.getAddress()), queue, nodeManager.getNodeId());
final Binding binding = new LocalQueueBinding(queue.getAddress(), queue, nodeManager.getNodeId());
queues.put(queue.getID(), queue);
postOffice.addBinding(binding);
@ -178,9 +178,7 @@ public class PostOfficeJournalLoader implements JournalLoader {
// TODO: figure out what else to set here
AddressInfo addressInfo = new AddressInfo(addressBindingInfo.getName())
.setRoutingType(addressBindingInfo.getRoutingType())
.setDefaultMaxQueueConsumers(addressBindingInfo.getDefaultMaxConsumers());
.setRoutingTypes(addressBindingInfo.getRoutingTypes());
postOffice.addAddressInfo(addressInfo);
managementService.registerAddress(addressInfo);
}

View File

@ -18,6 +18,7 @@ package org.apache.activemq.artemis.core.server.impl;
import java.util.concurrent.ScheduledExecutorService;
import org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration;
import org.apache.activemq.artemis.api.core.SimpleString;
import org.apache.activemq.artemis.core.filter.Filter;
import org.apache.activemq.artemis.core.paging.cursor.PageSubscription;
@ -75,9 +76,9 @@ public class QueueFactoryImpl implements QueueFactory {
final AddressSettings addressSettings = addressSettingsRepository.getMatch(config.address().toString());
final Queue queue;
if (addressSettings.isLastValueQueue()) {
queue = new LastValueQueue(config.id(), config.address(), config.name(), config.filter(), config.pageSubscription(), config.user(), config.isDurable(), config.isTemporary(), config.isAutoCreated(), config.maxConsumers(), config.isDeleteOnNoConsumers(), scheduledExecutor, postOffice, storageManager, addressSettingsRepository, executorFactory.getExecutor());
queue = new LastValueQueue(config.id(), config.address(), config.name(), config.filter(), config.pageSubscription(), config.user(), config.isDurable(), config.isTemporary(), config.isAutoCreated(), config.deliveryMode(), config.maxConsumers(), config.isDeleteOnNoConsumers(), scheduledExecutor, postOffice, storageManager, addressSettingsRepository, executorFactory.getExecutor());
} else {
queue = new QueueImpl(config.id(), config.address(), config.name(), config.filter(), config.pageSubscription(), config.user(), config.isDurable(), config.isTemporary(), config.isAutoCreated(), config.maxConsumers(), config.isDeleteOnNoConsumers(), scheduledExecutor, postOffice, storageManager, addressSettingsRepository, executorFactory.getExecutor());
queue = new QueueImpl(config.id(), config.address(), config.name(), config.filter(), config.pageSubscription(), config.user(), config.isDurable(), config.isTemporary(), config.isAutoCreated(), config.deliveryMode(), config.maxConsumers(), config.isDeleteOnNoConsumers(), scheduledExecutor, postOffice, storageManager, addressSettingsRepository, executorFactory.getExecutor());
}
return queue;
}
@ -101,7 +102,7 @@ public class QueueFactoryImpl implements QueueFactory {
Queue queue;
if (addressSettings.isLastValueQueue()) {
queue = new LastValueQueue(persistenceID, address, name, filter, pageSubscription, user, durable, temporary, autoCreated, null, null, scheduledExecutor, postOffice, storageManager, addressSettingsRepository, executorFactory.getExecutor());
queue = new LastValueQueue(persistenceID, address, name, filter, pageSubscription, user, durable, temporary, autoCreated, ActiveMQDefaultConfiguration.getDefaultRoutingType(), ActiveMQDefaultConfiguration.getDefaultMaxQueueConsumers(), ActiveMQDefaultConfiguration.getDefaultDeleteQueueOnNoConsumers(), scheduledExecutor, postOffice, storageManager, addressSettingsRepository, executorFactory.getExecutor());
} else {
queue = new QueueImpl(persistenceID, address, name, filter, pageSubscription, user, durable, temporary, autoCreated, scheduledExecutor, postOffice, storageManager, addressSettingsRepository, executorFactory.getExecutor());
}

View File

@ -65,6 +65,7 @@ import org.apache.activemq.artemis.core.server.ActiveMQMessageBundle;
import org.apache.activemq.artemis.core.server.ActiveMQServer;
import org.apache.activemq.artemis.core.server.ActiveMQServerLogger;
import org.apache.activemq.artemis.core.server.Consumer;
import org.apache.activemq.artemis.core.server.RoutingType;
import org.apache.activemq.artemis.core.server.HandleStatus;
import org.apache.activemq.artemis.core.server.MessageReference;
import org.apache.activemq.artemis.core.server.Queue;
@ -247,6 +248,8 @@ public class QueueImpl implements Queue {
private final AtomicInteger noConsumers = new AtomicInteger(0);
private RoutingType routingType;
/**
* This is to avoid multi-thread races on calculating direct delivery,
* to guarantee ordering will be always be correct
@ -343,7 +346,7 @@ public class QueueImpl implements Queue {
final StorageManager storageManager,
final HierarchicalRepository<AddressSettings> addressSettingsRepository,
final Executor executor) {
this(id, address, name, filter, pageSubscription, user, durable, temporary, autoCreated, null, null, scheduledExecutor, postOffice, storageManager, addressSettingsRepository, executor);
this(id, address, name, filter, pageSubscription, user, durable, temporary, autoCreated, RoutingType.MULTICAST, null, null, scheduledExecutor, postOffice, storageManager, addressSettingsRepository, executor);
}
public QueueImpl(final long id,
@ -355,6 +358,7 @@ public class QueueImpl implements Queue {
final boolean durable,
final boolean temporary,
final boolean autoCreated,
final RoutingType routingType,
final Integer maxConsumers,
final Boolean deleteOnNoConsumers,
final ScheduledExecutorService scheduledExecutor,
@ -369,6 +373,8 @@ public class QueueImpl implements Queue {
this.addressInfo = postOffice == null ? null : postOffice.getAddressInfo(address);
this.routingType = routingType;
this.name = name;
this.filter = filter;
@ -381,9 +387,9 @@ public class QueueImpl implements Queue {
this.autoCreated = autoCreated;
this.maxConsumers = maxConsumers == null ? (addressInfo == null ? ActiveMQDefaultConfiguration.getDefaultMaxQueueConsumers() : addressInfo.getDefaultMaxQueueConsumers()) : maxConsumers;
this.maxConsumers = maxConsumers == null ? ActiveMQDefaultConfiguration.getDefaultMaxQueueConsumers() : maxConsumers;
this.deleteOnNoConsumers = deleteOnNoConsumers == null ? (addressInfo == null ? ActiveMQDefaultConfiguration.getDefaultDeleteQueueOnNoConsumers() : addressInfo.isDefaultDeleteOnNoConsumers()) : deleteOnNoConsumers;
this.deleteOnNoConsumers = deleteOnNoConsumers == null ? ActiveMQDefaultConfiguration.getDefaultDeleteQueueOnNoConsumers() : deleteOnNoConsumers;
this.postOffice = postOffice;
@ -501,6 +507,18 @@ public class QueueImpl implements Queue {
return pageSubscription;
}
@Override
public RoutingType getRoutingType() {
return routingType;
}
@Override
public void setRoutingType(RoutingType routingType) {
if (addressInfo.getRoutingTypes().contains(routingType)) {
this.routingType = routingType;
}
}
@Override
public Filter getFilter() {
return filter;
@ -755,7 +773,7 @@ public class QueueImpl implements Queue {
synchronized (this) {
if (maxConsumers != -1 && noConsumers.get() >= maxConsumers) {
if (maxConsumers != MAX_CONSUMERS_UNLIMITED && noConsumers.get() >= maxConsumers) {
throw ActiveMQMessageBundle.BUNDLE.maxConsumerLimitReachedForQueue(address, name);
}

View File

@ -31,6 +31,7 @@ import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicLong;
import org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration;
import org.apache.activemq.artemis.api.core.ActiveMQException;
import org.apache.activemq.artemis.api.core.ActiveMQIOErrorException;
import org.apache.activemq.artemis.api.core.ActiveMQIllegalStateException;
@ -65,6 +66,7 @@ import org.apache.activemq.artemis.core.server.ActiveMQMessageBundle;
import org.apache.activemq.artemis.core.server.ActiveMQServer;
import org.apache.activemq.artemis.core.server.ActiveMQServerLogger;
import org.apache.activemq.artemis.core.server.BindingQueryResult;
import org.apache.activemq.artemis.core.server.RoutingType;
import org.apache.activemq.artemis.core.server.LargeServerMessage;
import org.apache.activemq.artemis.core.server.MessageReference;
import org.apache.activemq.artemis.core.server.Queue;
@ -489,18 +491,44 @@ public class ServerSessionImpl implements ServerSession, FailureListener {
final SimpleString filterString,
final boolean temporary,
final boolean durable) throws Exception {
return createQueue(address, name, filterString, temporary, durable, null, null, false);
return createQueue(address,
name,
ActiveMQDefaultConfiguration.getDefaultRoutingType(),
filterString,
temporary,
durable,
ActiveMQDefaultConfiguration.getDefaultMaxQueueConsumers(),
ActiveMQDefaultConfiguration.getDefaultDeleteQueueOnNoConsumers(),
false);
}
@Override
public Queue createQueue(final SimpleString address,
final SimpleString name,
final RoutingType routingType,
final SimpleString filterString,
final boolean temporary,
final boolean durable) throws Exception {
return createQueue(address,
name, routingType,
filterString,
temporary,
durable,
ActiveMQDefaultConfiguration.getDefaultMaxQueueConsumers(),
ActiveMQDefaultConfiguration.getDefaultDeleteQueueOnNoConsumers(),
false);
}
@Override
public Queue createQueue(final SimpleString address,
final SimpleString name,
final RoutingType routingType,
final SimpleString filterString,
final boolean temporary,
final boolean durable,
final Integer maxConsumers,
final Boolean deleteOnNoConsumers,
final Boolean autoCreated) throws Exception {
final int maxConsumers,
final boolean deleteOnNoConsumers,
final boolean autoCreated) throws Exception {
if (durable) {
// make sure the user has privileges to create this queue
securityCheck(address, CheckType.CREATE_DURABLE_QUEUE, this);
@ -510,7 +538,7 @@ public class ServerSessionImpl implements ServerSession, FailureListener {
server.checkQueueCreationLimit(getUsername());
Queue queue = server.createQueue(address, name, filterString, SimpleString.toSimpleString(getUsername()), durable, temporary, autoCreated, maxConsumers, deleteOnNoConsumers, true);
Queue queue = server.createQueue(address, routingType, name, filterString, SimpleString.toSimpleString(getUsername()), durable, temporary, autoCreated, maxConsumers, deleteOnNoConsumers, true);
if (temporary) {
// Temporary queue in core simply means the queue will be deleted if
@ -541,13 +569,46 @@ public class ServerSessionImpl implements ServerSession, FailureListener {
}
@Override
public AddressInfo createAddress(final SimpleString address, final boolean multicast, final boolean autoCreated) throws Exception {
public Queue createQueue(SimpleString address,
SimpleString name,
RoutingType routingType,
SimpleString filterString,
boolean temporary,
boolean durable,
boolean autoCreated) throws Exception {
return createQueue(address,
name, routingType,
filterString,
temporary,
durable,
ActiveMQDefaultConfiguration.getDefaultMaxQueueConsumers(),
ActiveMQDefaultConfiguration.getDefaultDeleteQueueOnNoConsumers(),
autoCreated);
}
@Override
public AddressInfo createAddress(final SimpleString address, Set<RoutingType> routingTypes, final boolean autoCreated) throws Exception {
securityCheck(address, CheckType.CREATE_ADDRESS, this);
AddressInfo.RoutingType routingType = multicast ? AddressInfo.RoutingType.MULTICAST : AddressInfo.RoutingType.ANYCAST;
return server.createOrUpdateAddressInfo(new AddressInfo(address, routingTypes).setAutoCreated(autoCreated));
}
AddressInfo addressInfo = server.createOrUpdateAddressInfo(new AddressInfo(address).setRoutingType(routingType).setAutoCreated(autoCreated));
@Override
public AddressInfo createAddress(final SimpleString address, RoutingType routingType, final boolean autoCreated) throws Exception {
securityCheck(address, CheckType.CREATE_ADDRESS, this);
return server.createOrUpdateAddressInfo(new AddressInfo(address, routingType).setAutoCreated(autoCreated));
}
return addressInfo;
@Override
public void createSharedQueue(final SimpleString address,
final SimpleString name,
final RoutingType routingType,
boolean durable,
final SimpleString filterString) throws Exception {
securityCheck(address, CheckType.CREATE_NON_DURABLE_QUEUE, this);
server.checkQueueCreationLimit(getUsername());
server.createSharedQueue(address, routingType, name, filterString, SimpleString.toSimpleString(getUsername()), durable);
}
@Override
@ -555,11 +616,7 @@ public class ServerSessionImpl implements ServerSession, FailureListener {
final SimpleString name,
boolean durable,
final SimpleString filterString) throws Exception {
securityCheck(address, CheckType.CREATE_NON_DURABLE_QUEUE, this);
server.checkQueueCreationLimit(getUsername());
server.createSharedQueue(address, name, filterString, SimpleString.toSimpleString(getUsername()), durable);
createSharedQueue(address, name, null, durable, filterString);
}
@Override

View File

@ -2577,12 +2577,6 @@
<!-- 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>
@ -2596,7 +2590,19 @@
<xsd:complexType name="addressType">
<xsd:all>
<xsd:element name="queues" maxOccurs="1" minOccurs="0">
<xsd:element name="anycast" 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:element name="multicast" maxOccurs="1" minOccurs="0">
<xsd:annotation>
<xsd:documentation>
a list of pre configured queues to create
@ -2616,31 +2622,6 @@
</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">

View File

@ -23,10 +23,12 @@ import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardCopyOption;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration;
import org.apache.activemq.artemis.api.core.BroadcastGroupConfiguration;
import org.apache.activemq.artemis.api.core.DiscoveryGroupConfiguration;
import org.apache.activemq.artemis.api.core.SimpleString;
@ -43,7 +45,9 @@ import org.apache.activemq.artemis.core.config.HAPolicyConfiguration;
import org.apache.activemq.artemis.core.config.ha.LiveOnlyPolicyConfiguration;
import org.apache.activemq.artemis.core.remoting.impl.netty.TransportConstants;
import org.apache.activemq.artemis.core.security.Role;
import org.apache.activemq.artemis.core.server.RoutingType;
import org.apache.activemq.artemis.core.server.JournalType;
import org.apache.activemq.artemis.core.server.Queue;
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.LegacyLDAPSecuritySettingPlugin;
@ -51,9 +55,6 @@ 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";
@ -373,12 +374,14 @@ public class FileConfigurationTest extends ConfigurationImplTest {
}
private void verifyAddresses() {
assertEquals(2, conf.getAddressConfigurations().size());
assertEquals(3, conf.getAddressConfigurations().size());
// Addr 1
CoreAddressConfiguration addressConfiguration = conf.getAddressConfigurations().get(0);
assertEquals("addr1", addressConfiguration.getName());
assertEquals(ANYCAST, addressConfiguration.getRoutingType());
Set<RoutingType> routingTypes = new HashSet<>();
routingTypes.add(RoutingType.ANYCAST);
assertEquals(routingTypes, addressConfiguration.getRoutingTypes());
assertEquals(2, addressConfiguration.getQueueConfigurations().size());
// Addr 1 Queue 1
@ -387,9 +390,9 @@ public class FileConfigurationTest extends ConfigurationImplTest {
assertEquals("q1", queueConfiguration.getName());
assertFalse(queueConfiguration.isDurable());
assertEquals("color='blue'", queueConfiguration.getFilterString());
assertEquals(addressConfiguration.getDefaultDeleteOnNoConsumers(), queueConfiguration.getDeleteOnNoConsumers());
assertEquals(ActiveMQDefaultConfiguration.getDefaultDeleteQueueOnNoConsumers(), queueConfiguration.getDeleteOnNoConsumers());
assertEquals("addr1", queueConfiguration.getAddress());
assertEquals(addressConfiguration.getDefaultMaxConsumers(), queueConfiguration.getMaxConsumers());
assertEquals(ActiveMQDefaultConfiguration.getDefaultMaxQueueConsumers(), queueConfiguration.getMaxConsumers());
// Addr 1 Queue 2
queueConfiguration = addressConfiguration.getQueueConfigurations().get(1);
@ -397,14 +400,16 @@ public class FileConfigurationTest extends ConfigurationImplTest {
assertEquals("q2", queueConfiguration.getName());
assertTrue(queueConfiguration.isDurable());
assertEquals("color='green'", queueConfiguration.getFilterString());
assertEquals(new Integer(-1), queueConfiguration.getMaxConsumers());
assertEquals(Queue.MAX_CONSUMERS_UNLIMITED, queueConfiguration.getMaxConsumers());
assertFalse(queueConfiguration.getDeleteOnNoConsumers());
assertEquals("addr1", queueConfiguration.getAddress());
// Addr 2
addressConfiguration = conf.getAddressConfigurations().get(1);
assertEquals("addr2", addressConfiguration.getName());
assertEquals(MULTICAST, addressConfiguration.getRoutingType());
routingTypes = new HashSet<>();
routingTypes.add(RoutingType.MULTICAST);
assertEquals(routingTypes, addressConfiguration.getRoutingTypes());
assertEquals(2, addressConfiguration.getQueueConfigurations().size());
// Addr 2 Queue 1
@ -413,8 +418,8 @@ public class FileConfigurationTest extends ConfigurationImplTest {
assertEquals("q3", queueConfiguration.getName());
assertTrue(queueConfiguration.isDurable());
assertEquals("color='red'", queueConfiguration.getFilterString());
assertEquals(new Integer(10), queueConfiguration.getMaxConsumers());
assertEquals(addressConfiguration.getDefaultDeleteOnNoConsumers(), queueConfiguration.getDeleteOnNoConsumers());
assertEquals(10, queueConfiguration.getMaxConsumers());
assertEquals(ActiveMQDefaultConfiguration.getDefaultDeleteQueueOnNoConsumers(), queueConfiguration.getDeleteOnNoConsumers());
assertEquals("addr2", queueConfiguration.getAddress());
// Addr 2 Queue 2
@ -423,9 +428,17 @@ public class FileConfigurationTest extends ConfigurationImplTest {
assertEquals("q4", queueConfiguration.getName());
assertTrue(queueConfiguration.isDurable());
assertNull(queueConfiguration.getFilterString());
assertEquals(addressConfiguration.getDefaultMaxConsumers(), queueConfiguration.getMaxConsumers());
assertEquals(ActiveMQDefaultConfiguration.getDefaultMaxQueueConsumers(), queueConfiguration.getMaxConsumers());
assertTrue(queueConfiguration.getDeleteOnNoConsumers());
assertEquals("addr2", queueConfiguration.getAddress());
// Addr 3
addressConfiguration = conf.getAddressConfigurations().get(2);
assertEquals("addr2", addressConfiguration.getName());
routingTypes = new HashSet<>();
routingTypes.add(RoutingType.MULTICAST);
routingTypes.add(RoutingType.ANYCAST);
assertEquals(routingTypes, addressConfiguration.getRoutingTypes());
}
@Test

View File

@ -24,6 +24,7 @@ import org.apache.activemq.artemis.api.core.client.ClientSession;
import org.apache.activemq.artemis.api.core.client.ClientSessionFactory;
import org.apache.activemq.artemis.api.core.client.ServerLocator;
import org.apache.activemq.artemis.core.server.ActiveMQServer;
import org.apache.activemq.artemis.core.server.RoutingType;
import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
import org.junit.Before;
import org.junit.Test;
@ -50,7 +51,10 @@ public class MessagePropertyTest extends ActiveMQTestBase {
private void sendMessages() throws Exception {
ClientSession session = sf.createSession(true, true);
session.createQueue(ADDRESS, ADDRESS, null, true);
String filter = null;
session.createAddress(SimpleString.toSimpleString(ADDRESS), RoutingType.MULTICAST, false);
session.createQueue(ADDRESS, RoutingType.MULTICAST, ADDRESS, filter, true);
ClientProducer producer = session.createProducer(ADDRESS);
for (int i = 0; i < numMessages; i++) {

View File

@ -41,6 +41,7 @@ import org.apache.activemq.artemis.core.message.BodyEncoder;
import org.apache.activemq.artemis.core.paging.PagingStore;
import org.apache.activemq.artemis.core.paging.cursor.PageSubscription;
import org.apache.activemq.artemis.core.server.Consumer;
import org.apache.activemq.artemis.core.server.RoutingType;
import org.apache.activemq.artemis.core.server.MessageReference;
import org.apache.activemq.artemis.core.server.Queue;
import org.apache.activemq.artemis.core.server.RoutingContext;
@ -885,6 +886,16 @@ public class ScheduledDeliveryHandlerTest extends Assert {
return null;
}
@Override
public RoutingType getRoutingType() {
return null;
}
@Override
public void setRoutingType(RoutingType routingType) {
}
@Override
public boolean isDurable() {
return false;

View File

@ -307,8 +307,8 @@
</connector-services>
<addresses>
<address name="addr1" type="anycast">
<queues>
<address name="addr1">
<anycast>
<queue name="q1">
<durable>false</durable>
<filter string="color='blue'"/>
@ -317,17 +317,27 @@
<durable>true</durable>
<filter string="color='green'"/>
</queue>
</queues>
</anycast>
</address>
<address name="addr2" type="multicast">
<queues>
<address name="addr2">
<multicast>
<queue name="q3" max-consumers="10" >
<filter string="color='red'"/>
</queue>
<queue name="q4" delete-on-no-consumers="true">
<durable>true</durable>
</queue>
</queues>
</multicast>
</address>
<address name="addr2">
<multicast>
<queue name="q5" max-consumers="1" />
<queue name="q6" max-consumers="1" />
</multicast>
<anycast>
<queue name="q7" max-consumers="-1" />
<queue name="q8" max-consumers="-1" />
</anycast>
</address>
</addresses>

View File

@ -17,9 +17,13 @@
package org.apache.activemq.artemis.tests.integration.addressing;
import java.util.HashSet;
import java.util.Set;
import org.apache.activemq.artemis.api.core.SimpleString;
import org.apache.activemq.artemis.core.config.Configuration;
import org.apache.activemq.artemis.core.server.ActiveMQServer;
import org.apache.activemq.artemis.core.server.RoutingType;
import org.apache.activemq.artemis.core.server.impl.AddressInfo;
import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
import org.junit.Before;
@ -45,6 +49,9 @@ public class AddressConfigTest extends ActiveMQTestBase {
server.start();
AddressInfo addressInfo = server.getAddressInfo(SimpleString.toSimpleString("myAddress"));
assertNotNull(addressInfo);
assertEquals(AddressInfo.RoutingType.MULTICAST, addressInfo.getRoutingType());
Set<RoutingType> routingTypeSet = new HashSet<>();
routingTypeSet.add(RoutingType.MULTICAST);
assertEquals(RoutingType.MULTICAST, addressInfo.getRoutingTypes());
}
}

View File

@ -33,11 +33,11 @@ import org.apache.activemq.artemis.api.core.client.ClientSession;
import org.apache.activemq.artemis.api.core.client.ClientSessionFactory;
import org.apache.activemq.artemis.api.core.client.ServerLocator;
import org.apache.activemq.artemis.core.server.ActiveMQServer;
import org.apache.activemq.artemis.core.server.RoutingType;
import org.apache.activemq.artemis.core.server.Queue;
import org.apache.activemq.artemis.core.server.impl.AddressInfo;
import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
public class AddressingTest extends ActiveMQTestBase {
@ -71,7 +71,7 @@ public class AddressingTest extends ActiveMQTestBase {
// For each address, create 2 Queues with the same address, assert both queues receive message
AddressInfo addressInfo = new AddressInfo(new SimpleString(consumeAddress));
addressInfo.setRoutingType(AddressInfo.RoutingType.MULTICAST);
addressInfo.addRoutingType(RoutingType.MULTICAST);
server.createOrUpdateAddressInfo(addressInfo);
Queue q1 = server.createQueue(new SimpleString(consumeAddress), new SimpleString(consumeAddress + ".1"), null, true, false);
@ -109,11 +109,11 @@ public class AddressingTest extends ActiveMQTestBase {
// For each address, create 2 Queues with the same address, assert one queue receive message
AddressInfo addressInfo = new AddressInfo(new SimpleString(consumeAddress));
addressInfo.setRoutingType(AddressInfo.RoutingType.ANYCAST);
addressInfo.addRoutingType(RoutingType.ANYCAST);
server.createOrUpdateAddressInfo(addressInfo);
Queue q1 = server.createQueue(new SimpleString(consumeAddress), new SimpleString(consumeAddress + ".1"), null, true, false);
Queue q2 = server.createQueue(new SimpleString(consumeAddress), new SimpleString(consumeAddress + ".2"), null, true, false);
Queue q1 = server.createQueue(new SimpleString(consumeAddress), RoutingType.ANYCAST, new SimpleString(consumeAddress + ".1"), null, true, false, Queue.MAX_CONSUMERS_UNLIMITED, false, true);
Queue q2 = server.createQueue(new SimpleString(consumeAddress), RoutingType.ANYCAST, new SimpleString(consumeAddress + ".2"), null, true, false, Queue.MAX_CONSUMERS_UNLIMITED, false, true);
ClientSession session = sessionFactory.createSession();
session.start();
@ -143,12 +143,12 @@ public class AddressingTest extends ActiveMQTestBase {
SimpleString address = new SimpleString("test.address");
AddressInfo addressInfo = new AddressInfo(address);
addressInfo.setRoutingType(AddressInfo.RoutingType.ANYCAST);
addressInfo.addRoutingType(RoutingType.ANYCAST);
server.createOrUpdateAddressInfo(addressInfo);
Queue q1 = server.createQueue(address, address.concat(".1"), null, true, false);
Queue q2 = server.createQueue(address, address.concat(".2"), null, true, false);
Queue q3 = server.createQueue(address, address.concat(".3"), null, true, false);
Queue q1 = server.createQueue(address, RoutingType.ANYCAST, address.concat(".1"), null, true, false, Queue.MAX_CONSUMERS_UNLIMITED, false, true);
Queue q2 = server.createQueue(address, RoutingType.ANYCAST, address.concat(".2"), null, true, false, Queue.MAX_CONSUMERS_UNLIMITED, false, true);
Queue q3 = server.createQueue(address, RoutingType.ANYCAST, address.concat(".3"), null, true, false, Queue.MAX_CONSUMERS_UNLIMITED, false, true);
ClientSession session = sessionFactory.createSession();
session.start();
@ -229,7 +229,7 @@ public class AddressingTest extends ActiveMQTestBase {
SimpleString queueName = SimpleString.toSimpleString(UUID.randomUUID().toString());
// For each address, create 2 Queues with the same address, assert both queues receive message
boolean deleteOnNoConsumers = true;
Queue q1 = server.createQueue(address, queueName, null, true, false, null, deleteOnNoConsumers, true);
Queue q1 = server.createQueue(address, RoutingType.MULTICAST, queueName, null, true, false, Queue.MAX_CONSUMERS_UNLIMITED, deleteOnNoConsumers, true);
ClientSession session = sessionFactory.createSession();
session.start();
@ -246,7 +246,7 @@ public class AddressingTest extends ActiveMQTestBase {
SimpleString queueName = SimpleString.toSimpleString(UUID.randomUUID().toString());
// For each address, create 2 Queues with the same address, assert both queues receive message
boolean deleteOnNoConsumers = false;
Queue q1 = server.createQueue(address, queueName, null, true, false, null, deleteOnNoConsumers, true);
Queue q1 = server.createQueue(address,RoutingType.MULTICAST, queueName, null, true, false, Queue.MAX_CONSUMERS_UNLIMITED, deleteOnNoConsumers, true);
ClientSession session = sessionFactory.createSession();
session.start();
@ -263,7 +263,7 @@ public class AddressingTest extends ActiveMQTestBase {
SimpleString queueName = SimpleString.toSimpleString(UUID.randomUUID().toString());
// For each address, create 2 Queues with the same address, assert both queues receive message
boolean deleteOnNoConsumers = false;
Queue q1 = server.createQueue(address, queueName, null, true, false, 0, deleteOnNoConsumers, true);
Queue q1 = server.createQueue(address, RoutingType.MULTICAST, queueName, null, true, false, 0, deleteOnNoConsumers, true);
Exception expectedException = null;
String expectedMessage = "Maximum Consumer Limit Reached on Queue";
@ -282,7 +282,6 @@ public class AddressingTest extends ActiveMQTestBase {
assertTrue(expectedException.getMessage().contains(queueName));
}
@Ignore
@Test
public void testUnlimitedMaxConsumers() throws Exception {
int noConsumers = 50;
@ -290,7 +289,7 @@ public class AddressingTest extends ActiveMQTestBase {
SimpleString queueName = SimpleString.toSimpleString(UUID.randomUUID().toString());
// For each address, create 2 Queues with the same address, assert both queues receive message
boolean deleteOnNoConsumers = false;
Queue q1 = server.createQueue(address, queueName, null, true, false, -1, deleteOnNoConsumers, false);
Queue q1 = server.createQueue(address, RoutingType.MULTICAST, queueName, null, true, false, Queue.MAX_CONSUMERS_UNLIMITED, deleteOnNoConsumers, true);
ClientSession session = sessionFactory.createSession();
session.start();
@ -299,30 +298,4 @@ public class AddressingTest extends ActiveMQTestBase {
session.createConsumer(q1.getName());
}
}
@Ignore
@Test
public void testDefaultMaxConsumersFromAddress() throws Exception {
int noConsumers = 50;
SimpleString address = new SimpleString("test.address");
SimpleString queueName = SimpleString.toSimpleString(UUID.randomUUID().toString());
// For each address, create 2 Queues with the same address, assert both queues receive message
boolean deleteOnNoConsumers = false;
AddressInfo addressInfo = new AddressInfo(address);
addressInfo.setDefaultMaxQueueConsumers(0);
Queue q1 = server.createQueue(address, queueName, null, true, false, null, deleteOnNoConsumers, false);
ClientSession session = sessionFactory.createSession();
session.start();
for (int i = 0; i < noConsumers; i++) {
session.createConsumer(q1.getName());
}
}
@Ignore
@Test
public void testDefaultDeleteOnNoConsumersFromAddress() {
fail("Not Implemented");
}
}

View File

@ -26,6 +26,7 @@ import org.apache.activemq.artemis.cli.commands.address.CreateAddress;
import org.apache.activemq.artemis.cli.commands.address.DeleteAddress;
import org.apache.activemq.artemis.cli.commands.address.ShowAddress;
import org.apache.activemq.artemis.core.config.DivertConfiguration;
import org.apache.activemq.artemis.core.server.RoutingType;
import org.apache.activemq.artemis.core.server.impl.AddressInfo;
import org.apache.activemq.artemis.tests.util.JMSTestBase;
import org.junit.Before;
@ -120,10 +121,10 @@ public class AddressCommandTest extends JMSTestBase {
// Create bindings
SimpleString address = new SimpleString("address");
server.createAddressInfo(new AddressInfo(address));
server.createQueue(address, new SimpleString("queue1"), null, true, false);
server.createQueue(address, new SimpleString("queue2"), null, true, false);
server.createQueue(address, new SimpleString("queue3"), null, true, false);
server.createAddressInfo(new AddressInfo(address, RoutingType.MULTICAST));
server.createQueue(address, RoutingType.MULTICAST, new SimpleString("queue1"), null, true, false);
server.createQueue(address, RoutingType.MULTICAST, new SimpleString("queue2"), null, true, false);
server.createQueue(address, RoutingType.MULTICAST, new SimpleString("queue3"), null, true, false);
DivertConfiguration divertConfiguration = new DivertConfiguration();
divertConfiguration.setName(address.toString());

View File

@ -50,6 +50,7 @@ import org.apache.activemq.artemis.core.postoffice.impl.LocalQueueBinding;
import org.apache.activemq.artemis.core.protocol.core.Packet;
import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.SessionReceiveMessage;
import org.apache.activemq.artemis.core.server.ActiveMQServer;
import org.apache.activemq.artemis.core.server.RoutingType;
import org.apache.activemq.artemis.core.server.MessageReference;
import org.apache.activemq.artemis.core.server.Queue;
import org.apache.activemq.artemis.core.server.QueueConfig;
@ -224,6 +225,7 @@ public class HangConsumerTest extends ActiveMQTestBase {
final boolean durable,
final boolean temporary,
final boolean autoCreated,
final RoutingType deliveryMode,
final Integer maxConsumers,
final Boolean deleteOnNoConsumers,
final ScheduledExecutorService scheduledExecutor,
@ -231,7 +233,7 @@ public class HangConsumerTest extends ActiveMQTestBase {
final StorageManager storageManager,
final HierarchicalRepository<AddressSettings> addressSettingsRepository,
final Executor executor) {
super(id, address, name, filter, pageSubscription, user, durable, temporary, autoCreated, maxConsumers, deleteOnNoConsumers, scheduledExecutor, postOffice, storageManager, addressSettingsRepository, executor);
super(id, address, name, filter, pageSubscription, user, durable, temporary, autoCreated, deliveryMode, maxConsumers, deleteOnNoConsumers, scheduledExecutor, postOffice, storageManager, addressSettingsRepository, executor);
}
@Override
@ -258,7 +260,7 @@ public class HangConsumerTest extends ActiveMQTestBase {
@Override
public Queue createQueueWith(final QueueConfig config) {
queue = new MyQueueWithBlocking(config.id(), config.address(), config.name(), config.filter(), config.user(), config.pageSubscription(), config.isDurable(), config.isTemporary(), config.isAutoCreated(), config.maxConsumers(), config.isDeleteOnNoConsumers(), scheduledExecutor, postOffice, storageManager, addressSettingsRepository, executorFactory.getExecutor());
queue = new MyQueueWithBlocking(config.id(), config.address(), config.name(), config.filter(), config.user(), config.pageSubscription(), config.isDurable(), config.isTemporary(), config.isAutoCreated(), config.deliveryMode(), config.maxConsumers(), config.isDeleteOnNoConsumers(), scheduledExecutor, postOffice, storageManager, addressSettingsRepository, executorFactory.getExecutor());
return queue;
}
@ -273,7 +275,7 @@ public class HangConsumerTest extends ActiveMQTestBase {
final boolean durable,
final boolean temporary,
final boolean autoCreated) {
queue = new MyQueueWithBlocking(persistenceID, address, name, filter, user, pageSubscription, durable, temporary, autoCreated, null, null, scheduledExecutor, postOffice, storageManager, addressSettingsRepository, executorFactory.getExecutor());
queue = new MyQueueWithBlocking(persistenceID, address, name, filter, user, pageSubscription, durable, temporary, autoCreated, RoutingType.MULTICAST, null, null, scheduledExecutor, postOffice, storageManager, addressSettingsRepository, executorFactory.getExecutor());
return queue;
}
@ -355,7 +357,7 @@ public class HangConsumerTest extends ActiveMQTestBase {
long txID = server.getStorageManager().generateID();
// Forcing a situation where the server would unexpectedly create a duplicated queue. The server should still start normally
LocalQueueBinding newBinding = new LocalQueueBinding(server.getAddressInfo(QUEUE), new QueueImpl(queueID, QUEUE, QUEUE, null, null, true, false, false, null, null, null, null, null), server.getNodeID());
LocalQueueBinding newBinding = new LocalQueueBinding(QUEUE, new QueueImpl(queueID, QUEUE, QUEUE, null, null, true, false, false, null, null, null, null, null), server.getNodeID());
server.getStorageManager().addQueueBinding(txID, newBinding);
server.getStorageManager().commitBindings(txID);

View File

@ -31,6 +31,7 @@ import org.apache.activemq.artemis.api.core.client.ServerLocator;
import org.apache.activemq.artemis.core.protocol.core.Packet;
import org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl;
import org.apache.activemq.artemis.core.server.ActiveMQServer;
import org.apache.activemq.artemis.core.server.RoutingType;
import org.apache.activemq.artemis.core.settings.impl.AddressFullMessagePolicy;
import org.apache.activemq.artemis.core.settings.impl.AddressSettings;
import org.apache.activemq.artemis.spi.core.protocol.RemotingConnection;
@ -89,7 +90,7 @@ public class ProducerTest extends ActiveMQTestBase {
server.getConfiguration().getAddressesSettings().put(QUEUE.toString(), setting);
server.start();
server.createQueue(QUEUE, QUEUE, null, true, false);
server.createQueue(QUEUE, RoutingType.MULTICAST, QUEUE, null, true, false);
for (int i = 0; i < 100; i++) {
final CountDownLatch latch = new CountDownLatch(1);

View File

@ -19,10 +19,10 @@ package org.apache.activemq.artemis.tests.integration.cluster.distribution;
import java.util.List;
import org.apache.activemq.artemis.api.core.SimpleString;
import org.apache.activemq.artemis.core.server.RoutingType;
import org.apache.activemq.artemis.core.server.Queue;
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.tests.util.Wait;
import org.junit.Test;
@ -55,7 +55,7 @@ public class AnycastRoutingWithClusterTest extends ClusterTestBase {
List<Queue> queues;
for (int i = 0; i < 3; i++) {
createAddressInfo(i, address, AddressInfo.RoutingType.ANYCAST, -1, false);
createAddressInfo(i, address, RoutingType.ANYCAST, -1, false);
setupSessionFactory(i, isNetty());
createQueue(i, address, queueName, null, false);
addConsumer(i, i, queueName, null);
@ -116,7 +116,7 @@ public class AnycastRoutingWithClusterTest extends ClusterTestBase {
List<Queue> queues;
for (int i = 0; i < 3; i++) {
createAddressInfo(i, address, AddressInfo.RoutingType.ANYCAST, -1, false);
createAddressInfo(i, address, RoutingType.ANYCAST, -1, false);
setupSessionFactory(i, isNetty());
createQueue(i, address, queueNamePrefix + i, null, false);
addConsumer(i, i, queueNamePrefix + i, null);
@ -176,7 +176,7 @@ public class AnycastRoutingWithClusterTest extends ClusterTestBase {
List<Queue> queues;
for (int i = 0; i < 3; i++) {
createAddressInfo(i, address, AddressInfo.RoutingType.ANYCAST, -1, false);
createAddressInfo(i, address, RoutingType.ANYCAST, -1, false);
setupSessionFactory(i, isNetty());
}
@ -238,7 +238,7 @@ public class AnycastRoutingWithClusterTest extends ClusterTestBase {
List<Queue> queues;
for (int i = 0; i < 3; i++) {
createAddressInfo(i, address, AddressInfo.RoutingType.MULTICAST, -1, false);
createAddressInfo(i, address, RoutingType.MULTICAST, -1, false);
setupSessionFactory(i, isNetty());
createQueue(i, address, queueNamePrefix + i, null, false);
addConsumer(i, i, queueNamePrefix + i, null);

View File

@ -68,6 +68,7 @@ import org.apache.activemq.artemis.core.protocol.core.impl.CoreProtocolManagerFa
import org.apache.activemq.artemis.core.remoting.impl.netty.TransportConstants;
import org.apache.activemq.artemis.core.server.ActiveMQServer;
import org.apache.activemq.artemis.core.server.ActiveMQServers;
import org.apache.activemq.artemis.core.server.RoutingType;
import org.apache.activemq.artemis.core.server.NodeManager;
import org.apache.activemq.artemis.core.server.cluster.ActiveMQServerSideProtocolManagerFactory;
import org.apache.activemq.artemis.core.server.cluster.ClusterConnection;
@ -521,14 +522,11 @@ public abstract class ClusterTestBase extends ActiveMQTestBase {
protected void createAddressInfo(final int node,
final String address,
final AddressInfo.RoutingType routingType,
final RoutingType routingType,
final int defaulMaxConsumers,
boolean defaultDeleteOnNoConsumers) throws Exception {
AddressInfo addressInfo = new AddressInfo(new SimpleString(address));
addressInfo.setRoutingType(routingType);
addressInfo.setDefaultMaxQueueConsumers(defaulMaxConsumers);
addressInfo.setDefaultDeleteOnNoConsumers(defaultDeleteOnNoConsumers);
addressInfo.addRoutingType(routingType);
servers[node].createOrUpdateAddressInfo(addressInfo);
}

View File

@ -143,7 +143,7 @@ public class AsynchronousFailoverTest extends FailoverTestBase {
ClientSession createSession = sf.createSession(true, true);
createSession.createQueue(FailoverTestBase.ADDRESS, FailoverTestBase.ADDRESS, null, true);
createSession.createQueue(FailoverTestBase.ADDRESS, FailoverTestBase.ADDRESS, (SimpleString) null, true);
RemotingConnection conn = ((ClientSessionInternal) createSession).getConnection();

View File

@ -41,6 +41,7 @@ import org.apache.activemq.artemis.core.paging.PagingStore;
import org.apache.activemq.artemis.core.persistence.impl.journal.DescribeJournal;
import org.apache.activemq.artemis.core.persistence.impl.journal.JournalStorageManager;
import org.apache.activemq.artemis.core.server.Queue;
import org.apache.activemq.artemis.core.server.RoutingType;
import org.apache.activemq.artemis.core.server.files.FileMoveManager;
import org.apache.activemq.artemis.tests.integration.cluster.util.BackupSyncDelay;
import org.apache.activemq.artemis.tests.integration.cluster.util.TestableServer;
@ -331,7 +332,7 @@ public class BackupSyncJournalTest extends FailoverTestBase {
protected void createProducerSendSomeMessages() throws ActiveMQException {
session = addClientSession(sessionFactory.createSession(true, true));
session.createQueue(ADDRESS, ADDRESS, null, true);
session.createQueue(ADDRESS, RoutingType.MULTICAST, ADDRESS, null, true);
if (producer != null)
producer.close();
producer = addClientProducer(session.createProducer(ADDRESS));

View File

@ -45,6 +45,7 @@ import org.apache.activemq.artemis.api.core.client.ClientSessionFactory;
import org.apache.activemq.artemis.api.core.client.MessageHandler;
import org.apache.activemq.artemis.api.core.client.ServerLocator;
import org.apache.activemq.artemis.core.client.impl.ClientSessionFactoryInternal;
import org.apache.activemq.artemis.core.server.RoutingType;
import org.apache.activemq.artemis.core.server.cluster.ha.BackupPolicy;
import org.apache.activemq.artemis.core.server.cluster.ha.HAPolicy;
import org.apache.activemq.artemis.core.server.cluster.ha.ReplicaPolicy;
@ -115,7 +116,7 @@ public class FailoverTest extends FailoverTestBase {
final ClientSession session = createSession(sf1, true, true);
session.createQueue(FailoverTestBase.ADDRESS, FailoverTestBase.ADDRESS, null, true);
session.createQueue(FailoverTestBase.ADDRESS, RoutingType.MULTICAST, FailoverTestBase.ADDRESS, null, true);
final ClientProducer producer = session.createProducer(FailoverTestBase.ADDRESS);
@ -180,7 +181,7 @@ public class FailoverTest extends FailoverTestBase {
final ClientSession session = createSession(sf1, true, true);
session.createQueue(FailoverTestBase.ADDRESS, FailoverTestBase.ADDRESS, null, true);
session.createQueue(FailoverTestBase.ADDRESS, RoutingType.MULTICAST, FailoverTestBase.ADDRESS, null, true);
final ClientProducer producer = session.createProducer(FailoverTestBase.ADDRESS);
@ -241,7 +242,7 @@ public class FailoverTest extends FailoverTestBase {
final ClientSession session = createSession(sf1, true, true);
session.createQueue(FailoverTestBase.ADDRESS, FailoverTestBase.ADDRESS, null, true);
session.createQueue(FailoverTestBase.ADDRESS, RoutingType.MULTICAST, FailoverTestBase.ADDRESS, null, true);
final ClientProducer producer = session.createProducer(FailoverTestBase.ADDRESS);
@ -334,7 +335,7 @@ public class FailoverTest extends FailoverTestBase {
final ClientSession session = createSession(sf1, true, false, false);
session.createQueue(FailoverTestBase.ADDRESS, FailoverTestBase.ADDRESS, null, true);
session.createQueue(FailoverTestBase.ADDRESS, RoutingType.MULTICAST, FailoverTestBase.ADDRESS, null, true);
final ClientProducer producer = session.createProducer(FailoverTestBase.ADDRESS);
@ -380,7 +381,7 @@ public class FailoverTest extends FailoverTestBase {
final ClientSession session = createSession(sf1, true, false, false);
session.createQueue(FailoverTestBase.ADDRESS, FailoverTestBase.ADDRESS, null, true);
session.createQueue(FailoverTestBase.ADDRESS, RoutingType.MULTICAST, FailoverTestBase.ADDRESS, null, true);
final ClientProducer producer = session.createProducer(FailoverTestBase.ADDRESS);
@ -431,7 +432,7 @@ public class FailoverTest extends FailoverTestBase {
ClientSession session = createSession(sf, true, true);
session.createQueue(FailoverTestBase.ADDRESS, FailoverTestBase.ADDRESS, null, true);
session.createQueue(FailoverTestBase.ADDRESS, RoutingType.MULTICAST, FailoverTestBase.ADDRESS, null, true);
ClientProducer producer = session.createProducer(FailoverTestBase.ADDRESS);
@ -476,7 +477,7 @@ public class FailoverTest extends FailoverTestBase {
ClientSession session = createSession(sf, true, true);
session.createQueue(FailoverTestBase.ADDRESS, FailoverTestBase.ADDRESS, null, true);
session.createQueue(FailoverTestBase.ADDRESS, RoutingType.MULTICAST, FailoverTestBase.ADDRESS, null, true);
ClientProducer producer = session.createProducer(FailoverTestBase.ADDRESS);
@ -761,7 +762,7 @@ public class FailoverTest extends FailoverTestBase {
protected ClientSession createSessionAndQueue() throws Exception {
ClientSession session = createSession(sf, false, false);
session.createQueue(FailoverTestBase.ADDRESS, FailoverTestBase.ADDRESS, null, true);
session.createQueue(FailoverTestBase.ADDRESS, RoutingType.MULTICAST, FailoverTestBase.ADDRESS, null, true);
return session;
}
@ -777,7 +778,7 @@ public class FailoverTest extends FailoverTestBase {
ClientSession session = createSession(sf);
session.createQueue(FailoverTestBase.ADDRESS, FailoverTestBase.ADDRESS, null, true);
session.createQueue(FailoverTestBase.ADDRESS, RoutingType.MULTICAST, FailoverTestBase.ADDRESS, null, true);
ClientProducer producer = session.createProducer(FailoverTestBase.ADDRESS);
@ -1049,7 +1050,7 @@ public class FailoverTest extends FailoverTestBase {
Xid xid = new XidImpl("uhuhuhu".getBytes(), 126512, "auhsduashd".getBytes());
session.createQueue(FailoverTestBase.ADDRESS, FailoverTestBase.ADDRESS, null, true);
session.createQueue(FailoverTestBase.ADDRESS, RoutingType.MULTICAST, FailoverTestBase.ADDRESS, null, true);
ClientProducer producer = session.createProducer(FailoverTestBase.ADDRESS);
@ -1085,7 +1086,7 @@ public class FailoverTest extends FailoverTestBase {
Xid xid = new XidImpl("uhuhuhu".getBytes(), 126512, "auhsduashd".getBytes());
session.createQueue(FailoverTestBase.ADDRESS, FailoverTestBase.ADDRESS, null, true);
session.createQueue(FailoverTestBase.ADDRESS, RoutingType.MULTICAST, FailoverTestBase.ADDRESS, null, true);
ClientProducer producer = session.createProducer(FailoverTestBase.ADDRESS);
@ -1122,7 +1123,7 @@ public class FailoverTest extends FailoverTestBase {
Xid xid = new XidImpl("uhuhuhu".getBytes(), 126512, "auhsduashd".getBytes());
session.createQueue(FailoverTestBase.ADDRESS, FailoverTestBase.ADDRESS, null, true);
session.createQueue(FailoverTestBase.ADDRESS, RoutingType.MULTICAST, FailoverTestBase.ADDRESS, null, true);
final ClientProducer producer = session.createProducer(FailoverTestBase.ADDRESS);
@ -1164,7 +1165,7 @@ public class FailoverTest extends FailoverTestBase {
Xid xid = new XidImpl("uhuhuhu".getBytes(), 126512, "auhsduashd".getBytes());
session.createQueue(FailoverTestBase.ADDRESS, FailoverTestBase.ADDRESS, null, true);
session.createQueue(FailoverTestBase.ADDRESS, RoutingType.MULTICAST, FailoverTestBase.ADDRESS, null, true);
ClientProducer producer = session.createProducer(FailoverTestBase.ADDRESS);
@ -1201,7 +1202,7 @@ public class FailoverTest extends FailoverTestBase {
Xid xid = new XidImpl("uhuhuhu".getBytes(), 126512, "auhsduashd".getBytes());
session.createQueue(FailoverTestBase.ADDRESS, FailoverTestBase.ADDRESS, null, true);
session.createQueue(FailoverTestBase.ADDRESS, RoutingType.MULTICAST, FailoverTestBase.ADDRESS, null, true);
ClientProducer producer = session.createProducer(FailoverTestBase.ADDRESS);
@ -1434,7 +1435,7 @@ public class FailoverTest extends FailoverTestBase {
for (int j = 0; j < numConsumersPerSession; j++) {
SimpleString queueName = new SimpleString("queue" + i + "-" + j);
session.createQueue(FailoverTestBase.ADDRESS, queueName, null, true);
session.createQueue(FailoverTestBase.ADDRESS, RoutingType.MULTICAST, queueName, null, true);
ClientConsumer consumer = session.createConsumer(queueName);
@ -1474,7 +1475,7 @@ public class FailoverTest extends FailoverTestBase {
createSessionFactory();
ClientSession session = createSession(sf, true, true);
session.createQueue(FailoverTestBase.ADDRESS, FailoverTestBase.ADDRESS, null, true);
session.createQueue(FailoverTestBase.ADDRESS, RoutingType.MULTICAST, FailoverTestBase.ADDRESS, null, true);
ClientProducer producer = session.createProducer(FailoverTestBase.ADDRESS);
@ -1504,7 +1505,7 @@ public class FailoverTest extends FailoverTestBase {
ClientSession session = createSession(sf, true, true);
session.createQueue(FailoverTestBase.ADDRESS, FailoverTestBase.ADDRESS, null, true);
session.createQueue(FailoverTestBase.ADDRESS, RoutingType.MULTICAST, FailoverTestBase.ADDRESS, null, true);
ClientProducer producer = session.createProducer(FailoverTestBase.ADDRESS);
@ -1583,7 +1584,7 @@ public class FailoverTest extends FailoverTestBase {
ClientSession session = createSession(sf, true, true, 0);
session.createQueue(FailoverTestBase.ADDRESS, FailoverTestBase.ADDRESS, null, true);
session.createQueue(FailoverTestBase.ADDRESS, RoutingType.MULTICAST, FailoverTestBase.ADDRESS, null, true);
ClientProducer producer = session.createProducer(FailoverTestBase.ADDRESS);
@ -1636,9 +1637,9 @@ public class FailoverTest extends FailoverTestBase {
ClientSession session = createSession(sf, true, true, 0);
if (temporary) {
session.createTemporaryQueue(FailoverTestBase.ADDRESS, FailoverTestBase.ADDRESS, null);
session.createTemporaryQueue(FailoverTestBase.ADDRESS, RoutingType.MULTICAST, FailoverTestBase.ADDRESS, null);
} else {
session.createQueue(FailoverTestBase.ADDRESS, FailoverTestBase.ADDRESS, null, durable);
session.createQueue(FailoverTestBase.ADDRESS, RoutingType.MULTICAST, FailoverTestBase.ADDRESS, null, durable);
}
ClientProducer producer = session.createProducer(FailoverTestBase.ADDRESS);
@ -1665,7 +1666,7 @@ public class FailoverTest extends FailoverTestBase {
final ClientSession session = createSession(sf, true, true, 0);
session.createQueue(FailoverTestBase.ADDRESS, FailoverTestBase.ADDRESS, null, true);
session.createQueue(FailoverTestBase.ADDRESS, RoutingType.MULTICAST, FailoverTestBase.ADDRESS, null, true);
final ClientProducer producer = session.createProducer(FailoverTestBase.ADDRESS);
@ -1714,7 +1715,7 @@ public class FailoverTest extends FailoverTestBase {
final ClientSession session = createSession(sf, false, false);
session.createQueue(FailoverTestBase.ADDRESS, FailoverTestBase.ADDRESS, null, true);
session.createQueue(FailoverTestBase.ADDRESS, RoutingType.MULTICAST, FailoverTestBase.ADDRESS, null, true);
ClientProducer producer = session.createProducer(FailoverTestBase.ADDRESS);
@ -1845,7 +1846,7 @@ public class FailoverTest extends FailoverTestBase {
final ClientSession session = createSession(sf, false, false);
session.createQueue(FailoverTestBase.ADDRESS, FailoverTestBase.ADDRESS, null, true);
session.createQueue(FailoverTestBase.ADDRESS, RoutingType.MULTICAST, FailoverTestBase.ADDRESS, null, true);
ClientProducer producer = session.createProducer(FailoverTestBase.ADDRESS);
sendMessages(session, producer, NUM_MESSAGES);
@ -2115,7 +2116,7 @@ public class FailoverTest extends FailoverTestBase {
ClientSession session = createSession(sf1, false, true, true);
if (createQueue) {
session.createQueue(FailoverTestBase.ADDRESS, FailoverTestBase.ADDRESS, null, false);
session.createQueue(FailoverTestBase.ADDRESS, RoutingType.MULTICAST, FailoverTestBase.ADDRESS, null, false);
}
ClientProducer producer = session.createProducer(FailoverTestBase.ADDRESS);

View File

@ -22,6 +22,7 @@ import org.apache.activemq.artemis.api.core.client.ClientProducer;
import org.apache.activemq.artemis.api.core.client.ClientSession;
import org.apache.activemq.artemis.api.core.client.ClientSessionFactory;
import org.apache.activemq.artemis.api.core.client.ServerLocator;
import org.apache.activemq.artemis.core.server.RoutingType;
import org.apache.activemq.artemis.tests.integration.cluster.util.TestableServer;
import org.junit.Test;
@ -66,7 +67,7 @@ public class ReplicatedMultipleServerFailoverTest extends MultipleServerFailover
ClientSession[] sessions = new ClientSession[liveServers.size()];
for (int i = 0; i < factories.length; i++) {
sessions[i] = createSession(factories[i], true, true);
sessions[i].createQueue(ADDRESS, ADDRESS, null, true);
sessions[i].createQueue(ADDRESS, RoutingType.MULTICAST, ADDRESS, null, true);
}
//make sure bindings are ready before sending messages

View File

@ -251,7 +251,7 @@ public abstract class MultiThreadRandomReattachTestBase extends MultiThreadReatt
ClientSession session = addClientSession(sf.createSession(false, true, true));
session.createQueue(MultiThreadRandomReattachTestBase.ADDRESS, subName, null, false);
session.createQueue(MultiThreadRandomReattachTestBase.ADDRESS, subName, (SimpleString) null, false);
ClientProducer producer = session.createProducer(MultiThreadRandomReattachTestBase.ADDRESS);
@ -307,7 +307,7 @@ public abstract class MultiThreadRandomReattachTestBase extends MultiThreadReatt
sessConsume.start();
sessConsume.createQueue(MultiThreadRandomReattachTestBase.ADDRESS, subName, null, false);
sessConsume.createQueue(MultiThreadRandomReattachTestBase.ADDRESS, subName, (SimpleString) null, false);
ClientConsumer consumer = sessConsume.createConsumer(subName);
@ -383,7 +383,7 @@ public abstract class MultiThreadRandomReattachTestBase extends MultiThreadReatt
ClientSession sessConsume = createAutoCommitSession(sf);
sessConsume.createQueue(MultiThreadRandomReattachTestBase.ADDRESS, subName, null, false);
sessConsume.createQueue(MultiThreadRandomReattachTestBase.ADDRESS, subName, (SimpleString) null, false);
ClientConsumer consumer = sessConsume.createConsumer(subName);
@ -467,7 +467,7 @@ public abstract class MultiThreadRandomReattachTestBase extends MultiThreadReatt
sessConsume.start();
sessConsume.createQueue(MultiThreadRandomReattachTestBase.ADDRESS, subName, null, false);
sessConsume.createQueue(MultiThreadRandomReattachTestBase.ADDRESS, subName, (SimpleString) null, false);
ClientConsumer consumer = sessConsume.createConsumer(subName);
@ -566,7 +566,7 @@ public abstract class MultiThreadRandomReattachTestBase extends MultiThreadReatt
ClientSession sessConsume = sf.createSession(false, false, false);
sessConsume.addMetaData("data", RandomUtil.randomString());
sessConsume.createQueue(MultiThreadRandomReattachTestBase.ADDRESS, subName, null, false);
sessConsume.createQueue(MultiThreadRandomReattachTestBase.ADDRESS, subName, (SimpleString) null, false);
ClientConsumer consumer = sessConsume.createConsumer(subName);
@ -695,7 +695,7 @@ public abstract class MultiThreadRandomReattachTestBase extends MultiThreadReatt
sessConsume.start();
sessConsume.createQueue(MultiThreadRandomReattachTestBase.ADDRESS, subName, null, false);
sessConsume.createQueue(MultiThreadRandomReattachTestBase.ADDRESS, subName, (SimpleString) null, false);
ClientConsumer consumer = sessConsume.createConsumer(subName);
@ -750,7 +750,7 @@ public abstract class MultiThreadRandomReattachTestBase extends MultiThreadReatt
ClientSession sessConsume = sf.createSession(false, true, true);
sessConsume.addMetaData("data", RandomUtil.randomString());
sessConsume.createQueue(MultiThreadRandomReattachTestBase.ADDRESS, subName, null, false);
sessConsume.createQueue(MultiThreadRandomReattachTestBase.ADDRESS, subName, (SimpleString) null, false);
ClientConsumer consumer = sessConsume.createConsumer(subName);
@ -811,7 +811,7 @@ public abstract class MultiThreadRandomReattachTestBase extends MultiThreadReatt
sessConsume.start();
sessConsume.createQueue(MultiThreadRandomReattachTestBase.ADDRESS, subName, null, false);
sessConsume.createQueue(MultiThreadRandomReattachTestBase.ADDRESS, subName, (SimpleString) null, false);
ClientConsumer consumer = sessConsume.createConsumer(subName);
@ -882,7 +882,7 @@ public abstract class MultiThreadRandomReattachTestBase extends MultiThreadReatt
ClientSession sessConsume = sf.createSession(false, false, false);
sessConsume.addMetaData("data", RandomUtil.randomString());
sessConsume.createQueue(MultiThreadRandomReattachTestBase.ADDRESS, subName, null, false);
sessConsume.createQueue(MultiThreadRandomReattachTestBase.ADDRESS, subName, (SimpleString) null, false);
ClientConsumer consumer = sessConsume.createConsumer(subName);
@ -942,7 +942,7 @@ public abstract class MultiThreadRandomReattachTestBase extends MultiThreadReatt
ClientSession sessCreate = sf.createSession(false, true, true);
sessCreate.addMetaData("data", RandomUtil.randomString());
sessCreate.createQueue(MultiThreadRandomReattachTestBase.ADDRESS, new SimpleString(threadNum + MultiThreadRandomReattachTestBase.ADDRESS.toString()), null, false);
sessCreate.createQueue(MultiThreadRandomReattachTestBase.ADDRESS, new SimpleString(threadNum + MultiThreadRandomReattachTestBase.ADDRESS.toString()), (SimpleString) null, false);
ClientSession sess = sf.createSession(false, true, true);
sess.addMetaData("data", RandomUtil.randomString());
@ -973,7 +973,7 @@ public abstract class MultiThreadRandomReattachTestBase extends MultiThreadReatt
ClientSession sessCreate = sf.createSession(false, true, true);
sessCreate.addMetaData("data", RandomUtil.randomString());
sessCreate.createQueue(MultiThreadRandomReattachTestBase.ADDRESS, new SimpleString(threadNum + MultiThreadRandomReattachTestBase.ADDRESS.toString()), null, false);
sessCreate.createQueue(MultiThreadRandomReattachTestBase.ADDRESS, new SimpleString(threadNum + MultiThreadRandomReattachTestBase.ADDRESS.toString()), (SimpleString) null, false);
ClientSession sess = sf.createSession(false, true, true);
sess.addMetaData("data", RandomUtil.randomString());
@ -1004,7 +1004,7 @@ public abstract class MultiThreadRandomReattachTestBase extends MultiThreadReatt
ClientSession s = sf.createSession(false, false, false);
s.addMetaData("data", RandomUtil.randomString());
s.createQueue(MultiThreadRandomReattachTestBase.ADDRESS, new SimpleString(threadNum + MultiThreadRandomReattachTestBase.ADDRESS.toString()), null, false);
s.createQueue(MultiThreadRandomReattachTestBase.ADDRESS, new SimpleString(threadNum + MultiThreadRandomReattachTestBase.ADDRESS.toString()), (SimpleString) null, false);
final int numConsumers = 100;
@ -1037,7 +1037,7 @@ public abstract class MultiThreadRandomReattachTestBase extends MultiThreadReatt
protected void doTestN(final ClientSessionFactory sf, final int threadNum) throws Exception {
ClientSession sessCreate = sf.createSession(false, true, true);
sessCreate.createQueue(MultiThreadRandomReattachTestBase.ADDRESS, new SimpleString(threadNum + MultiThreadRandomReattachTestBase.ADDRESS.toString()), null, false);
sessCreate.createQueue(MultiThreadRandomReattachTestBase.ADDRESS, new SimpleString(threadNum + MultiThreadRandomReattachTestBase.ADDRESS.toString()), (SimpleString) null, false);
ClientSession sess = sf.createSession(false, true, true);
sess.addMetaData("data", RandomUtil.randomString());
@ -1077,7 +1077,7 @@ public abstract class MultiThreadRandomReattachTestBase extends MultiThreadReatt
protected void doTestO(final ClientSessionFactory sf, final int threadNum) throws Exception {
ClientSession sessCreate = sf.createSession(false, true, true);
sessCreate.createQueue(MultiThreadRandomReattachTestBase.ADDRESS, new SimpleString(threadNum + MultiThreadRandomReattachTestBase.ADDRESS.toString()), null, false);
sessCreate.createQueue(MultiThreadRandomReattachTestBase.ADDRESS, new SimpleString(threadNum + MultiThreadRandomReattachTestBase.ADDRESS.toString()), (SimpleString) null, false);
ClientSession sess = sf.createSession(false, true, true);

View File

@ -34,6 +34,7 @@ import org.apache.activemq.artemis.api.core.client.ServerLocator;
import org.apache.activemq.artemis.core.client.impl.ClientSessionInternal;
import org.apache.activemq.artemis.core.protocol.core.impl.RemotingConnectionImpl;
import org.apache.activemq.artemis.core.server.ActiveMQServer;
import org.apache.activemq.artemis.core.server.RoutingType;
import org.apache.activemq.artemis.jms.client.ActiveMQTextMessage;
import org.apache.activemq.artemis.tests.integration.IntegrationTestLogger;
import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
@ -159,7 +160,7 @@ public class OrderReattachTest extends ActiveMQTestBase {
ClientSession sessConsume = sf.createSession(false, true, true);
sessConsume.createQueue(ADDRESS, subName, null, false);
sessConsume.createQueue(ADDRESS, RoutingType.MULTICAST, subName, null, false);
ClientConsumer consumer = sessConsume.createConsumer(subName);

View File

@ -29,6 +29,7 @@ import org.apache.activemq.ActiveMQXAConnectionFactory;
import org.apache.activemq.artemis.api.core.SimpleString;
import org.apache.activemq.artemis.core.config.Configuration;
import org.apache.activemq.artemis.core.server.ActiveMQServer;
import org.apache.activemq.artemis.core.server.RoutingType;
import org.apache.activemq.artemis.core.settings.impl.AddressSettings;
import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
import org.apache.qpid.jms.JmsConnectionFactory;
@ -59,7 +60,7 @@ public class OpenWireToAMQPTest extends ActiveMQTestBase {
serverConfig.setSecurityEnabled(false);
server.start();
coreQueue = new SimpleString(queueName);
this.server.createQueue(coreQueue, coreQueue, null, false, false);
this.server.createQueue(coreQueue, RoutingType.MULTICAST, coreQueue, null, false, false);
qpidfactory = new JmsConnectionFactory("amqp://localhost:61616");
}

View File

@ -34,6 +34,7 @@ import org.apache.activemq.artemis.core.postoffice.impl.DivertBinding;
import org.apache.activemq.artemis.core.server.ActiveMQServer;
import org.apache.activemq.artemis.core.server.ActiveMQServers;
import org.apache.activemq.artemis.core.server.Divert;
import org.apache.activemq.artemis.core.server.RoutingType;
import org.apache.activemq.artemis.core.server.ServerMessage;
import org.apache.activemq.artemis.core.server.cluster.Transformer;
import org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl;
@ -71,9 +72,9 @@ public class DivertTest extends ActiveMQTestBase {
final SimpleString queueName2 = new SimpleString("queue2");
session.createQueue(new SimpleString(forwardAddress), queueName1, null, false);
session.createQueue(new SimpleString(forwardAddress), RoutingType.MULTICAST, queueName1, null, false);
session.createQueue(new SimpleString(testAddress), queueName2, null, false);
session.createQueue(new SimpleString(testAddress), RoutingType.MULTICAST, queueName2, null, false);
session.start();
@ -148,11 +149,11 @@ public class DivertTest extends ActiveMQTestBase {
final SimpleString queueName2 = new SimpleString("queue2");
session.createQueue(new SimpleString(forwardAddress), queueName1, null, true);
session.createQueue(new SimpleString(forwardAddress), RoutingType.MULTICAST, queueName1, null, true);
session.createQueue(new SimpleString(testAddress), queueName2, null, true);
session.createQueue(new SimpleString(testAddress), RoutingType.MULTICAST, queueName2, null, true);
session.createQueue(new SimpleString(expiryAddress), new SimpleString(expiryAddress), null, true);
session.createQueue(new SimpleString(expiryAddress), RoutingType.MULTICAST, new SimpleString(expiryAddress), null, true);
session.start();
@ -253,13 +254,13 @@ public class DivertTest extends ActiveMQTestBase {
final SimpleString queueName4 = new SimpleString("queue4");
session.createQueue(new SimpleString(forwardAddress), queueName1, null, false);
session.createQueue(new SimpleString(forwardAddress), RoutingType.MULTICAST, queueName1, null, false);
session.createQueue(new SimpleString(testAddress), queueName2, null, false);
session.createQueue(new SimpleString(testAddress), RoutingType.MULTICAST, queueName2, null, false);
session.createQueue(new SimpleString(testAddress), queueName3, null, false);
session.createQueue(new SimpleString(testAddress), RoutingType.MULTICAST, queueName3, null, false);
session.createQueue(new SimpleString(testAddress), queueName4, null, false);
session.createQueue(new SimpleString(testAddress), RoutingType.MULTICAST, queueName4, null, false);
session.start();
@ -355,7 +356,7 @@ public class DivertTest extends ActiveMQTestBase {
final SimpleString queueName1 = new SimpleString("queue1");
session.createQueue(new SimpleString(forwardAddress), queueName1, null, false);
session.createQueue(new SimpleString(forwardAddress), RoutingType.MULTICAST, queueName1, null, false);
session.start();
@ -415,11 +416,11 @@ public class DivertTest extends ActiveMQTestBase {
final SimpleString queueName4 = new SimpleString("queue4");
session.createQueue(new SimpleString(forwardAddress), queueName1, null, false);
session.createQueue(new SimpleString(forwardAddress), RoutingType.MULTICAST, queueName1, null, false);
session.createQueue(new SimpleString(testAddress), queueName2, null, false);
session.createQueue(new SimpleString(testAddress), queueName3, null, false);
session.createQueue(new SimpleString(testAddress), queueName4, null, false);
session.createQueue(new SimpleString(testAddress), RoutingType.MULTICAST, queueName2, null, false);
session.createQueue(new SimpleString(testAddress), RoutingType.MULTICAST, queueName3, null, false);
session.createQueue(new SimpleString(testAddress), RoutingType.MULTICAST, queueName4, null, false);
session.start();
@ -497,13 +498,13 @@ public class DivertTest extends ActiveMQTestBase {
final SimpleString queueName4 = new SimpleString("queue4");
session.createQueue(new SimpleString(forwardAddress1), queueName1, null, false);
session.createQueue(new SimpleString(forwardAddress1), RoutingType.MULTICAST, queueName1, null, false);
session.createQueue(new SimpleString(forwardAddress2), queueName2, null, false);
session.createQueue(new SimpleString(forwardAddress2), RoutingType.MULTICAST, queueName2, null, false);
session.createQueue(new SimpleString(forwardAddress3), queueName3, null, false);
session.createQueue(new SimpleString(forwardAddress3), RoutingType.MULTICAST, queueName3, null, false);
session.createQueue(new SimpleString(testAddress), queueName4, null, false);
session.createQueue(new SimpleString(testAddress), RoutingType.MULTICAST, queueName4, null, false);
session.start();
@ -612,13 +613,13 @@ public class DivertTest extends ActiveMQTestBase {
final SimpleString queueName4 = new SimpleString("queue4");
session.createQueue(new SimpleString(forwardAddress1), queueName1, null, false);
session.createQueue(new SimpleString(forwardAddress1), RoutingType.MULTICAST, queueName1, null, false);
session.createQueue(new SimpleString(forwardAddress2), queueName2, null, false);
session.createQueue(new SimpleString(forwardAddress2), RoutingType.MULTICAST, queueName2, null, false);
session.createQueue(new SimpleString(forwardAddress3), queueName3, null, false);
session.createQueue(new SimpleString(forwardAddress3), RoutingType.MULTICAST, queueName3, null, false);
session.createQueue(new SimpleString(testAddress), queueName4, null, false);
session.createQueue(new SimpleString(testAddress), RoutingType.MULTICAST, queueName4, null, false);
session.start();
@ -716,13 +717,13 @@ public class DivertTest extends ActiveMQTestBase {
final SimpleString queueName4 = new SimpleString("queue4");
session.createQueue(new SimpleString(forwardAddress1), queueName1, null, false);
session.createQueue(new SimpleString(forwardAddress1), RoutingType.MULTICAST, queueName1, null, false);
session.createQueue(new SimpleString(forwardAddress2), queueName2, null, false);
session.createQueue(new SimpleString(forwardAddress2), RoutingType.MULTICAST, queueName2, null, false);
session.createQueue(new SimpleString(forwardAddress3), queueName3, null, false);
session.createQueue(new SimpleString(forwardAddress3), RoutingType.MULTICAST, queueName3, null, false);
session.createQueue(new SimpleString(testAddress), queueName4, null, false);
session.createQueue(new SimpleString(testAddress), RoutingType.MULTICAST, queueName4, null, false);
session.start();
@ -814,13 +815,13 @@ public class DivertTest extends ActiveMQTestBase {
final SimpleString queueName4 = new SimpleString("queue4");
session.createQueue(new SimpleString(forwardAddress1), queueName1, null, false);
session.createQueue(new SimpleString(forwardAddress1), RoutingType.MULTICAST, queueName1, null, false);
session.createQueue(new SimpleString(forwardAddress2), queueName2, null, false);
session.createQueue(new SimpleString(forwardAddress2), RoutingType.MULTICAST, queueName2, null, false);
session.createQueue(new SimpleString(forwardAddress3), queueName3, null, false);
session.createQueue(new SimpleString(forwardAddress3), RoutingType.MULTICAST, queueName3, null, false);
session.createQueue(new SimpleString(testAddress), queueName4, null, false);
session.createQueue(new SimpleString(testAddress), RoutingType.MULTICAST, queueName4, null, false);
session.start();
@ -960,13 +961,13 @@ public class DivertTest extends ActiveMQTestBase {
final SimpleString queueName4 = new SimpleString("queue4");
session.createQueue(new SimpleString(forwardAddress1), queueName1, null, false);
session.createQueue(new SimpleString(forwardAddress1), RoutingType.MULTICAST, queueName1, null, false);
session.createQueue(new SimpleString(forwardAddress2), queueName2, null, false);
session.createQueue(new SimpleString(forwardAddress2), RoutingType.MULTICAST, queueName2, null, false);
session.createQueue(new SimpleString(forwardAddress3), queueName3, null, false);
session.createQueue(new SimpleString(forwardAddress3), RoutingType.MULTICAST, queueName3, null, false);
session.createQueue(new SimpleString(testAddress), queueName4, null, false);
session.createQueue(new SimpleString(testAddress), RoutingType.MULTICAST, queueName4, null, false);
session.start();
@ -1085,13 +1086,13 @@ public class DivertTest extends ActiveMQTestBase {
final SimpleString queueName4 = new SimpleString("queue4");
session.createQueue(new SimpleString(forwardAddress1), queueName1, null, false);
session.createQueue(new SimpleString(forwardAddress1), RoutingType.MULTICAST, queueName1, null, false);
session.createQueue(new SimpleString(forwardAddress2), queueName2, null, false);
session.createQueue(new SimpleString(forwardAddress2), RoutingType.MULTICAST, queueName2, null, false);
session.createQueue(new SimpleString(forwardAddress3), queueName3, null, false);
session.createQueue(new SimpleString(forwardAddress3), RoutingType.MULTICAST, queueName3, null, false);
session.createQueue(new SimpleString(testAddress), queueName4, null, false);
session.createQueue(new SimpleString(testAddress), RoutingType.MULTICAST, queueName4, null, false);
session.start();
@ -1173,7 +1174,7 @@ public class DivertTest extends ActiveMQTestBase {
ActiveMQServer server = addServer(new ActiveMQServerImpl(null, null, null, null, serviceRegistry));
server.start();
server.waitForActivation(100, TimeUnit.MILLISECONDS);
server.deployQueue(ADDRESS, SimpleString.toSimpleString("myQueue"), null, false, false);
server.deployQueue(ADDRESS, RoutingType.MULTICAST, SimpleString.toSimpleString("myQueue"), null, false, false);
server.deployDivert(new DivertConfiguration().setName(DIVERT).setAddress(ADDRESS.toString()).setForwardingAddress(ADDRESS.toString()));
Collection<Binding> bindings = server.getPostOffice().getBindingsForAddress(ADDRESS).getBindings();
Divert divert = null;

View File

@ -83,7 +83,7 @@ public class TopicCleanupTest extends JMSTestBase {
final Queue queue = new QueueImpl(storage.generateID(), SimpleString.toSimpleString("topic"), SimpleString.toSimpleString("topic"), FilterImpl.createFilter(ActiveMQServerImpl.GENERIC_IGNORED_FILTER), null, true, false, false, server.getScheduledPool(), server.getPostOffice(), storage, server.getAddressSettingsRepository(), server.getExecutorFactory().getExecutor());
LocalQueueBinding binding = new LocalQueueBinding(server.getAddressInfo(queue.getAddress()), queue, server.getNodeID());
LocalQueueBinding binding = new LocalQueueBinding(queue.getAddress(), queue, server.getNodeID());
storage.addQueueBinding(txid, binding);

View File

@ -640,7 +640,7 @@ public class ConsumerTest extends JMSTestBase {
}
@Test
public void testShareDurale() throws Exception {
public void testShareDurable() throws Exception {
((ActiveMQConnectionFactory) cf).setConsumerWindowSize(0);
conn = cf.createConnection();
conn.start();

View File

@ -17,11 +17,13 @@
package org.apache.activemq.artemis.tests.integration.management;
import java.util.Map;
import java.util.Set;
import org.apache.activemq.artemis.api.core.ActiveMQAddressDoesNotExistException;
import org.apache.activemq.artemis.api.core.management.ActiveMQServerControl;
import org.apache.activemq.artemis.api.core.management.Parameter;
import org.apache.activemq.artemis.api.core.management.ResourceNames;
import org.apache.activemq.artemis.core.server.RoutingType;
import org.apache.activemq.artemis.core.settings.impl.AddressSettings;
public class ActiveMQServerControlUsingCoreTest extends ActiveMQServerControlTest {
@ -101,17 +103,17 @@ public class ActiveMQServerControlUsingCoreTest extends ActiveMQServerControlTes
}
@Override
public void createAddress(@Parameter(name = "name", desc = "The name of the address") String name, @Parameter(name = "routingType", desc = "the routing type of the address either 0 for multicast or 1 for anycast") int routingType, @Parameter(name = "defaultDeleteOnNoConsumers", desc = "Whether or not a queue with this address is deleted when it has no consumers") boolean defaultDeleteOnNoConsumers, @Parameter(name = "defaultMaxConsumers", desc = "The maximim number of consumer a queue with this address can have") int defaultMaxConsumers) throws Exception {
proxy.invokeOperation("createAddress", name, routingType, defaultDeleteOnNoConsumers, defaultMaxConsumers);
public void createQueue(@Parameter(name = "address", desc = "Address of the queue") String address,
@Parameter(name = "routingType", desc = "The routing type used for this address, 0=multicast, 1=anycast") RoutingType routingType,
@Parameter(name = "name", desc = "Name of the queue") String name,
@Parameter(name = "filter", desc = "Filter of the queue") String filterStr,
@Parameter(name = "durable", desc = "Is the queue durable?") boolean durable,
@Parameter(name = "maxConsumers", desc = "The maximum number of consumers allowed on this queue at any one time") int maxConsumers,
@Parameter(name = "deleteOnNoConsumers", desc = "Delete this queue when the last consumer disconnects") boolean deleteOnNoConsumers,
@Parameter(name = "autoCreateAddress", desc = "Create an address with default values should a matching address not be found") boolean autoCreateAddress) throws Exception {
}
@Override
public void createAddress(@Parameter(name = "name", desc = "The name of the address") String name,
@Parameter(name = "routingType", desc = "The routing type for the address either 'MULTICAST' or 'ANYCAST'") String routingType,
@Parameter(name = "defaultDeleteOnNoConsumers", desc = "Whether or not a queue with this address is deleted when it has no consumers") boolean defaultDeleteOnNoConsumers,
@Parameter(name = "defaultMaxConsumers", desc = "The maximim number of consumer a queue with this address can have") int defaultMaxConsumers) throws Exception {
proxy.invokeOperation("createAddress", name, routingType, defaultDeleteOnNoConsumers, defaultMaxConsumers);
}
@Override
public void deleteAddress(@Parameter(name = "name", desc = "The name of the address") String name) throws Exception {
@ -131,16 +133,6 @@ public class ActiveMQServerControlUsingCoreTest extends ActiveMQServerControlTes
proxy.invokeOperation("createQueue", address, name, durable);
}
@Override
public void createQueue(@Parameter(name = "address", desc = "Address of the queue") String address,
@Parameter(name = "name", desc = "Name of the queue") String name,
@Parameter(name = "filter", desc = "Filter of the queue") String filter,
@Parameter(name = "durable", desc = "Is the queue durable?") boolean durable,
@Parameter(name = "maxConsumers", desc = "The maximum number of consumers allowed on this queue at any one time") int maxConsumers,
@Parameter(name = "deleteOnNoConsumers", desc = "Delete this queue when the last consumer disconnects") boolean deleteOnNoConsumers,
@Parameter(name = "autoCreateAddress", desc = "Create an address with default values should a matching address not be found") boolean autoCreateAddress) throws Exception {
}
@Override
public void deployQueue(final String address,
@ -573,6 +565,12 @@ public class ActiveMQServerControlUsingCoreTest extends ActiveMQServerControlTes
return (Long) proxy.retrieveAttributeValue("GlobalMaxSize", Long.class);
}
@Override
public void createAddress(@Parameter(name = "name", desc = "The name of the address") String name,
@Parameter(name = "deliveryMode", desc = "The delivery modes enabled for this address'") Set<RoutingType> routingTypes) throws Exception {
}
@Override
public void addSecuritySettings(String addressMatch,
String sendRoles,

View File

@ -38,6 +38,8 @@ import java.util.regex.Pattern;
import org.apache.activemq.artemis.api.core.SimpleString;
import org.apache.activemq.artemis.core.protocol.mqtt.MQTTConnectionManager;
import org.apache.activemq.artemis.core.protocol.mqtt.MQTTSession;
import org.apache.activemq.artemis.core.server.Queue;
import org.apache.activemq.artemis.core.server.RoutingType;
import org.apache.activemq.artemis.core.server.impl.AddressInfo;
import org.apache.activemq.artemis.tests.integration.mqtt.imported.util.Wait;
import org.fusesource.mqtt.client.BlockingConnection;
@ -1625,10 +1627,9 @@ public class MQTTTest extends MQTTTestSupport {
Topic[] mqttSubscription = new Topic[]{new Topic("foo/bar", QoS.AT_LEAST_ONCE)};
AddressInfo addressInfo = new AddressInfo(coreAddress);
addressInfo.setDefaultMaxQueueConsumers(0);
getServer().createOrUpdateAddressInfo(addressInfo);
getServer().createQueue(coreAddress, new SimpleString(clientId + "." + coreAddress), null, false, true, 0, false, false);
getServer().createQueue(coreAddress, RoutingType.MULTICAST, new SimpleString(clientId + "." + coreAddress), null, false, true, 0, false, false);
MQTT mqtt = createMQTTConnection();
mqtt.setClientId(clientId);
@ -1652,7 +1653,7 @@ public class MQTTTest extends MQTTTestSupport {
Topic[] mqttSubscription = new Topic[]{new Topic("foo/bar", QoS.AT_LEAST_ONCE)};
AddressInfo addressInfo = new AddressInfo(coreAddress);
addressInfo.setRoutingType(AddressInfo.RoutingType.ANYCAST);
addressInfo.addRoutingType(RoutingType.ANYCAST);
getServer().createOrUpdateAddressInfo(addressInfo);
MQTT mqtt = createMQTTConnection();
@ -1674,7 +1675,7 @@ public class MQTTTest extends MQTTTestSupport {
try {
String clientId = "testMqtt";
SimpleString coreAddress = new SimpleString("foo.bar");
getServer().createQueue(coreAddress, new SimpleString(clientId + "." + coreAddress), null, false, true, -1, true, false);
getServer().createQueue(coreAddress, RoutingType.MULTICAST, new SimpleString(clientId + "." + coreAddress), null, false, true, Queue.MAX_CONSUMERS_UNLIMITED, true, false);
Topic[] mqttSubscription = new Topic[]{new Topic("foo/bar", QoS.AT_LEAST_ONCE)};

View File

@ -32,6 +32,7 @@ import org.apache.activemq.ActiveMQConnectionFactory;
import org.apache.activemq.ActiveMQXAConnectionFactory;
import org.apache.activemq.artemis.api.core.ActiveMQNonExistentQueueException;
import org.apache.activemq.artemis.api.core.SimpleString;
import org.apache.activemq.artemis.core.server.RoutingType;
import org.apache.activemq.command.ActiveMQDestination;
import org.junit.After;
import org.junit.Before;
@ -64,15 +65,15 @@ public class BasicOpenWireTest extends OpenWireTestBase {
public void setUp() throws Exception {
super.setUp();
SimpleString coreQueue = new SimpleString(queueName);
this.server.createQueue(coreQueue, coreQueue, null, false, false);
this.server.createQueue(coreQueue, RoutingType.MULTICAST, coreQueue, null, false, false);
testQueues.put(queueName, coreQueue);
SimpleString coreQueue2 = new SimpleString(queueName2);
this.server.createQueue(coreQueue2, coreQueue2, null, false, false);
this.server.createQueue(coreQueue2, RoutingType.MULTICAST, coreQueue2, null, false, false);
testQueues.put(queueName2, coreQueue2);
SimpleString durableQueue = new SimpleString(durableQueueName);
this.server.createQueue(durableQueue, durableQueue, null, true, false);
this.server.createQueue(durableQueue, RoutingType.MULTICAST, durableQueue, null, true, false);
testQueues.put(durableQueueName, durableQueue);
if (!enableSecurity) {
@ -138,7 +139,7 @@ public class BasicOpenWireTest extends OpenWireTestBase {
SimpleString coreQ = testQueues.get(qname);
if (coreQ == null) {
coreQ = new SimpleString(qname);
this.server.createQueue(coreQ, coreQ, null, false, false);
this.server.createQueue(coreQ, RoutingType.MULTICAST, coreQ, null, false, false);
testQueues.put(qname, coreQ);
}
}

View File

@ -65,7 +65,7 @@ public class JmsTopicRedeliverTest extends BasicOpenWireTest {
System.out.println("Created session: " + session);
System.out.println("Created consumeSession: " + consumeSession);
producer = session.createProducer(null);
// producer.setDeliveryMode(deliveryMode);
// producer.setRoutingType(deliveryMode);
System.out.println("Created producer: " + producer);

View File

@ -44,6 +44,7 @@ import org.apache.activemq.artemis.core.remoting.impl.invm.InVMConnectorFactory;
import org.apache.activemq.artemis.core.security.Role;
import org.apache.activemq.artemis.core.server.ActiveMQServer;
import org.apache.activemq.artemis.core.server.ActiveMQServers;
import org.apache.activemq.artemis.core.server.RoutingType;
import org.apache.activemq.artemis.spi.core.security.ActiveMQJAASSecurityManager;
import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
import org.apache.directory.server.annotations.CreateLdapServer;
@ -177,8 +178,8 @@ public class LDAPSecurityTest extends AbstractLdapTestUnit {
roles.add(new Role("programmers", false, false, false, false, false, false, false, false, false, false));
server.getConfiguration().putSecurityRoles("#", roles);
server.start();
server.createQueue(ADDRESS, DURABLE_QUEUE, null, true, false);
server.createQueue(ADDRESS, NON_DURABLE_QUEUE, null, false, false);
server.createQueue(ADDRESS, RoutingType.MULTICAST, DURABLE_QUEUE, null, true, false);
server.createQueue(ADDRESS, RoutingType.MULTICAST, NON_DURABLE_QUEUE, null, false, false);
ClientSessionFactory cf = locator.createSessionFactory();
ClientSession session = cf.createSession("first", "secret", false, true, true, false, 0);

View File

@ -32,6 +32,7 @@ import org.apache.activemq.artemis.core.config.impl.ConfigurationImpl;
import org.apache.activemq.artemis.core.server.ActiveMQServer;
import org.apache.activemq.artemis.core.server.ActiveMQServers;
import org.apache.activemq.artemis.core.server.Queue;
import org.apache.activemq.artemis.core.server.RoutingType;
import org.apache.activemq.artemis.core.settings.impl.AddressSettings;
import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
import org.junit.Assert;
@ -71,7 +72,7 @@ public class ExpiryRunnerTest extends ActiveMQTestBase {
@Test
public void testExpireFromMultipleQueues() throws Exception {
ClientProducer producer = clientSession.createProducer(qName);
clientSession.createQueue(qName2, qName2, null, false);
clientSession.createQueue(qName2, RoutingType.MULTICAST, qName2, null, false);
AddressSettings addressSettings = new AddressSettings().setExpiryAddress(expiryAddress);
server.getAddressSettingsRepository().addMatch(qName2.toString(), addressSettings);
ClientProducer producer2 = clientSession.createProducer(qName2);
@ -136,8 +137,8 @@ public class ExpiryRunnerTest extends ActiveMQTestBase {
AddressSettings addressSettings = new AddressSettings().setExpiryAddress(expiryAddress);
server.getAddressSettingsRepository().addMatch(qName2.toString(), addressSettings);
clientSession.deleteQueue(qName);
clientSession.createQueue(qName, qName, null, false);
clientSession.createQueue(qName, qName2, null, false);
clientSession.createQueue(qName, RoutingType.MULTICAST, qName, null, false);
clientSession.createQueue(qName, RoutingType.MULTICAST, qName2, null, false);
ClientProducer producer = clientSession.createProducer(qName);
int numMessages = 100;
long expiration = System.currentTimeMillis();
@ -241,13 +242,13 @@ public class ExpiryRunnerTest extends ActiveMQTestBase {
ClientSessionFactory sessionFactory = createSessionFactory(locator);
clientSession = sessionFactory.createSession(false, true, true);
clientSession.createQueue(qName, qName, null, false);
clientSession.createQueue(qName, RoutingType.MULTICAST, qName, null, false);
expiryAddress = new SimpleString("EA");
expiryQueue = new SimpleString("expiryQ");
AddressSettings addressSettings = new AddressSettings().setExpiryAddress(expiryAddress);
server.getAddressSettingsRepository().addMatch(qName.toString(), addressSettings);
server.getAddressSettingsRepository().addMatch(qName2.toString(), addressSettings);
clientSession.createQueue(expiryAddress, expiryQueue, null, false);
clientSession.createQueue(expiryAddress, RoutingType.MULTICAST, expiryQueue, null, false);
}
private static class DummyMessageHandler implements Runnable {

View File

@ -33,6 +33,7 @@ import org.apache.activemq.artemis.core.config.CoreQueueConfiguration;
import org.apache.activemq.artemis.core.postoffice.Bindings;
import org.apache.activemq.artemis.core.server.ActiveMQServer;
import org.apache.activemq.artemis.core.server.ActiveMQServers;
import org.apache.activemq.artemis.core.server.RoutingType;
import org.apache.activemq.artemis.tests.integration.IntegrationTestLogger;
import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
import org.junit.Assert;
@ -87,7 +88,7 @@ public class PredefinedQueueTest extends ActiveMQTestBase {
ClientSession session = addClientSession(sf.createSession(false, true, true));
try {
session.createQueue(testAddress, queueName1, null, false);
session.createQueue(testAddress, queueName1, "", false);
Assert.fail("Should throw exception");
} catch (ActiveMQQueueExistsException se) {

View File

@ -17,7 +17,6 @@
package org.apache.activemq.artemis.tests.integration.stomp;
import javax.jms.BytesMessage;
import javax.jms.DeliveryMode;
import javax.jms.Message;
import javax.jms.MessageConsumer;
import javax.jms.MessageListener;
@ -25,6 +24,8 @@ import javax.jms.MessageProducer;
import javax.jms.TextMessage;
import java.io.ByteArrayOutputStream;
import java.nio.charset.StandardCharsets;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
@ -45,6 +46,7 @@ import org.apache.activemq.artemis.api.jms.ActiveMQJMSClient;
import org.apache.activemq.artemis.core.postoffice.impl.LocalQueueBinding;
import org.apache.activemq.artemis.core.protocol.stomp.Stomp;
import org.apache.activemq.artemis.core.protocol.stomp.StompProtocolManagerFactory;
import org.apache.activemq.artemis.core.server.RoutingType;
import org.apache.activemq.artemis.core.server.Queue;
import org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl;
import org.apache.activemq.artemis.core.server.impl.AddressInfo;
@ -269,7 +271,7 @@ public class StompTest extends StompTestBase {
public void testSendMessageToNonExistentQueue() throws Exception {
String nonExistentQueue = RandomUtil.randomString();
conn.connect(defUser, defPass);
send(conn, getQueuePrefix() + nonExistentQueue, null, "Hello World", true, AddressInfo.RoutingType.ANYCAST);
send(conn, getQueuePrefix() + nonExistentQueue, null, "Hello World", true, RoutingType.ANYCAST);
MessageConsumer consumer = session.createConsumer(ActiveMQJMSClient.createQueue(nonExistentQueue));
TextMessage message = (TextMessage) consumer.receive(1000);
@ -300,7 +302,7 @@ public class StompTest extends StompTestBase {
conn.connect(defUser, defPass);
// first send a message to ensure that sending to a non-existent topic won't throw an error
send(conn, getTopicPrefix() + nonExistentTopic, null, "Hello World", true, AddressInfo.RoutingType.MULTICAST);
send(conn, getTopicPrefix() + nonExistentTopic, null, "Hello World", true, RoutingType.MULTICAST);
// create a subscription on the topic and send/receive another message
MessageConsumer consumer = session.createConsumer(ActiveMQJMSClient.createTopic(nonExistentTopic));
@ -488,7 +490,7 @@ public class StompTest extends StompTestBase {
Assert.assertEquals("JMSCorrelationID", "c123", message.getJMSCorrelationID());
Assert.assertEquals("getJMSType", "t345", message.getJMSType());
Assert.assertEquals("getJMSPriority", 3, message.getJMSPriority());
Assert.assertEquals(DeliveryMode.PERSISTENT, message.getJMSDeliveryMode());
Assert.assertEquals(javax.jms.DeliveryMode.PERSISTENT, message.getJMSDeliveryMode());
Assert.assertEquals("foo", "abc", message.getStringProperty("foo"));
Assert.assertEquals("bar", "123", message.getStringProperty("bar"));
@ -527,7 +529,7 @@ public class StompTest extends StompTestBase {
Assert.assertEquals("JMSCorrelationID", "c123", message.getJMSCorrelationID());
Assert.assertEquals("getJMSType", "t345", message.getJMSType());
Assert.assertEquals("getJMSPriority", 3, message.getJMSPriority());
Assert.assertEquals(DeliveryMode.PERSISTENT, message.getJMSDeliveryMode());
Assert.assertEquals(javax.jms.DeliveryMode.PERSISTENT, message.getJMSDeliveryMode());
Assert.assertEquals("foo", "abc", message.getStringProperty("foo"));
Assert.assertEquals("longHeader", 1024, message.getStringProperty("longHeader")
.length());
@ -1257,45 +1259,45 @@ public class StompTest extends StompTestBase {
@Test
public void testDotAnycastPrefixOnSend() throws Exception {
testPrefix("jms.queue.", AddressInfo.RoutingType.ANYCAST, true);
testPrefix("jms.queue.", RoutingType.ANYCAST, true);
}
@Test
public void testDotMulticastPrefixOnSend() throws Exception {
testPrefix("jms.topic.", AddressInfo.RoutingType.MULTICAST, true);
testPrefix("jms.topic.", RoutingType.MULTICAST, true);
}
@Test
public void testDotAnycastPrefixOnSubscribe() throws Exception {
testPrefix("jms.queue.", AddressInfo.RoutingType.ANYCAST, false);
testPrefix("jms.queue.", RoutingType.ANYCAST, false);
}
@Test
public void testDotMulticastPrefixOnSubscribe() throws Exception {
testPrefix("jms.topic.", AddressInfo.RoutingType.MULTICAST, false);
testPrefix("jms.topic.", RoutingType.MULTICAST, false);
}
@Test
public void testSlashAnycastPrefixOnSend() throws Exception {
testPrefix("/queue/", AddressInfo.RoutingType.ANYCAST, true);
testPrefix("/queue/", RoutingType.ANYCAST, true);
}
@Test
public void testSlashMulticastPrefixOnSend() throws Exception {
testPrefix("/topic/", AddressInfo.RoutingType.MULTICAST, true);
testPrefix("/topic/", RoutingType.MULTICAST, true);
}
@Test
public void testSlashAnycastPrefixOnSubscribe() throws Exception {
testPrefix("/queue/", AddressInfo.RoutingType.ANYCAST, false);
testPrefix("/queue/", RoutingType.ANYCAST, false);
}
@Test
public void testSlashMulticastPrefixOnSubscribe() throws Exception {
testPrefix("/topic/", AddressInfo.RoutingType.MULTICAST, false);
testPrefix("/topic/", RoutingType.MULTICAST, false);
}
public void testPrefix(final String prefix, final AddressInfo.RoutingType routingType, final boolean send) throws Exception {
public void testPrefix(final String prefix, final RoutingType routingType, final boolean send) throws Exception {
int port = 61614;
final String ADDRESS = UUID.randomUUID().toString();
final String PREFIXED_ADDRESS = prefix + ADDRESS;
@ -1322,32 +1324,35 @@ public class StompTest extends StompTestBase {
AddressInfo addressInfo = server.getActiveMQServer().getAddressInfo(SimpleString.toSimpleString(ADDRESS));
assertNotNull("No address was created with the name " + ADDRESS, addressInfo);
assertEquals(AddressInfo.RoutingType.valueOf(param), addressInfo.getRoutingType());
Set<RoutingType> deliveryModest = new HashSet<>();
deliveryModest.add(RoutingType.valueOf(param));
assertEquals(deliveryModest, addressInfo.getRoutingTypes());
conn.disconnect();
}
@Test
public void testDotPrefixedSendAndRecieveAnycast() throws Exception {
testPrefixedSendAndRecieve("jms.queue.", AddressInfo.RoutingType.ANYCAST);
testPrefixedSendAndRecieve("jms.queue.", RoutingType.ANYCAST);
}
@Test
public void testDotPrefixedSendAndRecieveMulticast() throws Exception {
testPrefixedSendAndRecieve("jms.topic.", AddressInfo.RoutingType.MULTICAST);
testPrefixedSendAndRecieve("jms.topic.", RoutingType.MULTICAST);
}
@Test
public void testSlashPrefixedSendAndRecieveAnycast() throws Exception {
testPrefixedSendAndRecieve("/queue/", AddressInfo.RoutingType.ANYCAST);
testPrefixedSendAndRecieve("/queue/", RoutingType.ANYCAST);
}
@Test
public void testSlashPrefixedSendAndRecieveMulticast() throws Exception {
testPrefixedSendAndRecieve("/topic/", AddressInfo.RoutingType.MULTICAST);
testPrefixedSendAndRecieve("/topic/", RoutingType.MULTICAST);
}
public void testPrefixedSendAndRecieve(final String prefix, AddressInfo.RoutingType routingType) throws Exception {
public void testPrefixedSendAndRecieve(final String prefix, RoutingType routingType) throws Exception {
int port = 61614;
final String ADDRESS = UUID.randomUUID().toString();
final String PREFIXED_ADDRESS = prefix + ADDRESS;
@ -1378,12 +1383,12 @@ public class StompTest extends StompTestBase {
@Test
public void testMulticastOperationsOnAnycastAddress() throws Exception {
testRoutingSemantics(AddressInfo.RoutingType.MULTICAST.toString(), getQueuePrefix() + getQueueName());
testRoutingSemantics(RoutingType.MULTICAST.toString(), getQueuePrefix() + getQueueName());
}
@Test
public void testAnycastOperationsOnMulticastAddress() throws Exception {
testRoutingSemantics(AddressInfo.RoutingType.ANYCAST.toString(), getTopicPrefix() + getTopicName());
testRoutingSemantics(RoutingType.ANYCAST.toString(), getTopicPrefix() + getTopicName());
}
public void testRoutingSemantics(String routingType, String destination) throws Exception {
@ -1402,7 +1407,7 @@ public class StompTest extends StompTestBase {
uuid = UUID.randomUUID().toString();
frame = conn.createFrame(Stomp.Commands.SEND)
.addHeader(Stomp.Headers.Send.DESTINATION_TYPE, AddressInfo.RoutingType.MULTICAST.toString())
.addHeader(Stomp.Headers.Send.DESTINATION_TYPE, RoutingType.MULTICAST.toString())
.addHeader(Stomp.Headers.Send.DESTINATION, getQueuePrefix() + getQueueName())
.addHeader(Stomp.Headers.RECEIPT_REQUESTED, uuid);

View File

@ -46,7 +46,7 @@ import org.apache.activemq.artemis.core.remoting.impl.netty.TransportConstants;
import org.apache.activemq.artemis.core.security.Role;
import org.apache.activemq.artemis.core.server.ActiveMQServer;
import org.apache.activemq.artemis.core.server.ActiveMQServers;
import org.apache.activemq.artemis.core.server.impl.AddressInfo;
import org.apache.activemq.artemis.core.server.RoutingType;
import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory;
import org.apache.activemq.artemis.jms.client.ActiveMQJMSConnectionFactory;
import org.apache.activemq.artemis.jms.server.JMSServerManager;
@ -363,7 +363,7 @@ public abstract class StompTestBase extends ActiveMQTestBase {
String destination,
boolean receipt) throws IOException, InterruptedException {
ClientStompFrame frame = conn.createFrame(Stomp.Commands.SUBSCRIBE)
.addHeader(Stomp.Headers.Subscribe.SUBSCRIPTION_TYPE, AddressInfo.RoutingType.ANYCAST.toString())
.addHeader(Stomp.Headers.Subscribe.SUBSCRIPTION_TYPE, RoutingType.ANYCAST.toString())
.addHeader(Stomp.Headers.Subscribe.DESTINATION, destination);
if (subscriptionId != null) {
frame.addHeader(Stomp.Headers.Subscribe.ID, subscriptionId);
@ -413,7 +413,7 @@ public abstract class StompTestBase extends ActiveMQTestBase {
boolean receipt,
boolean noLocal) throws IOException, InterruptedException {
ClientStompFrame frame = conn.createFrame(Stomp.Commands.SUBSCRIBE)
.addHeader(Stomp.Headers.Subscribe.SUBSCRIPTION_TYPE, AddressInfo.RoutingType.MULTICAST.toString())
.addHeader(Stomp.Headers.Subscribe.SUBSCRIPTION_TYPE, RoutingType.MULTICAST.toString())
.addHeader(Stomp.Headers.Subscribe.DESTINATION, getTopicPrefix() + getTopicName());
if (subscriptionId != null) {
frame.addHeader(Stomp.Headers.Subscribe.ID, subscriptionId);
@ -492,11 +492,11 @@ public abstract class StompTestBase extends ActiveMQTestBase {
return send(conn, destination, contentType, body, receipt, null);
}
public ClientStompFrame send(StompClientConnection conn, String destination, String contentType, String body, boolean receipt, AddressInfo.RoutingType destinationType) throws IOException, InterruptedException {
public ClientStompFrame send(StompClientConnection conn, String destination, String contentType, String body, boolean receipt, RoutingType destinationType) throws IOException, InterruptedException {
return send(conn, destination, contentType, body, receipt, destinationType, null);
}
public ClientStompFrame send(StompClientConnection conn, String destination, String contentType, String body, boolean receipt, AddressInfo.RoutingType destinationType, String txId) throws IOException, InterruptedException {
public ClientStompFrame send(StompClientConnection conn, String destination, String contentType, String body, boolean receipt, RoutingType destinationType, String txId) throws IOException, InterruptedException {
ClientStompFrame frame = conn.createFrame(Stomp.Commands.SEND)
.addHeader(Stomp.Headers.Send.DESTINATION, destination)
.setBody(body);

View File

@ -17,7 +17,6 @@
package org.apache.activemq.artemis.tests.integration.stomp.v11;
import javax.jms.BytesMessage;
import javax.jms.DeliveryMode;
import javax.jms.Message;
import javax.jms.MessageConsumer;
import javax.jms.MessageListener;
@ -32,7 +31,7 @@ import java.util.concurrent.TimeUnit;
import org.apache.activemq.artemis.api.core.SimpleString;
import org.apache.activemq.artemis.core.protocol.stomp.Stomp;
import org.apache.activemq.artemis.core.server.impl.AddressInfo;
import org.apache.activemq.artemis.core.server.RoutingType;
import org.apache.activemq.artemis.tests.integration.IntegrationTestLogger;
import org.apache.activemq.artemis.tests.integration.stomp.StompTestBase;
import org.apache.activemq.artemis.tests.integration.stomp.util.ClientStompFrame;
@ -1757,7 +1756,7 @@ public class StompV11Test extends StompTestBase {
Assert.assertEquals("JMSCorrelationID", "c123", message.getJMSCorrelationID());
Assert.assertEquals("getJMSType", "t345", message.getJMSType());
Assert.assertEquals("getJMSPriority", 3, message.getJMSPriority());
Assert.assertEquals(DeliveryMode.PERSISTENT, message.getJMSDeliveryMode());
Assert.assertEquals(javax.jms.DeliveryMode.PERSISTENT, message.getJMSDeliveryMode());
Assert.assertEquals("foo", "abc", message.getStringProperty("foo"));
Assert.assertEquals("bar", "123", message.getStringProperty("bar"));
@ -1796,7 +1795,7 @@ public class StompV11Test extends StompTestBase {
Assert.assertEquals("JMSCorrelationID", "c123", message.getJMSCorrelationID());
Assert.assertEquals("getJMSType", "t345", message.getJMSType());
Assert.assertEquals("getJMSPriority", 3, message.getJMSPriority());
Assert.assertEquals(DeliveryMode.PERSISTENT, message.getJMSDeliveryMode());
Assert.assertEquals(javax.jms.DeliveryMode.PERSISTENT, message.getJMSDeliveryMode());
Assert.assertEquals("foo", "abc", message.getStringProperty("foo"));
Assert.assertEquals("longHeader", 2048, message.getStringProperty("longHeader").length());
@ -2163,7 +2162,7 @@ public class StompV11Test extends StompTestBase {
public void testSendMessageToNonExistentQueueWithAutoCreation() throws Exception {
conn.connect(defUser, defPass);
send(conn, "NonExistentQueue" + UUID.randomUUID().toString(), null, "Hello World", true, AddressInfo.RoutingType.ANYCAST);
send(conn, "NonExistentQueue" + UUID.randomUUID().toString(), null, "Hello World", true, RoutingType.ANYCAST);
conn.disconnect();
}

View File

@ -17,7 +17,6 @@
package org.apache.activemq.artemis.tests.integration.stomp.v12;
import javax.jms.BytesMessage;
import javax.jms.DeliveryMode;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageConsumer;
@ -33,7 +32,7 @@ import java.util.concurrent.TimeUnit;
import org.apache.activemq.artemis.api.core.SimpleString;
import org.apache.activemq.artemis.core.protocol.stomp.Stomp;
import org.apache.activemq.artemis.core.server.impl.AddressInfo;
import org.apache.activemq.artemis.core.server.RoutingType;
import org.apache.activemq.artemis.core.settings.impl.AddressSettings;
import org.apache.activemq.artemis.tests.integration.IntegrationTestLogger;
import org.apache.activemq.artemis.tests.integration.stomp.StompTestBase;
@ -1755,7 +1754,7 @@ public class StompV12Test extends StompTestBase {
Assert.assertEquals("JMSCorrelationID", "c123", message.getJMSCorrelationID());
Assert.assertEquals("getJMSType", "t345", message.getJMSType());
Assert.assertEquals("getJMSPriority", 3, message.getJMSPriority());
Assert.assertEquals(DeliveryMode.PERSISTENT, message.getJMSDeliveryMode());
Assert.assertEquals(javax.jms.DeliveryMode.PERSISTENT, message.getJMSDeliveryMode());
Assert.assertEquals("foo", "abc", message.getStringProperty("foo"));
Assert.assertEquals("bar", "123", message.getStringProperty("bar"));
@ -1794,7 +1793,7 @@ public class StompV12Test extends StompTestBase {
Assert.assertEquals("JMSCorrelationID", "c123", message.getJMSCorrelationID());
Assert.assertEquals("getJMSType", "t345", message.getJMSType());
Assert.assertEquals("getJMSPriority", 3, message.getJMSPriority());
Assert.assertEquals(DeliveryMode.PERSISTENT, message.getJMSDeliveryMode());
Assert.assertEquals(javax.jms.DeliveryMode.PERSISTENT, message.getJMSDeliveryMode());
Assert.assertEquals("foo", "abc", message.getStringProperty("foo"));
Assert.assertEquals("very-very-long-stomp-message-header", 2048, message.getStringProperty("very-very-long-stomp-message-header").length());
@ -2207,7 +2206,7 @@ public class StompV12Test extends StompTestBase {
public void testSendMessageToNonExistentQueueWithAutoCreation() throws Exception {
conn.connect(defUser, defPass);
send(conn, "NonExistentQueue" + UUID.randomUUID().toString(), null, "Hello World", true, AddressInfo.RoutingType.ANYCAST);
send(conn, "NonExistentQueue" + UUID.randomUUID().toString(), null, "Hello World", true, RoutingType.ANYCAST);
conn.disconnect();
}

View File

@ -49,6 +49,7 @@ import org.apache.activemq.artemis.api.core.client.SendAcknowledgementHandler;
import org.apache.activemq.artemis.api.core.client.SessionFailureListener;
import org.apache.activemq.artemis.core.client.impl.ClientMessageImpl;
import org.apache.activemq.artemis.core.remoting.FailureListener;
import org.apache.activemq.artemis.core.server.RoutingType;
import org.apache.activemq.artemis.jms.client.ActiveMQBytesMessage;
import org.apache.activemq.artemis.jms.client.ActiveMQMapMessage;
import org.apache.activemq.artemis.jms.client.ActiveMQMessage;
@ -867,6 +868,218 @@ public class MessageHeaderTest extends MessageHeaderTestBase {
final String filter) throws ActiveMQException {
}
/**
* Creates a <em>non-temporary</em> queue.
*
* @param address the queue will be bound to this address
* @param routingType the delivery mode for this queue, MULTICAST or ANYCAST
* @param queueName the name of the queue
* @param durable whether the queue is durable or not
* @throws ActiveMQException in an exception occurs while creating the queue
*/
@Override
public void createQueue(SimpleString address, RoutingType routingType, SimpleString queueName, boolean durable) throws ActiveMQException {
}
/**
* Creates a transient queue. A queue that will exist as long as there are consumers. When the last consumer is closed the queue will be deleted
* <p>
* Notice: you will get an exception if the address or the filter doesn't match to an already existent queue
*
* @param address the queue will be bound to this address
* @param routingType the delivery mode for this queue, MULTICAST or ANYCAST
* @param queueName the name of the queue
* @param durable if the queue is durable
* @throws ActiveMQException in an exception occurs while creating the queue
*/
@Override
public void createSharedQueue(SimpleString address, RoutingType routingType, SimpleString queueName, boolean durable) throws ActiveMQException {
}
/**
* Creates a transient queue. A queue that will exist as long as there are consumers. When the last consumer is closed the queue will be deleted
* <p>
* Notice: you will get an exception if the address or the filter doesn't match to an already existent queue
*
* @param address the queue will be bound to this address
* @param routingType the delivery mode for this queue, MULTICAST or ANYCAST
* @param queueName the name of the queue
* @param filter whether the queue is durable or not
* @param durable if the queue is durable
* @throws ActiveMQException in an exception occurs while creating the queue
*/
@Override
public void createSharedQueue(SimpleString address, RoutingType routingType, SimpleString queueName, SimpleString filter,
boolean durable) throws ActiveMQException {
}
/**
* Creates a <em>non-temporary</em> queue.
*
* @param address the queue will be bound to this address
* @param routingType the delivery mode for this queue, MULTICAST or ANYCAST
* @param queueName the name of the queue
* @param durable whether the queue is durable or not
* @throws ActiveMQException in an exception occurs while creating the queue
*/
@Override
public void createQueue(String address, RoutingType routingType, String queueName, boolean durable) throws ActiveMQException {
}
/**
* Creates a <em>non-temporary</em> queue <em>non-durable</em> queue.
*
* @param address the queue will be bound to this address
* @param routingType the delivery mode for this queue, MULTICAST or ANYCAST
* @param queueName the name of the queue
* @throws ActiveMQException in an exception occurs while creating the queue
*/
@Override
public void createQueue(String address, RoutingType routingType, String queueName) throws ActiveMQException {
}
/**
* Creates a <em>non-temporary</em> queue <em>non-durable</em> queue.
*
* @param address the queue will be bound to this address
* @param routingType the delivery mode for this queue, MULTICAST or ANYCAST
* @param queueName the name of the queue
* @throws ActiveMQException in an exception occurs while creating the queue
*/
@Override
public void createQueue(SimpleString address, RoutingType routingType, SimpleString queueName) throws ActiveMQException {
}
/**
* Creates a <em>non-temporary</em> queue.
*
* @param address the queue will be bound to this address
* @param routingType the delivery mode for this queue, MULTICAST or ANYCAST
* @param queueName the name of the queue
* @param filter only messages which match this filter will be put in the queue
* @param durable whether the queue is durable or not
* @throws ActiveMQException in an exception occurs while creating the queue
*/
@Override
public void createQueue(SimpleString address, RoutingType routingType, SimpleString queueName, SimpleString filter,
boolean durable) throws ActiveMQException {
}
/**
* Creates a <em>non-temporary</em>queue.
*
* @param address the queue will be bound to this address
* @param routingType the delivery mode for this queue, MULTICAST or ANYCAST
* @param queueName the name of the queue
* @param filter only messages which match this filter will be put in the queue
* @param durable whether the queue is durable or not
* @throws ActiveMQException in an exception occurs while creating the queue
*/
@Override
public void createQueue(String address, RoutingType routingType, String queueName, String filter, boolean durable) throws ActiveMQException {
}
/**
* Creates a <em>non-temporary</em> queue.
*
* @param address the queue will be bound to this address
* @param routingType the delivery mode for this queue, MULTICAST or ANYCAST
* @param queueName the name of the queue
* @param filter only messages which match this filter will be put in the queue
* @param durable whether the queue is durable or not
* @param autoCreated whether to mark this queue as autoCreated or not
* @throws ActiveMQException in an exception occurs while creating the queue
*/
@Override
public void createQueue(SimpleString address, RoutingType routingType, SimpleString queueName, SimpleString filter,
boolean durable,
boolean autoCreated) throws ActiveMQException {
}
/**
* Creates a <em>non-temporary</em>queue.
*
* @param address the queue will be bound to this address
* @param routingType the delivery mode for this queue, MULTICAST or ANYCAST
* @param queueName the name of the queue
* @param filter only messages which match this filter will be put in the queue
* @param durable whether the queue is durable or not
* @param autoCreated whether to mark this queue as autoCreated or not
* @throws ActiveMQException in an exception occurs while creating the queue
*/
@Override
public void createQueue(String address, RoutingType routingType, String queueName, String filter,
boolean durable,
boolean autoCreated) throws ActiveMQException {
}
/**
* Creates a <em>temporary</em> queue.
*
* @param address the queue will be bound to this address
* @param routingType the delivery mode for this queue, MULTICAST or ANYCAST
* @param queueName the name of the queue
* @throws ActiveMQException in an exception occurs while creating the queue
*/
@Override
public void createTemporaryQueue(SimpleString address, RoutingType routingType, SimpleString queueName) throws ActiveMQException {
}
/**
* Creates a <em>temporary</em> queue.
*
* @param address the queue will be bound to this address
* @param routingType the delivery mode for this queue, MULTICAST or ANYCAST
* @param queueName the name of the queue
* @throws ActiveMQException in an exception occurs while creating the queue
*/
@Override
public void createTemporaryQueue(String address, RoutingType routingType, String queueName) throws ActiveMQException {
}
/**
* Creates a <em>temporary</em> queue with a filter.
*
* @param address the queue will be bound to this address
* @param routingType the delivery mode for this queue, MULTICAST or ANYCAST
* @param queueName the name of the queue
* @param filter only messages which match this filter will be put in the queue
* @throws ActiveMQException in an exception occurs while creating the queue
*/
@Override
public void createTemporaryQueue(SimpleString address,
RoutingType routingType,
SimpleString queueName,
SimpleString filter) throws ActiveMQException {
}
/**
* Creates a <em>temporary</em> queue with a filter.
*
* @param address the queue will be bound to this address
* @param routingType the delivery mode for this queue, MULTICAST or ANYCAST
* @param queueName the name of the queue
* @param filter only messages which match this filter will be put in the queue
* @throws ActiveMQException in an exception occurs while creating the queue
*/
@Override
public void createTemporaryQueue(String address, RoutingType routingType, String queueName, String filter) throws ActiveMQException {
}
@Override
public void deleteQueue(final SimpleString queueName) throws ActiveMQException {
}
@ -1130,8 +1343,32 @@ public class MessageHeaderTest extends MessageHeaderTestBase {
return 0;
}
/**
* Create Address with a single initial routing type
*
* @param address
* @param routingTypes
* @param autoCreated @throws ActiveMQException
*/
@Override
public void createAddress(SimpleString address, boolean multicast, final boolean autoCreated) throws ActiveMQException {
public void createAddress(SimpleString address,
Set<RoutingType> routingTypes,
boolean autoCreated) throws ActiveMQException {
}
/**
* Create Address with a single initial routing type
*
* @param address
* @param routingType
* @param autoCreated
* @throws ActiveMQException
*/
@Override
public void createAddress(SimpleString address,
RoutingType routingType,
boolean autoCreated) throws ActiveMQException {
}

View File

@ -34,7 +34,7 @@ import org.apache.activemq.artemis.api.core.client.ServerLocator;
import org.apache.activemq.artemis.api.core.management.ManagementHelper;
import org.apache.activemq.artemis.api.core.management.ResourceNames;
import org.apache.activemq.artemis.core.remoting.impl.netty.NettyConnectorFactory;
import org.apache.activemq.artemis.core.server.impl.AddressInfo;
import org.apache.activemq.artemis.core.server.RoutingType;
import org.apache.activemq.artemis.tests.util.SpawnedVMSupport;
import org.objectweb.jtests.jms.admin.Admin;
@ -150,7 +150,7 @@ public class AbstractAdmin implements Admin {
public void createTopic(final String name) {
Boolean result;
try {
invokeSyncOperation(ResourceNames.BROKER, "createAddress", name, (int)AddressInfo.RoutingType.MULTICAST.getType(), false, -1);
invokeSyncOperation(ResourceNames.BROKER, "createAddress", name, (int) RoutingType.MULTICAST.getType(), false, -1);
} catch (Exception e) {
throw new IllegalStateException(e);
}

View File

@ -30,7 +30,7 @@ import org.objectweb.jtests.jms.framework.JMSTestCase;
public class MessageDefaultTest extends JMSTestCase {
/**
* test that the <code>DEFAULT_DELIVERY_MODE</code> of <code>javax.jms.Message</code>
* test that the <code>DEFAULT_ROUTING_TYPE</code> of <code>javax.jms.Message</code>
* corresponds to <code>javax.jms.Delivery.PERSISTENT</code>.
*/
@Test

View File

@ -133,12 +133,12 @@ public class MessageHeaderTest extends PTPTestCase {
/**
* Test that the <code>JMSDeliveryMode</code> header field value is ignored
* when the message is sent and that it holds the value specified by the sending
* method (i.e. <code>Message.DEFAULT_DELIVERY_MODE</code> in this test when the message is received.
* method (i.e. <code>Message.DEFAULT_ROUTING_TYPE</code> in this test when the message is received.
*/
@Test
public void testJMSDeliveryMode() {
try {
// sender has been created with the DEFAULT_DELIVERY_MODE which is PERSISTENT
// sender has been created with the DEFAULT_ROUTING_TYPE which is PERSISTENT
Assert.assertEquals(DeliveryMode.PERSISTENT, sender.getDeliveryMode());
Message message = senderSession.createMessage();
// send a message specfiying NON_PERSISTENT for the JMSDeliveryMode header field

View File

@ -25,6 +25,7 @@ import org.apache.activemq.artemis.api.core.SimpleString;
import org.apache.activemq.artemis.core.filter.Filter;
import org.apache.activemq.artemis.core.paging.cursor.PageSubscription;
import org.apache.activemq.artemis.core.server.Consumer;
import org.apache.activemq.artemis.core.server.RoutingType;
import org.apache.activemq.artemis.core.server.MessageReference;
import org.apache.activemq.artemis.core.server.Queue;
import org.apache.activemq.artemis.core.server.RoutingContext;
@ -559,6 +560,16 @@ public class FakeQueue implements Queue {
return subs;
}
@Override
public RoutingType getRoutingType() {
return null;
}
@Override
public void setRoutingType(RoutingType routingType) {
}
public void setPageSubscription(PageSubscription sub) {
this.subs = sub;
}