This closes #2038
This commit is contained in:
commit
10b661a5c2
|
@ -39,6 +39,7 @@ import io.airlift.airline.Arguments;
|
||||||
import io.airlift.airline.Command;
|
import io.airlift.airline.Command;
|
||||||
import io.airlift.airline.Option;
|
import io.airlift.airline.Option;
|
||||||
import org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration;
|
import org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration;
|
||||||
|
import org.apache.activemq.artemis.api.core.RoutingType;
|
||||||
import org.apache.activemq.artemis.cli.CLIException;
|
import org.apache.activemq.artemis.cli.CLIException;
|
||||||
import org.apache.activemq.artemis.cli.commands.util.HashUtil;
|
import org.apache.activemq.artemis.cli.commands.util.HashUtil;
|
||||||
import org.apache.activemq.artemis.cli.commands.util.SyncCalculation;
|
import org.apache.activemq.artemis.cli.commands.util.SyncCalculation;
|
||||||
|
@ -226,7 +227,7 @@ public class Create extends InputAbstract {
|
||||||
@Option(name = "--no-web", description = "Remove the web-server definition from bootstrap.xml")
|
@Option(name = "--no-web", description = "Remove the web-server definition from bootstrap.xml")
|
||||||
private boolean noWeb;
|
private boolean noWeb;
|
||||||
|
|
||||||
@Option(name = "--queues", description = "Comma separated list of queues.")
|
@Option(name = "--queues", description = "Comma separated list of queues with the option to specify a routing type. (ex: --queues myqueue,mytopic:multicast)")
|
||||||
private String queues;
|
private String queues;
|
||||||
|
|
||||||
@Option(name = "--addresses", description = "Comma separated list of addresses ")
|
@Option(name = "--addresses", description = "Comma separated list of addresses ")
|
||||||
|
@ -890,10 +891,20 @@ public class Create extends InputAbstract {
|
||||||
printWriter.println();
|
printWriter.println();
|
||||||
|
|
||||||
for (String str : getQueueList()) {
|
for (String str : getQueueList()) {
|
||||||
printWriter.println(" <address name=\"" + str + "\">");
|
String[] seg = str.split(":");
|
||||||
printWriter.println(" <anycast>");
|
String name = seg[0].trim();
|
||||||
printWriter.println(" <queue name=\"" + str + "\" />");
|
// default routing type to anycast if not specified
|
||||||
printWriter.println(" </anycast>");
|
String routingType = (seg.length == 2 ? seg[1].trim() : "anycast");
|
||||||
|
try {
|
||||||
|
RoutingType.valueOf(routingType.toUpperCase());
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
System.err.println("Invalid routing type: " + routingType);
|
||||||
|
}
|
||||||
|
printWriter.println(" <address name=\"" + name + "\">");
|
||||||
|
printWriter.println(" <" + routingType + ">");
|
||||||
|
printWriter.println(" <queue name=\"" + name + "\" />");
|
||||||
|
printWriter.println(" </" + routingType + ">");
|
||||||
printWriter.println(" </address>");
|
printWriter.println(" </address>");
|
||||||
}
|
}
|
||||||
for (String str : getAddressList()) {
|
for (String str : getAddressList()) {
|
||||||
|
|
|
@ -36,6 +36,7 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.apache.activemq.artemis.api.core.Pair;
|
import org.apache.activemq.artemis.api.core.Pair;
|
||||||
|
import org.apache.activemq.artemis.api.core.RoutingType;
|
||||||
import org.apache.activemq.artemis.api.core.SimpleString;
|
import org.apache.activemq.artemis.api.core.SimpleString;
|
||||||
import org.apache.activemq.artemis.api.core.client.ClientSession;
|
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.ClientSessionFactory;
|
||||||
|
@ -557,7 +558,7 @@ public class ArtemisTest extends CliTestBase {
|
||||||
File instanceFolder = temporaryFolder.newFolder(folderName);
|
File instanceFolder = temporaryFolder.newFolder(folderName);
|
||||||
|
|
||||||
setupAuth(instanceFolder);
|
setupAuth(instanceFolder);
|
||||||
String queues = "q1,q2";
|
String queues = "q1,q2:multicast";
|
||||||
String addresses = "a1,a2";
|
String addresses = "a1,a2";
|
||||||
|
|
||||||
|
|
||||||
|
@ -575,8 +576,11 @@ public class ArtemisTest extends CliTestBase {
|
||||||
ClientSessionFactory factory = locator.createSessionFactory();
|
ClientSessionFactory factory = locator.createSessionFactory();
|
||||||
ClientSession coreSession = factory.createSession("admin", "admin", false, true, true, false, 0)) {
|
ClientSession coreSession = factory.createSession("admin", "admin", false, true, true, false, 0)) {
|
||||||
for (String str : queues.split(",")) {
|
for (String str : queues.split(",")) {
|
||||||
ClientSession.QueueQuery queryResult = coreSession.queueQuery(SimpleString.toSimpleString(str));
|
String[] seg = str.split(":");
|
||||||
assertTrue("Couldn't find queue " + str, queryResult.isExists());
|
RoutingType routingType = RoutingType.valueOf((seg.length == 2 ? seg[1] : "anycast").toUpperCase());
|
||||||
|
ClientSession.QueueQuery queryResult = coreSession.queueQuery(SimpleString.toSimpleString(seg[0]));
|
||||||
|
assertTrue("Couldn't find queue " + seg[0], queryResult.isExists());
|
||||||
|
assertEquals(routingType, queryResult.getRoutingType());
|
||||||
}
|
}
|
||||||
for (String str : addresses.split(",")) {
|
for (String str : addresses.split(",")) {
|
||||||
ClientSession.AddressQuery queryResult = coreSession.addressQuery(SimpleString.toSimpleString(str));
|
ClientSession.AddressQuery queryResult = coreSession.addressQuery(SimpleString.toSimpleString(str));
|
||||||
|
|
Loading…
Reference in New Issue