diff --git a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/Create.java b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/Create.java index 580b4110c7..7495ce278c 100644 --- a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/Create.java +++ b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/Create.java @@ -121,6 +121,9 @@ public class Create extends InputAbstract @Option(name = "--slave", description = "Valid for shared store or replication: this is a slave server?") boolean slave; + @Option(name = "--failover-on-shutdown", description = "Valid for shared store: will shutdown trigger a failover? (Default: false)") + boolean failoverOnShutodwn; + @Option(name = "--cluster-user", description = "The cluster user to use for clustering. (Default: input)") String clusterUser = null; @@ -424,6 +427,16 @@ public class Create extends InputAbstract this.slave = slave; } + public boolean isFailoverOnShutodwn() + { + return failoverOnShutodwn; + } + + public void setFailoverOnShutodwn(boolean failoverOnShutodwn) + { + this.failoverOnShutodwn = failoverOnShutodwn; + } + public Boolean getAllowAnonymous() { return allowAnonymous; @@ -494,6 +507,8 @@ public class Create extends InputAbstract filters.put("${master-slave}", isSlave() ? "slave" : "master"); + filters.put("${failover-on-shutdown}", isFailoverOnShutodwn() ? "true" : "false"); + if (replicated) { clustered = true; diff --git a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/process/ProcessBuilder.java b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/process/ProcessBuilder.java index 05d09d5335..eaf4865538 100644 --- a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/process/ProcessBuilder.java +++ b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/process/ProcessBuilder.java @@ -36,7 +36,7 @@ public class ProcessBuilder { for (Process p : processes) { - if (p.isAlive()) +// if (p.isAlive()) { p.destroy(); } @@ -53,7 +53,7 @@ public class ProcessBuilder { for (Process p: processes) { - if (!p.isAlive()) +// if (!p.isAlive()) { processes.remove(p); } @@ -93,14 +93,14 @@ public class ProcessBuilder ProcessLogger outputLogger = new ProcessLogger(true, process.getInputStream(), - logname + "::Out", + logname, false); outputLogger.start(); // Adding a reader to System.err, so the VM won't hang on a System.err.println as identified on this forum thread: ProcessLogger errorLogger = new ProcessLogger(true, process.getErrorStream(), - logname + "::Err", + logname, true); errorLogger.start(); @@ -172,11 +172,11 @@ public class ProcessBuilder { if (sendToErr) { - System.err.println(logName + " err:" + line); + System.err.println(logName + "-err:" + line); } else { - System.out.println(logName + " out:" + line); + System.out.println(logName + "-out:" + line); } } } diff --git a/artemis-cli/src/main/java/org/apache/activemq/artemis/util/ServerUtil.java b/artemis-cli/src/main/java/org/apache/activemq/artemis/util/ServerUtil.java new file mode 100644 index 0000000000..9b384cd584 --- /dev/null +++ b/artemis-cli/src/main/java/org/apache/activemq/artemis/util/ServerUtil.java @@ -0,0 +1,207 @@ +/** + * 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.util; + +import org.apache.activemq.artemis.api.core.TransportConfiguration; +import org.apache.activemq.artemis.api.core.client.ClientSession; +import org.apache.activemq.artemis.api.jms.ActiveMQJMSClient; +import org.apache.activemq.artemis.api.jms.JMSFactoryType; +import org.apache.activemq.artemis.core.remoting.impl.netty.NettyConnectorFactory; +import org.apache.activemq.artemis.jms.client.ActiveMQConnection; +import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory; + +import javax.jms.Connection; +import java.io.BufferedReader; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.util.HashMap; + +public class ServerUtil +{ + public static Process startServer(String artemisInstance, String serverName) throws Exception + { + return startServer(artemisInstance, serverName, 0, 0); + } + + public static Process startServer(String artemisInstance, String serverName, int id, int timeout) throws Exception + { + boolean IS_WINDOWS = System.getProperty("os.name").toLowerCase().trim().startsWith("win"); + + ProcessBuilder builder = null; + if (IS_WINDOWS) + { + builder = new ProcessBuilder("cmd", "/c", "artemis.cmd", "run"); + } + else + { + builder = new ProcessBuilder("./artemis", "run"); + } + + builder.directory(new File(artemisInstance + "/bin")); + + final Process process = builder.start(); + Runtime.getRuntime().addShutdownHook(new Thread() + { + public void run() + { + process.destroy(); + } + }); + + ProcessLogger outputLogger = new ProcessLogger(true, + process.getInputStream(), + serverName, + false); + outputLogger.start(); + + // Adding a reader to System.err, so the VM won't hang on a System.err.println as identified on this forum thread: + // http://www.jboss.org/index.html?module=bb&op=viewtopic&t=151815 + ProcessLogger errorLogger = new ProcessLogger(true, + process.getErrorStream(), + serverName, + true); + errorLogger.start(); + + // wait for start + if (timeout != 0) + { + waitForServerToStart(id, timeout); + } + + return process; + } + + public static void waitForServerToStart(int id, int timeout) throws InterruptedException + { + long realTimeout = System.currentTimeMillis() + timeout; + while (System.currentTimeMillis() < realTimeout) + { + try + { + HashMap params = new HashMap(); + params.put("host", "localhost"); + params.put("port", 61616 + id); + TransportConfiguration transportConfiguration = new TransportConfiguration(NettyConnectorFactory.class.getName(), params); + ActiveMQConnectionFactory cf = ActiveMQJMSClient.createConnectionFactoryWithoutHA(JMSFactoryType.CF, transportConfiguration); + cf.createConnection().close(); + System.out.println("server " + id + " started"); + } + catch (Exception e) + { + System.out.println("awaiting server " + id + " start at " + (61616 + id)); + Thread.sleep(500); + continue; + } + break; + } + } + + public static void killServer(final Process server) throws Exception + { + if (server != null) + { + System.out.println("**********************************"); + System.out.println("Killing server " + server); + System.out.println("**********************************"); + server.destroy(); + server.waitFor(); + Thread.sleep(1000); + } + } + + public static int getServer(Connection connection) + { + ClientSession session = ((ActiveMQConnection) connection).getInitialSession(); + TransportConfiguration transportConfiguration = session.getSessionFactory().getConnectorConfiguration(); + String port = (String) transportConfiguration.getParams().get("port"); + return Integer.valueOf(port) - 61616; + } + + public static Connection getServerConnection(int server, Connection... connections) + { + for (Connection connection : connections) + { + ClientSession session = ((ActiveMQConnection) connection).getInitialSession(); + TransportConfiguration transportConfiguration = session.getSessionFactory().getConnectorConfiguration(); + String port = (String) transportConfiguration.getParams().get("port"); + if (Integer.valueOf(port) == server + 61616) + { + return connection; + } + } + return null; + } + + + /** + * Redirect the input stream to a logger (as debug logs) + */ + static class ProcessLogger extends Thread + { + private final InputStream is; + + private final String logName; + + private final boolean print; + + private final boolean sendToErr; + + ProcessLogger(final boolean print, + final InputStream is, + final String logName, + final boolean sendToErr) throws ClassNotFoundException + { + this.is = is; + this.print = print; + this.logName = logName; + this.sendToErr = sendToErr; + setDaemon(false); + } + + @Override + public void run() + { + try + { + InputStreamReader isr = new InputStreamReader(is); + BufferedReader br = new BufferedReader(isr); + String line; + while ((line = br.readLine()) != null) + { + if (print) + { + if (sendToErr) + { + System.err.println(logName + "-err:" + line); + } + else + { + System.out.println(logName + "-out:" + line); + } + } + } + } + catch (IOException e) + { + // ok, stream closed + } + } + } +} diff --git a/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/etc/shared-store-settings.txt b/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/etc/shared-store-settings.txt index 750dbc1738..120df7f559 100644 --- a/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/etc/shared-store-settings.txt +++ b/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/etc/shared-store-settings.txt @@ -1,6 +1,8 @@ - <${master-slave}/> + <${master-slave}> + ${failover-on-shutdown} + diff --git a/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/server/impl/JMSServerManagerImpl.java b/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/server/impl/JMSServerManagerImpl.java index 6a4856b49f..6c257c845a 100644 --- a/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/server/impl/JMSServerManagerImpl.java +++ b/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/server/impl/JMSServerManagerImpl.java @@ -1850,7 +1850,8 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback else { ActiveMQJMSServerLogger.LOGGER.serverCachingCommand(runnable); - cachedCommands.add(runnable); + if (!cachedCommands.contains(runnable)) + cachedCommands.add(runnable); return false; } } diff --git a/artemis-maven-plugin/src/main/java/org/apache/activemq/artemis/maven/ActiveMQCreatePlugin.java b/artemis-maven-plugin/src/main/java/org/apache/activemq/artemis/maven/ActiveMQCreatePlugin.java index 5fca4a3037..78154b68e6 100644 --- a/artemis-maven-plugin/src/main/java/org/apache/activemq/artemis/maven/ActiveMQCreatePlugin.java +++ b/artemis-maven-plugin/src/main/java/org/apache/activemq/artemis/maven/ActiveMQCreatePlugin.java @@ -104,9 +104,15 @@ public class ActiveMQCreatePlugin extends AbstractMojo @Parameter(defaultValue = "false") private boolean slave; - @Parameter(defaultValue = "../data") + @Parameter(defaultValue = "./data") String dataFolder; + @Parameter(defaultValue = "false") + private boolean failoverOnShutdown; + + @Parameter(defaultValue = "ON_DEMAND") + private String messageLoadBalancing; + @Component private RepositorySystem repositorySystem; @@ -162,6 +168,10 @@ public class ActiveMQCreatePlugin extends AbstractMojo public void execute() throws MojoExecutionException, MojoFailureException { + if (System.getProperty("bypassAddress") != null) + { + System.out.println("BYPASSADDRESS"); + } getLog().info("Local " + localRepository); MavenProject project = (MavenProject) getPluginContext().get("project"); @@ -224,12 +234,7 @@ public class ActiveMQCreatePlugin extends AbstractMojo add(listCommands, "--replicated"); } - if (replicated) - { - add(listCommands, "--shared-store"); - } - - if (replicated) + if (sharedStore) { add(listCommands, "--shared-store"); } @@ -237,6 +242,12 @@ public class ActiveMQCreatePlugin extends AbstractMojo if (clustered) { add(listCommands, "--clustered"); + add(listCommands, "--message-load-balancing", messageLoadBalancing); + } + + if (failoverOnShutdown) + { + add(listCommands, "--failover-on-shutdown"); } add(listCommands, "--verbose"); diff --git a/artemis-maven-plugin/src/main/java/org/apache/activemq/artemis/maven/ArtemisCLIPlugin.java b/artemis-maven-plugin/src/main/java/org/apache/activemq/artemis/maven/ArtemisCLIPlugin.java index 79aad50fc3..1fd46148db 100644 --- a/artemis-maven-plugin/src/main/java/org/apache/activemq/artemis/maven/ArtemisCLIPlugin.java +++ b/artemis-maven-plugin/src/main/java/org/apache/activemq/artemis/maven/ArtemisCLIPlugin.java @@ -16,12 +16,6 @@ */ package org.apache.activemq.artemis.maven; -import java.io.File; -import java.nio.file.Files; -import java.nio.file.LinkOption; -import java.nio.file.Path; -import java.util.Map; - import org.apache.activemq.artemis.cli.Artemis; import org.apache.activemq.artemis.cli.commands.Run; import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory; @@ -34,19 +28,19 @@ import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.project.MavenProject; +import java.io.File; +import java.nio.file.Files; +import java.nio.file.LinkOption; +import java.nio.file.Path; + @Mojo(name = "cli", defaultPhase = LifecyclePhase.VERIFY) public class ArtemisCLIPlugin extends AbstractMojo - { - - @Parameter - String name; - - /** - * The plugin descriptor - */ private PluginDescriptor descriptor; + @Parameter(defaultValue = "server") + String name; + @Parameter(defaultValue = "${activemq.basedir}", required = true) private File home; @@ -62,8 +56,17 @@ public class ArtemisCLIPlugin extends AbstractMojo @Parameter private boolean spawn = false; + @Parameter(defaultValue = "10000") + private long spawnTimeout; + @Parameter - private boolean testServer; + private String testURI = null; + + @Parameter + private String testUser = null; + + @Parameter + private String testPassword = null; /** @@ -120,13 +123,11 @@ public class ArtemisCLIPlugin extends AbstractMojo } } - Map properties = getPluginContext(); - try { if (spawn) { - final Process process = org.apache.activemq.artemis.cli.process.ProcessBuilder.build("server", location, true, args); + final Process process = org.apache.activemq.artemis.cli.process.ProcessBuilder.build(name, location, true, args); Runtime.getRuntime().addShutdownHook(new Thread() { public void run() @@ -135,14 +136,21 @@ public class ArtemisCLIPlugin extends AbstractMojo } }); - if (testServer) + if (testURI != null) { - for (int tryNr = 0; tryNr < 20; tryNr++) + long timeout = System.currentTimeMillis() + spawnTimeout; + while (System.currentTimeMillis() <= timeout) { - try + try (ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory(testURI)) { - ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory(); - cf.createConnection().close(); + if (testUser != null && testPassword != null) + { + cf.createConnection(testUser, testPassword).close(); + } + else + { + cf.createConnection().close(); + } getLog().info("Server started"); } catch (Exception e) diff --git a/examples/core/embedded/pom.xml b/examples/core/embedded/pom.xml index 1390c6ae18..8453105cf4 100644 --- a/examples/core/embedded/pom.xml +++ b/examples/core/embedded/pom.xml @@ -86,6 +86,4 @@ under the License. - - diff --git a/examples/core/perf/pom.xml b/examples/core/perf/pom.xml index 5600953e5c..0681d2ac4c 100644 --- a/examples/core/perf/pom.xml +++ b/examples/core/perf/pom.xml @@ -51,11 +51,6 @@ under the License. netty-all ${netty.version} - - org.apache.activemq.examples.jms - common - ${project.version} - org.apache.geronimo.specs geronimo-jms_2.0_spec @@ -64,7 +59,7 @@ under the License. - default + server @@ -72,26 +67,16 @@ under the License. artemis-maven-plugin - start + create0 - start + create - true - ${basedir}/target/classes/server0 - - - build.directory - ${basedir}/target/ - - + ${basedir}/target/server0 + ${basedir}/target/classes/activemq/server0 - - false - ${basedir}/target/classes/server0 - org.apache.activemq.examples.core @@ -175,6 +160,4 @@ under the License. - - diff --git a/examples/core/perf/src/main/resources/server0/broker.xml b/examples/core/perf/src/main/resources/activemq/server0/broker.xml similarity index 86% rename from examples/core/perf/src/main/resources/server0/broker.xml rename to examples/core/perf/src/main/resources/activemq/server0/broker.xml index 6896640215..8876d42c49 100644 --- a/examples/core/perf/src/main/resources/server0/broker.xml +++ b/examples/core/perf/src/main/resources/activemq/server0/broker.xml @@ -22,13 +22,15 @@ under the License. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:activemq /schema/artemis-server.xsd"> - target/server0/data/messaging/bindings - target/server0/data/messaging/journal + ${data.dir:./data}/bindings - target/server0/data/messaging/largemessages + ${data.dir:./data}/journal + + ${data.dir:./data}/largemessages + + ${data.dir:./data}/paging - target/server0/data/messaging/paging tcp://localhost:61616?tcpNoDelay=false;tcpSendBufferSize=1048576;tcpReceiveBufferSize=1048576 diff --git a/examples/core/perf/src/main/resources/server0/hornetq-configuration-messaging-lab.xml b/examples/core/perf/src/main/resources/activemq/server0/hornetq-configuration-messaging-lab.xml similarity index 100% rename from examples/core/perf/src/main/resources/server0/hornetq-configuration-messaging-lab.xml rename to examples/core/perf/src/main/resources/activemq/server0/hornetq-configuration-messaging-lab.xml diff --git a/examples/core/vertx-connector/pom.xml b/examples/core/vertx-connector/pom.xml index 4a2e1fa289..8d8ba8eab2 100644 --- a/examples/core/vertx-connector/pom.xml +++ b/examples/core/vertx-connector/pom.xml @@ -61,24 +61,29 @@ under the License. org.apache.geronimo.specs geronimo-jms_2.0_spec - - io.vertx - vertx-core - ${vertx.version} - provided - - - io.vertx - vertx-platform - ${vertx.version} - provided - - - io.vertx - vertx-hazelcast - ${vertx.version} - provided - + + io.vertx + vertx-core + ${vertx.version} + provided + + + io.vertx + vertx-platform + ${vertx.version} + provided + + + io.vertx + vertx-hazelcast + ${vertx.version} + provided + + + org.apache.activemq + artemis-vertx-integration + ${project.version} + @@ -89,37 +94,41 @@ under the License. org.apache.activemq artemis-maven-plugin - - - start - - start - - - - - build.directory - ${basedir}/target/ - - - - - - runClient - - runClient - - - org.apache.activemq.artemis.core.example.VertxConnectorExample - - - - stop - - stop - - - + + + create0 + + create + + + ${basedir}/target/server0 + ${basedir}/target/classes/activemq/server0 + + + + start0 + + cli + + + true + ${basedir}/target/server0 + tcp://localhost:61616 + + run + + + + + runClient + + runClient + + + org.apache.activemq.artemis.core.example.VertxConnectorExample + + + org.apache.activemq.examples.core @@ -157,30 +166,24 @@ under the License. ${netty.version} - io.vertx - vertx-core - ${vertx.version} + io.vertx + vertx-core + ${vertx.version} - io.vertx - vertx-platform - ${vertx.version} + io.vertx + vertx-platform + ${vertx.version} - io.vertx - vertx-hazelcast - ${vertx.version} + io.vertx + vertx-hazelcast + ${vertx.version} - - false - ${basedir}/target/classes/server0 - - - diff --git a/examples/core/vertx-connector/src/main/resources/server0/broker.xml b/examples/core/vertx-connector/src/main/resources/activemq/server0/broker.xml similarity index 100% rename from examples/core/vertx-connector/src/main/resources/server0/broker.xml rename to examples/core/vertx-connector/src/main/resources/activemq/server0/broker.xml diff --git a/examples/core/vertx-connector/src/main/resources/server0/artemis-roles.properties b/examples/core/vertx-connector/src/main/resources/server0/artemis-roles.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/core/vertx-connector/src/main/resources/server0/artemis-roles.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/core/vertx-connector/src/main/resources/server0/artemis-users.properties b/examples/core/vertx-connector/src/main/resources/server0/artemis-users.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/core/vertx-connector/src/main/resources/server0/artemis-users.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/aerogear/pom.xml b/examples/jms/aerogear/pom.xml index f99707ba32..a42a6e889c 100644 --- a/examples/jms/aerogear/pom.xml +++ b/examples/jms/aerogear/pom.xml @@ -28,10 +28,9 @@ under the License. - - - - 2.2.1 + + + ${project.basedir}/../../.. @@ -45,43 +44,6 @@ under the License. artemis-cli ${project.version} - - - - org.apache.maven - maven-artifact - ${mavenVersion} - - - org.apache.maven - maven-plugin-api - ${mavenVersion} - - - org.apache.maven - maven-project - ${mavenVersion} - - - org.apache.maven - maven-model - ${mavenVersion} - - - org.apache.maven - maven-core - ${mavenVersion} - - - org.apache.maven - maven-artifact-manager - ${mavenVersion} - - - org.apache.maven - maven-repository-metadata - ${mavenVersion} - @@ -122,8 +84,7 @@ under the License. true - true - + tcp://localhost:61616 run @@ -136,9 +97,6 @@ under the License. org.apache.activemq.artemis.jms.example.AerogearExample - - ${basedir}/target/server0 - diff --git a/examples/jms/aerogear/src/main/resources/activemq/server0/broker.xml b/examples/jms/aerogear/src/main/resources/activemq/server0/broker.xml index 90c93e6a35..5c389c8ac5 100644 --- a/examples/jms/aerogear/src/main/resources/activemq/server0/broker.xml +++ b/examples/jms/aerogear/src/main/resources/activemq/server0/broker.xml @@ -29,13 +29,13 @@ under the License. - ${data.dir:../data}/bindings + ${data.dir:./data}/bindings - ${data.dir:../data}/journal + ${data.dir:./data}/journal - ${data.dir:../data}/largemessages + ${data.dir:./data}/largemessages - ${data.dir:../data}/paging + ${data.dir:./data}/paging @@ -73,6 +73,5 @@ under the License. - diff --git a/examples/jms/application-layer-failover/pom.xml b/examples/jms/application-layer-failover/pom.xml index 9f4abb583d..65d217d75a 100644 --- a/examples/jms/application-layer-failover/pom.xml +++ b/examples/jms/application-layer-failover/pom.xml @@ -37,8 +37,8 @@ under the License. - org.apache.activemq.examples.jms - common + org.apache.activemq + artemis-cli ${project.version} @@ -57,7 +57,7 @@ under the License. artemis-maven-plugin - create + create0 create @@ -66,7 +66,7 @@ under the License. - create2 + create1 create diff --git a/examples/jms/application-layer-failover/src/main/java/org/apache/activemq/artemis/jms/example/ApplicationLayerFailoverExample.java b/examples/jms/application-layer-failover/src/main/java/org/apache/activemq/artemis/jms/example/ApplicationLayerFailoverExample.java index ca916ee908..fcd3ccaaaf 100644 --- a/examples/jms/application-layer-failover/src/main/java/org/apache/activemq/artemis/jms/example/ApplicationLayerFailoverExample.java +++ b/examples/jms/application-layer-failover/src/main/java/org/apache/activemq/artemis/jms/example/ApplicationLayerFailoverExample.java @@ -16,6 +16,8 @@ */ package org.apache.activemq.artemis.jms.example; +import org.apache.activemq.artemis.util.ServerUtil; + import java.lang.Object; import java.lang.String; import java.util.Hashtable; @@ -32,37 +34,37 @@ import javax.jms.Queue; import javax.jms.Session; import javax.jms.TextMessage; import javax.naming.InitialContext; - -import org.apache.activemq.artemis.common.example.ActiveMQExample; +import javax.naming.NamingException; /** * A simple example that demonstrates application-layer failover of the JMS connection from one node to another * when the live server crashes */ -public class ApplicationLayerFailoverExample extends ActiveMQExample +public class ApplicationLayerFailoverExample { - public static void main(final String[] args) - { - new ApplicationLayerFailoverExample().run(args); - } + private static InitialContext initialContext; - private volatile InitialContext initialContext; + private static Connection connection; - private volatile Connection connection; + private static Session session; - private volatile Session session; + private static MessageConsumer consumer; - private volatile MessageConsumer consumer; + private static MessageProducer producer; - private volatile MessageProducer producer; + private static final CountDownLatch failoverLatch = new CountDownLatch(1); - private final CountDownLatch failoverLatch = new CountDownLatch(1); + private static Process server0; - @Override - public boolean runExample() throws Exception + private static Process server1; + + public static void main(final String[] args) throws Exception { try { + server0 = ServerUtil.startServer(args[0], ApplicationLayerFailoverExample.class.getSimpleName() + "0", 0, 5000); + server1 = ServerUtil.startServer(args[1], ApplicationLayerFailoverExample.class.getSimpleName() + "1", 1, 5000); + // Step 1. We create our JMS Connection, Session, MessageProducer and MessageConsumer on server 1. createJMSObjects(0); @@ -99,21 +101,12 @@ public class ApplicationLayerFailoverExample extends ActiveMQExample System.out.println("Killing the server"); - killServer(0); - - // this utility method will wait for the server1 to be activated - waitForServerStart(1, 20000); - + ServerUtil.killServer(server0); // Step 6. Wait for the client side to register the failure and reconnect boolean ok = failoverLatch.await(5000, TimeUnit.MILLISECONDS); - if (!ok) - { - return false; - } - System.out.println("Reconnection has occurred. Now sending more messages."); // Step 8. We now send some more messages @@ -135,23 +128,21 @@ public class ApplicationLayerFailoverExample extends ActiveMQExample System.out.println("Got message: " + message0.getText()); } - - return true; } catch(Throwable t) { t.printStackTrace(); - return false; } finally { // Step 14. Be sure to close our resources! - closeResources(); + ServerUtil.killServer(server0); + ServerUtil.killServer(server1); } } - private void createJMSObjects(final int server) throws Exception + private static void createJMSObjects(final int server) throws Exception { // Step 1. Get an initial context for looking up JNDI from the server Hashtable properties = new Hashtable(); @@ -182,20 +173,34 @@ public class ApplicationLayerFailoverExample extends ActiveMQExample producer = session.createProducer(queue); } - private void closeResources() throws Exception + private static void closeResources() { if (initialContext != null) { - initialContext.close(); + try + { + initialContext.close(); + } + catch (NamingException e) + { + e.printStackTrace(); + } } if (connection != null) { - connection.close(); + try + { + connection.close(); + } + catch (JMSException e) + { + e.printStackTrace(); + } } } - private class ExampleListener implements ExceptionListener + private static class ExampleListener implements ExceptionListener { public void onException(final JMSException exception) { diff --git a/examples/jms/bridge/pom.xml b/examples/jms/bridge/pom.xml index f1dd547e1d..73cbdc56d9 100644 --- a/examples/jms/bridge/pom.xml +++ b/examples/jms/bridge/pom.xml @@ -27,20 +27,15 @@ under the License. 1.0.1-SNAPSHOT - artemis-jms-bridge-example + artemis-jms-core-bridge-example jar - ActiveMQ Artemis JMS Bridge Example + ActiveMQ Artemis Core Bridge Example ${project.basedir}/../../.. - - org.apache.activemq.examples.jms - common - ${project.version} - org.apache.activemq artemis-server @@ -62,7 +57,7 @@ under the License. artemis-maven-plugin - create + create0 create @@ -72,7 +67,7 @@ under the License. - create2 + create1 create @@ -82,16 +77,66 @@ under the License. 1 + + start0 + + cli + + + true + ${basedir}/target/server0 + tcp://localhost:61616 + + run + + server0 + + + + start1 + + cli + + + true + ${basedir}/target/server1 + tcp://localhost:61617 + + run + + server1 + + runClient - client + runClient org.apache.activemq.artemis.jms.example.BridgeExample + + + + stop0 + + cli + + + ${basedir}/target/server0 - ${basedir}/target/server0 - ${basedir}/target/server1 + stop + + + + + stop1 + + cli + + + ${basedir}/target/server1 + + stop @@ -99,29 +144,9 @@ under the License. org.apache.activemq.examples.jms - artemis-jms-bridge-example + artemis-jms-core-bridge-example ${project.version} - - org.apache.activemq - artemis-core-client - ${project.version} - - - org.apache.activemq - artemis-jms-client - ${project.version} - - - io.netty - netty-all - ${netty.version} - - - org.apache.geronimo.specs - geronimo-jms_2.0_spec - ${geronimo.jms.2.spec.version} - diff --git a/examples/jms/bridge/src/main/java/org/apache/activemq/artemis/jms/example/BridgeExample.java b/examples/jms/bridge/src/main/java/org/apache/activemq/artemis/jms/example/BridgeExample.java index 4346c32498..a4a165c0ec 100644 --- a/examples/jms/bridge/src/main/java/org/apache/activemq/artemis/jms/example/BridgeExample.java +++ b/examples/jms/bridge/src/main/java/org/apache/activemq/artemis/jms/example/BridgeExample.java @@ -26,21 +26,13 @@ import javax.jms.Session; import javax.naming.InitialContext; import java.util.Hashtable; -import org.apache.activemq.artemis.common.example.ActiveMQExample; - /** * This example demonstrates a core bridge set-up between two nodes, consuming messages from a queue * on one node and forwarding them to an address on the second node. */ -public class BridgeExample extends ActiveMQExample +public class BridgeExample { - public static void main(final String[] args) - { - new BridgeExample().run(args); - } - - @Override - public boolean runExample() throws Exception + public static void main(final String[] args) throws Exception { Connection connection0 = null; @@ -120,9 +112,9 @@ public class BridgeExample extends ActiveMQExample producer.send(message); System.out.println("Sent " + message.getStringProperty("name") + - " message with " + - message.getStringProperty("hat") + - " hat to sausage-factory on node 0"); + " message with " + + message.getStringProperty("hat") + + " hat to sausage-factory on node 0"); // Step 14 - we successfully receive the aardvark message from the mincing-machine one node 1. The aardvark's // hat is now blue since it has been transformed! @@ -130,9 +122,9 @@ public class BridgeExample extends ActiveMQExample Message receivedMessage = consumer.receive(5000); System.out.println("Received " + receivedMessage.getStringProperty("name") + - " message with " + - receivedMessage.getStringProperty("hat") + - " hat from mincing-machine on node 1"); + " message with " + + receivedMessage.getStringProperty("hat") + + " hat from mincing-machine on node 1"); // Step 13. We create and send another message, this time representing a sasquatch with a mauve hat to the // sausage-factory on node 0. This won't be bridged to the mincing-machine since we only want aardvarks, not @@ -147,9 +139,9 @@ public class BridgeExample extends ActiveMQExample producer.send(message); System.out.println("Sent " + message.getStringProperty("name") + - " message with " + - message.getStringProperty("hat") + - " hat to sausage-factory on node 0"); + " message with " + + message.getStringProperty("hat") + + " hat to sausage-factory on node 0"); // Step 14. We don't receive the message since it has not been bridged. @@ -161,10 +153,8 @@ public class BridgeExample extends ActiveMQExample } else { - return false; + throw new IllegalStateException(); } - - return true; } finally { @@ -191,5 +181,4 @@ public class BridgeExample extends ActiveMQExample } } } - } diff --git a/examples/jms/browser/pom.xml b/examples/jms/browser/pom.xml index 530f66b83c..adaf22266d 100644 --- a/examples/jms/browser/pom.xml +++ b/examples/jms/browser/pom.xml @@ -36,11 +36,6 @@ under the License. - - org.apache.activemq.examples.jms - common - ${project.version} - org.apache.geronimo.specs geronimo-jms_2.0_spec @@ -63,6 +58,19 @@ under the License. create + + start + + cli + + + true + tcp://localhost:61616 + + run + + + runClient @@ -70,8 +78,16 @@ under the License. org.apache.activemq.artemis.jms.example.QueueBrowserExample + + + + stop + + cli + + - ${basedir}/target/server0 + stop diff --git a/examples/jms/browser/src/main/java/org/apache/activemq/artemis/jms/example/QueueBrowserExample.java b/examples/jms/browser/src/main/java/org/apache/activemq/artemis/jms/example/QueueBrowserExample.java index 8e8e422412..6c93cc685a 100644 --- a/examples/jms/browser/src/main/java/org/apache/activemq/artemis/jms/example/QueueBrowserExample.java +++ b/examples/jms/browser/src/main/java/org/apache/activemq/artemis/jms/example/QueueBrowserExample.java @@ -27,20 +27,12 @@ import javax.jms.TextMessage; import javax.naming.InitialContext; import java.util.Enumeration; -import org.apache.activemq.artemis.common.example.ActiveMQExample; - /** * A simple example which shows how to use a QueueBrowser to look at messages of a queue without removing them from the queue */ -public class QueueBrowserExample extends ActiveMQExample +public class QueueBrowserExample { - public static void main(final String[] args) - { - new QueueBrowserExample().run(args); - } - - @Override - public boolean runExample() throws Exception + public static void main(final String[] args) throws Exception { Connection connection = null; InitialContext initialContext = null; @@ -98,9 +90,6 @@ public class QueueBrowserExample extends ActiveMQExample System.out.println("Received message: " + messageReceived.getText()); messageReceived = (TextMessage)messageConsumer.receive(5000); System.out.println("Received message: " + messageReceived.getText()); - - return true; - } finally { diff --git a/examples/jms/client-kickoff/pom.xml b/examples/jms/client-kickoff/pom.xml index 22d511c972..1c86b5a520 100644 --- a/examples/jms/client-kickoff/pom.xml +++ b/examples/jms/client-kickoff/pom.xml @@ -36,11 +36,6 @@ under the License. - - org.apache.activemq.examples.jms - common - ${project.version} - org.apache.activemq artemis-core-client @@ -71,6 +66,19 @@ under the License. -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=3000 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false + + start + + cli + + + true + tcp://localhost:61616 + + run + + + runClient @@ -78,8 +86,16 @@ under the License. org.apache.activemq.artemis.jms.example.ClientKickoffExample + + + + stop + + cli + + - ${basedir}/target/server0 + stop diff --git a/examples/jms/client-kickoff/src/main/java/org/apache/activemq/artemis/jms/example/ClientKickoffExample.java b/examples/jms/client-kickoff/src/main/java/org/apache/activemq/artemis/jms/example/ClientKickoffExample.java index eb5db60e43..54217390a0 100644 --- a/examples/jms/client-kickoff/src/main/java/org/apache/activemq/artemis/jms/example/ClientKickoffExample.java +++ b/examples/jms/client-kickoff/src/main/java/org/apache/activemq/artemis/jms/example/ClientKickoffExample.java @@ -27,27 +27,21 @@ import javax.management.remote.JMXConnector; import javax.management.remote.JMXConnectorFactory; import javax.management.remote.JMXServiceURL; import javax.naming.InitialContext; +import java.lang.Exception; import java.util.HashMap; import java.util.concurrent.atomic.AtomicReference; import org.apache.activemq.artemis.api.core.management.ActiveMQServerControl; import org.apache.activemq.artemis.api.core.management.ObjectNameBuilder; -import org.apache.activemq.artemis.common.example.ActiveMQExample; /** * An example that shows how to kick off a client connected to ActiveMQ Artemis by using JMX. */ -public class ClientKickoffExample extends ActiveMQExample +public class ClientKickoffExample { private static final String JMX_URL = "service:jmx:rmi:///jndi/rmi://localhost:3000/jmxrmi"; - public static void main(final String[] args) - { - new ClientKickoffExample().run(args); - } - - @Override - public boolean runExample() throws Exception + public static void main(final String[] args) throws Exception { QueueConnection connection = null; InitialContext initialContext = null; @@ -67,7 +61,7 @@ public class ClientKickoffExample extends ActiveMQExample connection.setExceptionListener(new ExceptionListener() { @Override - public void onException(final JMSException e) + public void onException(final JMSException e) { exception.set(e); } @@ -81,9 +75,9 @@ public class ClientKickoffExample extends ActiveMQExample JMXConnector connector = JMXConnectorFactory.connect(new JMXServiceURL(JMX_URL), new HashMap()); MBeanServerConnection mbsc = connector.getMBeanServerConnection(); ActiveMQServerControl serverControl = MBeanServerInvocationHandler.newProxyInstance(mbsc, - on, - ActiveMQServerControl.class, - false); + on, + ActiveMQServerControl.class, + false); // Step 7. List the remote address connected to the server System.out.println("List of remote addresses connected to the server:"); @@ -107,8 +101,6 @@ public class ClientKickoffExample extends ActiveMQExample System.err.println("----------------------------------"); exception.get().printStackTrace(); System.err.println("----------------------------------"); - - return true; } finally { @@ -123,5 +115,4 @@ public class ClientKickoffExample extends ActiveMQExample } } } - } diff --git a/examples/jms/client-kickoff/src/main/resources/activemq/server0/broker.xml b/examples/jms/client-kickoff/src/main/resources/activemq/server0/broker.xml index af12f6a75a..3b5a4655fa 100644 --- a/examples/jms/client-kickoff/src/main/resources/activemq/server0/broker.xml +++ b/examples/jms/client-kickoff/src/main/resources/activemq/server0/broker.xml @@ -27,13 +27,13 @@ under the License. - ${data.dir}/server0/data/messaging/bindings + ${data.dir:../data}/bindings - ${data.dir}/server0/data/messaging/journal + ${data.dir:../data}/journal - ${data.dir}/server0/data/messaging/largemessages + ${data.dir:../data}/largemessages - ${data.dir}/server0/data/messaging/paging + ${data.dir:../data}/paging true diff --git a/examples/jms/client-side-failoverlistener/pom.xml b/examples/jms/client-side-failoverlistener/pom.xml index 87c41f334d..cfdcdd6181 100644 --- a/examples/jms/client-side-failoverlistener/pom.xml +++ b/examples/jms/client-side-failoverlistener/pom.xml @@ -37,8 +37,13 @@ under the License. - org.apache.activemq.examples.jms - common + org.apache.activemq + artemis-cli + ${project.version} + + + org.apache.activemq + artemis-jms-client ${project.version} @@ -57,31 +62,31 @@ under the License. artemis-maven-plugin - create + create0 create ${basedir}/target/server0 - ../../shared/ + ../shared true false + true - create2 + create1 create ${basedir}/target/server1 - ../../shared/ + ../shared true true 1 - runClient diff --git a/examples/jms/client-side-failoverlistener/src/main/java/org/apache/activemq/artemis/jms/example/ClientSideFailoverListerExample.java b/examples/jms/client-side-failoverlistener/src/main/java/org/apache/activemq/artemis/jms/example/ClientSideFailoverListerExample.java index c7530003c0..006613930d 100644 --- a/examples/jms/client-side-failoverlistener/src/main/java/org/apache/activemq/artemis/jms/example/ClientSideFailoverListerExample.java +++ b/examples/jms/client-side-failoverlistener/src/main/java/org/apache/activemq/artemis/jms/example/ClientSideFailoverListerExample.java @@ -16,6 +16,11 @@ */ package org.apache.activemq.artemis.jms.example; +import org.apache.activemq.artemis.api.core.client.FailoverEventListener; +import org.apache.activemq.artemis.api.core.client.FailoverEventType; +import org.apache.activemq.artemis.jms.client.ActiveMQConnection; +import org.apache.activemq.artemis.util.ServerUtil; + import javax.jms.Connection; import javax.jms.ConnectionFactory; import javax.jms.MessageConsumer; @@ -25,38 +30,19 @@ import javax.jms.Session; import javax.jms.TextMessage; import javax.naming.InitialContext; -import org.apache.activemq.artemis.api.core.client.FailoverEventListener; -import org.apache.activemq.artemis.api.core.client.FailoverEventType; -import org.apache.activemq.artemis.common.example.ActiveMQExample; -import org.apache.activemq.artemis.jms.client.ActiveMQConnection; - /** * This example demonstrates how you can listen on failover event on the client side - * + *

* In this example there are two nodes running in a cluster, both server will be running for start, * but after a while the first server will crash. This will trigger a fail-over event */ -public class ClientSideFailoverListerExample extends ActiveMQExample +public class ClientSideFailoverListerExample { + private static Process server0; + + private static Process server1; + public static void main(final String[] args) throws Exception - { - new ClientSideFailoverListerExample().run(args); - } - - @Override - protected void startServers(String[] serversArgs) throws Exception - { - startServer(0, 5000); - - // server 1 is a backup, it's not activated - startServer(1, 0); - - Thread.sleep(1000); - } - - - @Override - public boolean runExample() throws Exception { InitialContext initialContext = null; @@ -64,20 +50,23 @@ public class ClientSideFailoverListerExample extends ActiveMQExample try { + server0 = ServerUtil.startServer(args[0], ClientSideFailoverListerExample.class.getSimpleName() + "0", 0, 5000); + server1 = ServerUtil.startServer(args[1], ClientSideFailoverListerExample.class.getSimpleName() + "1", 1, 0); + // Step 1. Get an initial context for looking up JNDI from server 0 initialContext = new InitialContext(); // Step 2. Look-up the JMS Queue object from JNDI - Queue queue = (Queue)initialContext.lookup("queue/exampleQueue"); + Queue queue = (Queue) initialContext.lookup("queue/exampleQueue"); // Step 3. Look-up a JMS Connection Factory object from JNDI on server 0 - ConnectionFactory connectionFactory = (ConnectionFactory)initialContext.lookup("ConnectionFactory"); + ConnectionFactory connectionFactory = (ConnectionFactory) initialContext.lookup("ConnectionFactory"); // Step 4. We create 1 JMS connections from the same connection factory. // Wait a little while to make sure broadcasts from all nodes have reached the client Thread.sleep(5000); connectionA = connectionFactory.createConnection(); - ((ActiveMQConnection)connectionA).setFailoverListener(new FailoverListenerImpl()); + ((ActiveMQConnection) connectionA).setFailoverListener(new FailoverListenerImpl()); // Step 5. We create JMS Sessions Session sessionA = connectionA.createSession(false, Session.AUTO_ACKNOWLEDGE); @@ -102,8 +91,6 @@ public class ClientSideFailoverListerExample extends ActiveMQExample // Step 9. We consume messages from the session A, one at a time. // We reached message no 5 the first server will crash consume(sessionA, queue, numMessages, "A"); - - return true; } finally { @@ -118,20 +105,23 @@ public class ClientSideFailoverListerExample extends ActiveMQExample { initialContext.close(); } + + ServerUtil.killServer(server0); + ServerUtil.killServer(server1); } } - private void consume(Session session, Queue queue, int numMessages, String node) throws Exception + private static void consume(Session session, Queue queue, int numMessages, String node) throws Exception { MessageConsumer consumer = session.createConsumer(queue); for (int i = 0; i < numMessages; i++) { - TextMessage message = (TextMessage)consumer.receive(2000); + TextMessage message = (TextMessage) consumer.receive(2000); System.out.println("Got message: " + message.getText() + " from node " + node); if (i == 5) { - killServer(0); + ServerUtil.killServer(server0); } } diff --git a/examples/jms/client-side-load-balancing/pom.xml b/examples/jms/client-side-load-balancing/pom.xml index fc4ec4c83d..77c8186aad 100644 --- a/examples/jms/client-side-load-balancing/pom.xml +++ b/examples/jms/client-side-load-balancing/pom.xml @@ -37,8 +37,8 @@ under the License. - org.apache.activemq.examples.jms - common + org.apache.activemq + artemis-jms-client ${project.version} @@ -57,14 +57,24 @@ under the License. artemis-maven-plugin - create + create0 create ${basedir}/target/server0 true - ${basedir}/target/classes/activemq/server0 + + + + create1 + + create + + + ${basedir}/target/server1 + true + 1 @@ -72,26 +82,57 @@ under the License. create - - ${basedir}/target/server1 - true - ${basedir}/target/classes/activemq/server1 - 1 - - - - create3 - - create - ${basedir}/target/server2 true - ${basedir}/target/classes/activemq/server2 2 - + + start0 + + cli + + + true + ${basedir}/target/server0 + tcp://localhost:61616 + + run + + server0 + + + + start1 + + cli + + + true + ${basedir}/target/server1 + tcp://localhost:61617 + + run + + server1 + + + + start2 + + cli + + + true + ${basedir}/target/server2 + tcp://localhost:61618 + + run + + server2 + + runClient @@ -99,10 +140,41 @@ under the License. org.apache.activemq.artemis.jms.example.ClientSideLoadBalancingExample + + + + stop0 + + cli + + + ${basedir}/target/server0 - ${basedir}/target/server0 - ${basedir}/target/server1 - ${basedir}/target/server2 + stop + + + + + stop1 + + cli + + + ${basedir}/target/server1 + + stop + + + + + stop2 + + cli + + + ${basedir}/target/server2 + + stop diff --git a/examples/jms/client-side-load-balancing/src/main/java/org/apache/activemq/artemis/jms/example/ClientSideLoadBalancingExample.java b/examples/jms/client-side-load-balancing/src/main/java/org/apache/activemq/artemis/jms/example/ClientSideLoadBalancingExample.java index 287b2a7f69..688ba5aa57 100644 --- a/examples/jms/client-side-load-balancing/src/main/java/org/apache/activemq/artemis/jms/example/ClientSideLoadBalancingExample.java +++ b/examples/jms/client-side-load-balancing/src/main/java/org/apache/activemq/artemis/jms/example/ClientSideLoadBalancingExample.java @@ -26,8 +26,6 @@ import javax.jms.Session; import javax.jms.TextMessage; import javax.naming.InitialContext; -import org.apache.activemq.artemis.common.example.ActiveMQExample; - /** * This example demonstrates how sessions created from a single connection can be load * balanced across the different nodes of the cluster. @@ -35,15 +33,9 @@ import org.apache.activemq.artemis.common.example.ActiveMQExample; * In this example there are three nodes and we use a round-robin client side load-balancing * policy. */ -public class ClientSideLoadBalancingExample extends ActiveMQExample +public class ClientSideLoadBalancingExample { - public static void main(final String[] args) - { - new ClientSideLoadBalancingExample().run(args); - } - - @Override - public boolean runExample() throws Exception + public static void main(final String[] args) throws Exception { InitialContext initialContext = null; @@ -116,8 +108,6 @@ public class ClientSideLoadBalancingExample extends ActiveMQExample consume(sessionA, queue, numMessages, "A"); consume(sessionB, queue, numMessages, "B"); consume(sessionC, queue, numMessages, "C"); - - return true; } finally { @@ -143,7 +133,7 @@ public class ClientSideLoadBalancingExample extends ActiveMQExample } } - private void consume(Session session, Queue queue, int numMessages, String node) throws JMSException + private static void consume(Session session, Queue queue, int numMessages, String node) throws JMSException { MessageConsumer consumer = session.createConsumer(queue); @@ -154,6 +144,5 @@ public class ClientSideLoadBalancingExample extends ActiveMQExample } System.out.println("receive other message from node " + node + ": " + consumer.receive(2000)); - } } diff --git a/examples/jms/clustered-durable-subscription/pom.xml b/examples/jms/clustered-durable-subscription/pom.xml index a23512c66e..041fbe30fa 100644 --- a/examples/jms/clustered-durable-subscription/pom.xml +++ b/examples/jms/clustered-durable-subscription/pom.xml @@ -36,11 +36,6 @@ under the License. - - org.apache.activemq.examples.jms - common - ${project.version} - org.apache.geronimo.specs geronimo-jms_2.0_spec @@ -57,7 +52,7 @@ under the License. artemis-maven-plugin - create + create0 create @@ -67,7 +62,7 @@ under the License. - create2 + create1 create @@ -77,6 +72,36 @@ under the License. 1 + + start0 + + cli + + + true + ${basedir}/target/server0 + tcp://localhost:61616 + + run + + server0 + + + + start1 + + cli + + + true + ${basedir}/target/server1 + tcp://localhost:61617 + + run + + server1 + + runClient @@ -84,9 +109,29 @@ under the License. org.apache.activemq.artemis.jms.example.ClusteredDurableSubscriptionExample + + + + stop0 + + cli + + + ${basedir}/target/server0 - ${basedir}/target/server0 - ${basedir}/target/server1 + stop + + + + + stop1 + + cli + + + ${basedir}/target/server1 + + stop diff --git a/examples/jms/clustered-durable-subscription/src/main/java/org/apache/activemq/artemis/jms/example/ClusteredDurableSubscriptionExample.java b/examples/jms/clustered-durable-subscription/src/main/java/org/apache/activemq/artemis/jms/example/ClusteredDurableSubscriptionExample.java index d850f08e58..31d1434419 100644 --- a/examples/jms/clustered-durable-subscription/src/main/java/org/apache/activemq/artemis/jms/example/ClusteredDurableSubscriptionExample.java +++ b/examples/jms/clustered-durable-subscription/src/main/java/org/apache/activemq/artemis/jms/example/ClusteredDurableSubscriptionExample.java @@ -26,23 +26,15 @@ import javax.jms.Topic; import javax.naming.InitialContext; import java.util.Hashtable; -import org.apache.activemq.artemis.common.example.ActiveMQExample; - /** * A simple example that shows a JMS Durable Subscription across two nodes of a cluster. * * The same durable subscription can exist on more than one node of the cluster, and messages * sent to the topic will be load-balanced in a round-robin fashion between the two nodes */ -public class ClusteredDurableSubscriptionExample extends ActiveMQExample +public class ClusteredDurableSubscriptionExample { - public static void main(final String[] args) - { - new ClusteredDurableSubscriptionExample().run(args); - } - - @Override - public boolean runExample() throws Exception + public static void main(final String[] args) throws Exception { Connection connection0 = null; @@ -145,8 +137,6 @@ public class ClusteredDurableSubscriptionExample extends ActiveMQExample System.out.println("Got message: " + message1.getText() + " from node 1"); } - - return true; } finally { @@ -172,5 +162,4 @@ public class ClusteredDurableSubscriptionExample extends ActiveMQExample } } } - } diff --git a/examples/jms/clustered-durable-subscription/src/main/resources/activemq/server0/broker.xml b/examples/jms/clustered-durable-subscription/src/main/resources/activemq/server0/broker.xml index f9b0e67d0a..6214a63a6c 100644 --- a/examples/jms/clustered-durable-subscription/src/main/resources/activemq/server0/broker.xml +++ b/examples/jms/clustered-durable-subscription/src/main/resources/activemq/server0/broker.xml @@ -29,13 +29,13 @@ under the License. - ${data.dir}/server0/data/messaging/bindings + ${data.dir:./data}/bindings - ${data.dir}/server0/data/messaging/journal + ${data.dir:./data}/journal - ${data.dir}/server0/data/messaging/largemessages + ${data.dir:./data}/largemessages - ${data.dir}/server0/data/messaging/paging + ${data.dir:./data}/paging diff --git a/examples/jms/clustered-durable-subscription/src/main/resources/activemq/server1/broker.xml b/examples/jms/clustered-durable-subscription/src/main/resources/activemq/server1/broker.xml index 64f6d68e26..3d1cb2ea76 100644 --- a/examples/jms/clustered-durable-subscription/src/main/resources/activemq/server1/broker.xml +++ b/examples/jms/clustered-durable-subscription/src/main/resources/activemq/server1/broker.xml @@ -29,14 +29,13 @@ under the License. + ${data.dir:./data}/bindings - ${data.dir}/server1/data/messaging/bindings + ${data.dir:./data}/journal - ${data.dir}/server1/data/messaging/journal + ${data.dir:./data}/largemessages - ${data.dir}/server1/data/messaging/largemessages - - ${data.dir}/server1/data/messaging/paging + ${data.dir:./data}/paging diff --git a/examples/jms/clustered-grouping/pom.xml b/examples/jms/clustered-grouping/pom.xml index a9357cfda2..0f9f1015eb 100644 --- a/examples/jms/clustered-grouping/pom.xml +++ b/examples/jms/clustered-grouping/pom.xml @@ -36,11 +36,6 @@ under the License. - - org.apache.activemq.examples.jms - common - ${project.version} - org.apache.geronimo.specs geronimo-jms_2.0_spec @@ -57,7 +52,7 @@ under the License. artemis-maven-plugin - create + create0 create @@ -67,25 +62,68 @@ under the License. - create2 + create1 create ${basedir}/target/server1 ${basedir}/target/classes/activemq/server1 - 1 - create3 + create2 create ${basedir}/target/server2 ${basedir}/target/classes/activemq/server2 - 2 + + + + start0 + + cli + + + true + ${basedir}/target/server0 + tcp://localhost:61616 + + run + + server0 + + + + start1 + + cli + + + true + ${basedir}/target/server1 + tcp://localhost:61617 + + run + + server1 + + + + start2 + + cli + + + true + ${basedir}/target/server2 + tcp://localhost:61618 + + run + + server2 @@ -95,10 +133,41 @@ under the License. org.apache.activemq.artemis.jms.example.ClusteredGroupingExample + + + + stop0 + + cli + + + ${basedir}/target/server0 - ${basedir}/target/server0 - ${basedir}/target/server1 - ${basedir}/target/server2 + stop + + + + + stop1 + + cli + + + ${basedir}/target/server1 + + stop + + + + + stop2 + + cli + + + ${basedir}/target/server2 + + stop diff --git a/examples/jms/clustered-grouping/src/main/java/org/apache/activemq/artemis/jms/example/ClusteredGroupingExample.java b/examples/jms/clustered-grouping/src/main/java/org/apache/activemq/artemis/jms/example/ClusteredGroupingExample.java index b13681b858..a60ea6b656 100644 --- a/examples/jms/clustered-grouping/src/main/java/org/apache/activemq/artemis/jms/example/ClusteredGroupingExample.java +++ b/examples/jms/clustered-grouping/src/main/java/org/apache/activemq/artemis/jms/example/ClusteredGroupingExample.java @@ -26,21 +26,13 @@ import javax.jms.TextMessage; import javax.naming.InitialContext; import java.util.Hashtable; -import org.apache.activemq.artemis.common.example.ActiveMQExample; - /** * A simple example that demonstrates server side load-balancing of messages between the queue instances on different * nodes of the cluster. */ -public class ClusteredGroupingExample extends ActiveMQExample +public class ClusteredGroupingExample { - public static void main(String[] args) - { - new ClusteredGroupingExample().run(args); - } - - @Override - public boolean runExample() throws Exception + public static void main(String[] args) throws Exception { Connection connection0 = null; @@ -171,8 +163,6 @@ public class ClusteredGroupingExample extends ActiveMQExample System.out.println("Got message: " + message0.getText() + " from node 0"); } - - return true; } finally { diff --git a/examples/jms/clustered-grouping/src/main/resources/activemq/server0/broker.xml b/examples/jms/clustered-grouping/src/main/resources/activemq/server0/broker.xml index 8b67aa5a34..77fa2e6454 100644 --- a/examples/jms/clustered-grouping/src/main/resources/activemq/server0/broker.xml +++ b/examples/jms/clustered-grouping/src/main/resources/activemq/server0/broker.xml @@ -29,14 +29,13 @@ under the License. + ${data.dir:./data}/bindings - ${data.dir:../data}/bindings + ${data.dir:./data}/journal - ${data.dir:../data}/journal + ${data.dir:./data}/largemessages - ${data.dir:../data}/largemessages - - ${data.dir:../data}/paging + ${data.dir:./data}/paging diff --git a/examples/jms/clustered-grouping/src/main/resources/activemq/server1/broker.xml b/examples/jms/clustered-grouping/src/main/resources/activemq/server1/broker.xml index 7ab2e7ed5c..fabd98d8ce 100644 --- a/examples/jms/clustered-grouping/src/main/resources/activemq/server1/broker.xml +++ b/examples/jms/clustered-grouping/src/main/resources/activemq/server1/broker.xml @@ -29,14 +29,13 @@ under the License. + ${data.dir:./data}/bindings - ${data.dir:../data}/bindings + ${data.dir:./data}/journal - ${data.dir:../data}/journal + ${data.dir:./data}/largemessages - ${data.dir:../data}/largemessages - - ${data.dir:../data}/paging + ${data.dir:./data}/paging diff --git a/examples/jms/clustered-grouping/src/main/resources/activemq/server2/broker.xml b/examples/jms/clustered-grouping/src/main/resources/activemq/server2/broker.xml index 1776c5c852..07d18fcd0a 100644 --- a/examples/jms/clustered-grouping/src/main/resources/activemq/server2/broker.xml +++ b/examples/jms/clustered-grouping/src/main/resources/activemq/server2/broker.xml @@ -29,14 +29,13 @@ under the License. + ${data.dir:./data}/bindings - ${data.dir:../data}/bindings + ${data.dir:./data}/journal - ${data.dir:../data}/journal + ${data.dir:./data}/largemessages - ${data.dir:../data}/largemessages - - ${data.dir:../data}/paging + ${data.dir:./data}/paging diff --git a/examples/jms/clustered-jgroups/pom.xml b/examples/jms/clustered-jgroups/pom.xml index b19deb3b12..fc90be7024 100644 --- a/examples/jms/clustered-jgroups/pom.xml +++ b/examples/jms/clustered-jgroups/pom.xml @@ -36,11 +36,6 @@ under the License. - - org.apache.activemq.examples.jms - common - ${project.version} - org.apache.geronimo.specs geronimo-jms_2.0_spec @@ -71,7 +66,7 @@ under the License. - create2 + create1 create @@ -82,7 +77,36 @@ under the License. ${basedir}/target/server1 ${basedir}/target/classes/activemq/server1 - 1 + + + + start0 + + cli + + + true + ${basedir}/target/server0 + tcp://localhost:61616 + + run + + server0 + + + + start1 + + cli + + + true + ${basedir}/target/server1 + tcp://localhost:61617 + + run + + server1 @@ -92,9 +116,29 @@ under the License. org.apache.activemq.artemis.jms.example.ClusteredJgroupsExample + + + + stop0 + + cli + + + ${basedir}/target/server0 - ${basedir}/target/server0 - ${basedir}/target/server1 + stop + + + + + stop1 + + cli + + + ${basedir}/target/server1 + + stop diff --git a/examples/jms/clustered-jgroups/src/main/java/org/apache/activemq/artemis/jms/example/ClusteredJgroupsExample.java b/examples/jms/clustered-jgroups/src/main/java/org/apache/activemq/artemis/jms/example/ClusteredJgroupsExample.java index 9d7c3dcbd9..532161890d 100644 --- a/examples/jms/clustered-jgroups/src/main/java/org/apache/activemq/artemis/jms/example/ClusteredJgroupsExample.java +++ b/examples/jms/clustered-jgroups/src/main/java/org/apache/activemq/artemis/jms/example/ClusteredJgroupsExample.java @@ -26,20 +26,12 @@ import javax.jms.TextMessage; import javax.naming.InitialContext; import java.util.Hashtable; -import org.apache.activemq.artemis.common.example.ActiveMQExample; - /** * A simple example that demonstrates clustering using jgroups. */ -public class ClusteredJgroupsExample extends ActiveMQExample +public class ClusteredJgroupsExample { - public static void main(final String[] args) - { - new ClusteredJgroupsExample().run(args); - } - - @Override - public boolean runExample() throws Exception + public static void main(final String[] args) throws Exception { Connection connection0 = null; @@ -128,8 +120,6 @@ public class ClusteredJgroupsExample extends ActiveMQExample System.out.println("Got message: " + message1.getText() + " from node 1"); } - - return true; } finally { @@ -156,5 +146,4 @@ public class ClusteredJgroupsExample extends ActiveMQExample } } } - } diff --git a/examples/jms/clustered-jgroups/src/main/resources/activemq/server0/broker.xml b/examples/jms/clustered-jgroups/src/main/resources/activemq/server0/broker.xml index 8eb82842eb..4af9867449 100644 --- a/examples/jms/clustered-jgroups/src/main/resources/activemq/server0/broker.xml +++ b/examples/jms/clustered-jgroups/src/main/resources/activemq/server0/broker.xml @@ -29,14 +29,13 @@ under the License. + ${data.dir:./data}/bindings - server0/paging + ${data.dir:./data}/journal - server0/bindings + ${data.dir:./data}/largemessages - server0/journal - - server0/large-messages + ${data.dir:./data}/paging diff --git a/examples/jms/clustered-jgroups/src/main/resources/activemq/server1/broker.xml b/examples/jms/clustered-jgroups/src/main/resources/activemq/server1/broker.xml index b72e119ff2..3393a42fd4 100644 --- a/examples/jms/clustered-jgroups/src/main/resources/activemq/server1/broker.xml +++ b/examples/jms/clustered-jgroups/src/main/resources/activemq/server1/broker.xml @@ -29,14 +29,13 @@ under the License. + ${data.dir:./data}/bindings - server1/paging + ${data.dir:./data}/journal - server1/bindings + ${data.dir:./data}/largemessages - server1/journal - - server1/large-messages + ${data.dir:./data}/paging diff --git a/examples/jms/clustered-queue/pom.xml b/examples/jms/clustered-queue/pom.xml index d4afa599f7..7b4287542e 100644 --- a/examples/jms/clustered-queue/pom.xml +++ b/examples/jms/clustered-queue/pom.xml @@ -36,11 +36,6 @@ under the License. - - org.apache.activemq.examples.jms - common - ${project.version} - org.apache.geronimo.specs geronimo-jms_2.0_spec @@ -57,7 +52,7 @@ under the License. artemis-maven-plugin - create + create0 create @@ -67,14 +62,43 @@ under the License. - create2 + create1 create ${basedir}/target/server1 ${basedir}/target/classes/activemq/server1 - 1 + + + + start0 + + cli + + + true + ${basedir}/target/server0 + tcp://localhost:61616 + + run + + server0 + + + + start1 + + cli + + + true + ${basedir}/target/server1 + tcp://localhost:61617 + + run + + server1 @@ -84,9 +108,29 @@ under the License. org.apache.activemq.artemis.jms.example.ClusteredQueueExample + + + + stop0 + + cli + + + ${basedir}/target/server0 - ${basedir}/target/server0 - ${basedir}/target/server1 + stop + + + + + stop1 + + cli + + + ${basedir}/target/server1 + + stop diff --git a/examples/jms/clustered-queue/src/main/java/org/apache/activemq/artemis/jms/example/ClusteredQueueExample.java b/examples/jms/clustered-queue/src/main/java/org/apache/activemq/artemis/jms/example/ClusteredQueueExample.java index 0011865a49..12a0a4554c 100644 --- a/examples/jms/clustered-queue/src/main/java/org/apache/activemq/artemis/jms/example/ClusteredQueueExample.java +++ b/examples/jms/clustered-queue/src/main/java/org/apache/activemq/artemis/jms/example/ClusteredQueueExample.java @@ -26,21 +26,13 @@ import javax.jms.TextMessage; import javax.naming.InitialContext; import java.util.Hashtable; -import org.apache.activemq.artemis.common.example.ActiveMQExample; - /** * A simple example that demonstrates server side load-balancing of messages between the queue instances on different * nodes of the cluster. */ -public class ClusteredQueueExample extends ActiveMQExample +public class ClusteredQueueExample { - public static void main(final String[] args) - { - new ClusteredQueueExample().run(args); - } - - @Override - public boolean runExample() throws Exception + public static void main(final String[] args) throws Exception { Connection connection0 = null; @@ -55,7 +47,7 @@ public class ClusteredQueueExample extends ActiveMQExample // Step 1. Get an initial context for looking up JNDI from server 0 Hashtable properties = new Hashtable(); properties.put("java.naming.factory.initial", "org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory"); - properties.put("connectionFactory.ConnectionFactory", DEFAULT_TCP1); + properties.put("connectionFactory.ConnectionFactory", "tcp://localhost:61616"); properties.put("queue.queue/exampleQueue", "exampleQueue"); ic0 = new InitialContext(properties); @@ -68,7 +60,7 @@ public class ClusteredQueueExample extends ActiveMQExample // Step 4. Get an initial context for looking up JNDI from server 1 properties = new Hashtable(); properties.put("java.naming.factory.initial", "org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory"); - properties.put("connectionFactory.ConnectionFactory", DEFAULT_TCP2); + properties.put("connectionFactory.ConnectionFactory", "tcp://localhost:61617"); ic1 = new InitialContext(properties); // Step 5. Look-up a JMS Connection Factory object from JNDI on server 1 @@ -129,8 +121,6 @@ public class ClusteredQueueExample extends ActiveMQExample System.out.println("Got message: " + message1.getText() + " from node 1"); } - - return true; } finally { @@ -157,5 +147,4 @@ public class ClusteredQueueExample extends ActiveMQExample } } } - } diff --git a/examples/jms/clustered-queue/src/main/resources/activemq/server0/artemis-roles.properties b/examples/jms/clustered-queue/src/main/resources/activemq/server0/artemis-roles.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/clustered-queue/src/main/resources/activemq/server0/artemis-roles.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/clustered-queue/src/main/resources/activemq/server0/artemis-users.properties b/examples/jms/clustered-queue/src/main/resources/activemq/server0/artemis-users.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/clustered-queue/src/main/resources/activemq/server0/artemis-users.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/clustered-queue/src/main/resources/activemq/server0/broker.xml b/examples/jms/clustered-queue/src/main/resources/activemq/server0/broker.xml index f038cfe2d9..db9707688d 100644 --- a/examples/jms/clustered-queue/src/main/resources/activemq/server0/broker.xml +++ b/examples/jms/clustered-queue/src/main/resources/activemq/server0/broker.xml @@ -29,14 +29,13 @@ under the License. + ${data.dir:./data}/bindings - target/server0/data/messaging/bindings + ${data.dir:./data}/journal - target/server0/data/messaging/journal + ${data.dir:./data}/largemessages - target/server0/data/messaging/largemessages - - target/server0/data/messaging/paging + ${data.dir:./data}/paging diff --git a/examples/jms/clustered-queue/src/main/resources/activemq/server1/artemis-roles.properties b/examples/jms/clustered-queue/src/main/resources/activemq/server1/artemis-roles.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/clustered-queue/src/main/resources/activemq/server1/artemis-roles.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/clustered-queue/src/main/resources/activemq/server1/artemis-users.properties b/examples/jms/clustered-queue/src/main/resources/activemq/server1/artemis-users.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/clustered-queue/src/main/resources/activemq/server1/artemis-users.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/clustered-standalone/pom.xml b/examples/jms/clustered-standalone/pom.xml index 1f2249d534..e37336f0db 100644 --- a/examples/jms/clustered-standalone/pom.xml +++ b/examples/jms/clustered-standalone/pom.xml @@ -36,11 +36,6 @@ under the License. - - org.apache.activemq.examples.jms - common - ${project.version} - org.apache.geronimo.specs geronimo-jms_2.0_spec @@ -57,7 +52,7 @@ under the License. artemis-maven-plugin - create + create0 create @@ -67,25 +62,68 @@ under the License. - create2 + create1 create ${basedir}/target/server1 ${basedir}/target/classes/activemq/server1 - 1 - create3 + create2 create ${basedir}/target/server2 ${basedir}/target/classes/activemq/server2 - 2 + + + + start0 + + cli + + + true + ${basedir}/target/server0 + tcp://localhost:61616 + + run + + server0 + + + + start1 + + cli + + + true + ${basedir}/target/server1 + tcp://localhost:61617 + + run + + server1 + + + + start2 + + cli + + + true + ${basedir}/target/server2 + tcp://localhost:61618 + + run + + server2 @@ -95,10 +133,41 @@ under the License. org.apache.activemq.artemis.jms.example.ClusteredStandaloneExample + + + + stop0 + + cli + + + ${basedir}/target/server0 - ${basedir}/target/server0 - ${basedir}/target/server1 - ${basedir}/target/server2 + stop + + + + + stop1 + + cli + + + ${basedir}/target/server1 + + stop + + + + + stop2 + + cli + + + ${basedir}/target/server2 + + stop diff --git a/examples/jms/clustered-standalone/src/main/java/org/apache/activemq/artemis/jms/example/ClusteredStandaloneExample.java b/examples/jms/clustered-standalone/src/main/java/org/apache/activemq/artemis/jms/example/ClusteredStandaloneExample.java index 9437a8c11e..59427f8b4a 100644 --- a/examples/jms/clustered-standalone/src/main/java/org/apache/activemq/artemis/jms/example/ClusteredStandaloneExample.java +++ b/examples/jms/clustered-standalone/src/main/java/org/apache/activemq/artemis/jms/example/ClusteredStandaloneExample.java @@ -26,17 +26,9 @@ import javax.jms.Topic; import javax.naming.InitialContext; import java.util.Hashtable; -import org.apache.activemq.artemis.common.example.ActiveMQExample; - -public class ClusteredStandaloneExample extends ActiveMQExample +public class ClusteredStandaloneExample { - public static void main(final String[] args) - { - new ClusteredStandaloneExample().run(args); - } - - @Override - public boolean runExample() throws Exception + public static void main(final String[] args) throws Exception { Connection connection0 = null; @@ -52,18 +44,18 @@ public class ClusteredStandaloneExample extends ActiveMQExample { Hashtable properties = new Hashtable(); properties.put("java.naming.factory.initial", "org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory"); - properties.put("connectionFactory.ConnectionFactory", DEFAULT_TCP1); + properties.put("connectionFactory.ConnectionFactory", "tcp://localhost:61616"); properties.put("topic.topic/exampleTopic", "exampleTopic"); initialContext0 = new InitialContext(properties); properties = new Hashtable(); properties.put("java.naming.factory.initial", "org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory"); - properties.put("connectionFactory.ConnectionFactory", DEFAULT_TCP2); + properties.put("connectionFactory.ConnectionFactory", "tcp://localhost:61617"); initialContext1 = new InitialContext(properties); properties = new Hashtable(); properties.put("java.naming.factory.initial", "org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory"); - properties.put("connectionFactory.ConnectionFactory", DEFAULT_TCP3); + properties.put("connectionFactory.ConnectionFactory", "tcp://localhost:61618"); initialContext2 = new InitialContext(properties); // First we demonstrate a distributed topic. @@ -125,7 +117,7 @@ public class ClusteredStandaloneExample extends ActiveMQExample if (message0 == null) { - return false; + throw new IllegalStateException(); } // System.out.println("Received message " + message0.getText()); @@ -134,7 +126,7 @@ public class ClusteredStandaloneExample extends ActiveMQExample if (message1 == null) { - return false; + throw new IllegalStateException(); } // System.out.println("Received message " + message1.getText()); @@ -143,7 +135,7 @@ public class ClusteredStandaloneExample extends ActiveMQExample if (message2 == null) { - return false; + throw new IllegalStateException(); } System.out.println("Received message " + message2.getText()); @@ -156,8 +148,6 @@ public class ClusteredStandaloneExample extends ActiveMQExample messageConsumer1.close(); messageConsumer2.close(); - - return true; } finally { @@ -188,5 +178,4 @@ public class ClusteredStandaloneExample extends ActiveMQExample } } } - } diff --git a/examples/jms/clustered-standalone/src/main/resources/activemq/server0/artemis-roles.properties b/examples/jms/clustered-standalone/src/main/resources/activemq/server0/artemis-roles.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/clustered-standalone/src/main/resources/activemq/server0/artemis-roles.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/clustered-standalone/src/main/resources/activemq/server0/artemis-users.properties b/examples/jms/clustered-standalone/src/main/resources/activemq/server0/artemis-users.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/clustered-standalone/src/main/resources/activemq/server0/artemis-users.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/clustered-standalone/src/main/resources/activemq/server0/broker.xml b/examples/jms/clustered-standalone/src/main/resources/activemq/server0/broker.xml index 16f500258c..55675d0095 100644 --- a/examples/jms/clustered-standalone/src/main/resources/activemq/server0/broker.xml +++ b/examples/jms/clustered-standalone/src/main/resources/activemq/server0/broker.xml @@ -29,14 +29,13 @@ under the License. + ${data.dir:./data}/bindings - target/server0/data/messaging/bindings + ${data.dir:./data}/journal - target/server0/data/messaging/journal + ${data.dir:./data}/largemessages - target/server0/data/messaging/largemessages - - target/server0/data/messaging/paging + ${data.dir:./data}/paging diff --git a/examples/jms/clustered-standalone/src/main/resources/activemq/server1/artemis-roles.properties b/examples/jms/clustered-standalone/src/main/resources/activemq/server1/artemis-roles.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/clustered-standalone/src/main/resources/activemq/server1/artemis-roles.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/clustered-standalone/src/main/resources/activemq/server1/artemis-users.properties b/examples/jms/clustered-standalone/src/main/resources/activemq/server1/artemis-users.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/clustered-standalone/src/main/resources/activemq/server1/artemis-users.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/clustered-standalone/src/main/resources/activemq/server1/broker.xml b/examples/jms/clustered-standalone/src/main/resources/activemq/server1/broker.xml index 33f9cf4f8d..78b0f2f8f3 100644 --- a/examples/jms/clustered-standalone/src/main/resources/activemq/server1/broker.xml +++ b/examples/jms/clustered-standalone/src/main/resources/activemq/server1/broker.xml @@ -29,14 +29,13 @@ under the License. + ${data.dir:./data}/bindings - target/server1/data/messaging/bindings + ${data.dir:./data}/journal - target/server1/data/messaging/journal + ${data.dir:./data}/largemessages - target/server1/data/messaging/largemessages - - target/server1/data/messaging/paging + ${data.dir:./data}/paging diff --git a/examples/jms/clustered-standalone/src/main/resources/activemq/server2/artemis-roles.properties b/examples/jms/clustered-standalone/src/main/resources/activemq/server2/artemis-roles.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/clustered-standalone/src/main/resources/activemq/server2/artemis-roles.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/clustered-standalone/src/main/resources/activemq/server2/artemis-users.properties b/examples/jms/clustered-standalone/src/main/resources/activemq/server2/artemis-users.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/clustered-standalone/src/main/resources/activemq/server2/artemis-users.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/clustered-standalone/src/main/resources/activemq/server2/broker.xml b/examples/jms/clustered-standalone/src/main/resources/activemq/server2/broker.xml index 3275f283a6..389914cce9 100644 --- a/examples/jms/clustered-standalone/src/main/resources/activemq/server2/broker.xml +++ b/examples/jms/clustered-standalone/src/main/resources/activemq/server2/broker.xml @@ -29,14 +29,13 @@ under the License. + ${data.dir:./data}/bindings - target/server2/data/messaging/bindings + ${data.dir:./data}/journal - target/server2/data/messaging/journal + ${data.dir:./data}/largemessages - target/server2/data/messaging/largemessages - - target/server2/data/messaging/paging + ${data.dir:./data}/paging diff --git a/examples/jms/clustered-static-discovery/pom.xml b/examples/jms/clustered-static-discovery/pom.xml index 597bdfb14a..98fcc909a0 100644 --- a/examples/jms/clustered-static-discovery/pom.xml +++ b/examples/jms/clustered-static-discovery/pom.xml @@ -37,8 +37,8 @@ under the License. - org.apache.activemq.examples.jms - common + org.apache.activemq + artemis-cli ${project.version} @@ -57,7 +57,7 @@ under the License. artemis-maven-plugin - create + create0 create @@ -67,14 +67,23 @@ under the License. - create2 + create1 create ${basedir}/target/server1 ${basedir}/target/classes/activemq/server1 - 1 + + + + create2 + + create + + + ${basedir}/target/server2 + ${basedir}/target/classes/activemq/server2 @@ -83,20 +92,68 @@ under the License. create - ${basedir}/target/server2 - ${basedir}/target/classes/activemq/server2 - 2 + ${basedir}/target/server3 + ${basedir}/target/classes/activemq/server3 - create4 + start0 - create + cli - ${basedir}/target/server3 - ${basedir}/target/classes/activemq/server3 - 3 + true + ${basedir}/target/server0 + tcp://localhost:61616 + + run + + server0 + + + + start1 + + cli + + + true + ${basedir}/target/server1 + tcp://localhost:61617 + + run + + server1 + + + + start2 + + cli + + + true + ${basedir}/target/server2 + tcp://localhost:61618 + + run + + server2 + + + + start3 + + cli + + + true + ${basedir}/target/server3 + tcp://localhost:61619 + + run + + server3 @@ -106,11 +163,53 @@ under the License. org.apache.activemq.artemis.jms.example.StaticClusteredQueueExample + + + + stop0 + + cli + + + ${basedir}/target/server0 - ${basedir}/target/server0 - ${basedir}/target/server1 - ${basedir}/target/server2 - ${basedir}/target/server3 + stop + + + + + stop1 + + cli + + + ${basedir}/target/server1 + + stop + + + + + stop2 + + cli + + + ${basedir}/target/server2 + + stop + + + + + stop3 + + cli + + + ${basedir}/target/server3 + + stop diff --git a/examples/jms/clustered-static-discovery/src/main/java/org/apache/activemq/artemis/jms/example/StaticClusteredQueueExample.java b/examples/jms/clustered-static-discovery/src/main/java/org/apache/activemq/artemis/jms/example/StaticClusteredQueueExample.java index c7c9efb94f..4e0ac264cd 100644 --- a/examples/jms/clustered-static-discovery/src/main/java/org/apache/activemq/artemis/jms/example/StaticClusteredQueueExample.java +++ b/examples/jms/clustered-static-discovery/src/main/java/org/apache/activemq/artemis/jms/example/StaticClusteredQueueExample.java @@ -16,6 +16,8 @@ */ package org.apache.activemq.artemis.jms.example; +import org.apache.activemq.artemis.util.ServerUtil; + import javax.jms.Connection; import javax.jms.ConnectionFactory; import javax.jms.MessageConsumer; @@ -26,21 +28,13 @@ import javax.jms.TextMessage; import javax.naming.InitialContext; import java.util.Hashtable; -import org.apache.activemq.artemis.common.example.ActiveMQExample; - /** * A simple example that demonstrates server side load-balancing of messages between the queue instances on different * nodes of the cluster. The cluster is created from a static list of nodes. */ -public class StaticClusteredQueueExample extends ActiveMQExample +public class StaticClusteredQueueExample { - public static void main(final String[] args) - { - new StaticClusteredQueueExample().run(args); - } - - @Override - public boolean runExample() throws Exception + public static void main(final String[] args) throws Exception { Connection initialConnection = null; @@ -59,7 +53,7 @@ public class StaticClusteredQueueExample extends ActiveMQExample // Step 1. Get an initial context for looking up JNDI from server 3 Hashtable properties = new Hashtable(); properties.put("java.naming.factory.initial", "org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory"); - properties.put("connectionFactory.ConnectionFactory", DEFAULT_TCP4); + properties.put("connectionFactory.ConnectionFactory", "tcp://localhost:61619"); properties.put("queue.queue/exampleQueue", "exampleQueue"); ic0 = new InitialContext(properties); @@ -139,14 +133,14 @@ public class StaticClusteredQueueExample extends ActiveMQExample // We note the messages have been distributed between servers in a round robin fashion // JMS Queues implement point-to-point message where each message is only ever consumed by a // maximum of one consumer - int con0Node = getServer(connection0); - int con1Node = getServer(connection1); - int con2Node = getServer(connection2); - int con3Node = getServer(connection3); + int con0Node = ServerUtil.getServer(connection0); + int con1Node = ServerUtil.getServer(connection1); + int con2Node = ServerUtil.getServer(connection2); + int con3Node = ServerUtil.getServer(connection3); if(con0Node + con1Node + con2Node + con3Node != 6) { - return false; + throw new IllegalStateException(); } for (int i = 0; i < numMessages; i += 4) { @@ -166,8 +160,6 @@ public class StaticClusteredQueueExample extends ActiveMQExample System.out.println("Got message: " + message3.getText() + " from node " + con3Node); } - - return true; } finally { @@ -204,5 +196,4 @@ public class StaticClusteredQueueExample extends ActiveMQExample } } } - } diff --git a/examples/jms/clustered-static-discovery/src/main/resources/activemq/server0/artemis-roles.properties b/examples/jms/clustered-static-discovery/src/main/resources/activemq/server0/artemis-roles.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/clustered-static-discovery/src/main/resources/activemq/server0/artemis-roles.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/clustered-static-discovery/src/main/resources/activemq/server0/artemis-users.properties b/examples/jms/clustered-static-discovery/src/main/resources/activemq/server0/artemis-users.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/clustered-static-discovery/src/main/resources/activemq/server0/artemis-users.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/clustered-static-discovery/src/main/resources/activemq/server0/broker.xml b/examples/jms/clustered-static-discovery/src/main/resources/activemq/server0/broker.xml index e751729637..30bee5dcf7 100644 --- a/examples/jms/clustered-static-discovery/src/main/resources/activemq/server0/broker.xml +++ b/examples/jms/clustered-static-discovery/src/main/resources/activemq/server0/broker.xml @@ -29,14 +29,13 @@ under the License. + ${data.dir:./data}/bindings - ${data.dir}/server0/data/messaging/bindings + ${data.dir:./data}/journal - ${data.dir}/server0/data/messaging/journal + ${data.dir:./data}/largemessages - ${data.dir}/server0/data/messaging/largemessages - - ${data.dir}/server0/data/messaging/paging + ${data.dir:./data}/paging diff --git a/examples/jms/clustered-static-discovery/src/main/resources/activemq/server1/artemis-roles.properties b/examples/jms/clustered-static-discovery/src/main/resources/activemq/server1/artemis-roles.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/clustered-static-discovery/src/main/resources/activemq/server1/artemis-roles.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/clustered-static-discovery/src/main/resources/activemq/server1/artemis-users.properties b/examples/jms/clustered-static-discovery/src/main/resources/activemq/server1/artemis-users.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/clustered-static-discovery/src/main/resources/activemq/server1/artemis-users.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/clustered-static-discovery/src/main/resources/activemq/server1/broker.xml b/examples/jms/clustered-static-discovery/src/main/resources/activemq/server1/broker.xml index 8e48890608..f2f2565841 100644 --- a/examples/jms/clustered-static-discovery/src/main/resources/activemq/server1/broker.xml +++ b/examples/jms/clustered-static-discovery/src/main/resources/activemq/server1/broker.xml @@ -29,14 +29,13 @@ under the License. + ${data.dir:./data}/bindings - ${data.dir}/server1/data/messaging/bindings + ${data.dir:./data}/journal - ${data.dir}/server1/data/messaging/journal + ${data.dir:./data}/largemessages - ${data.dir}/server1/data/messaging/largemessages - - ${data.dir}/server1/data/messaging/paging + ${data.dir:./data}/paging diff --git a/examples/jms/clustered-static-discovery/src/main/resources/activemq/server2/artemis-roles.properties b/examples/jms/clustered-static-discovery/src/main/resources/activemq/server2/artemis-roles.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/clustered-static-discovery/src/main/resources/activemq/server2/artemis-roles.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/clustered-static-discovery/src/main/resources/activemq/server2/artemis-users.properties b/examples/jms/clustered-static-discovery/src/main/resources/activemq/server2/artemis-users.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/clustered-static-discovery/src/main/resources/activemq/server2/artemis-users.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/clustered-static-discovery/src/main/resources/activemq/server2/broker.xml b/examples/jms/clustered-static-discovery/src/main/resources/activemq/server2/broker.xml index 9321799dda..e9e5f08ba0 100644 --- a/examples/jms/clustered-static-discovery/src/main/resources/activemq/server2/broker.xml +++ b/examples/jms/clustered-static-discovery/src/main/resources/activemq/server2/broker.xml @@ -26,14 +26,13 @@ + ${data.dir:./data}/bindings - ${data.dir}/server2/data/messaging/bindings + ${data.dir:./data}/journal - ${data.dir}/server2/data/messaging/journal + ${data.dir:./data}/largemessages - ${data.dir}/server2/data/messaging/largemessages - - ${data.dir}/server2/data/messaging/paging + ${data.dir:./data}/paging diff --git a/examples/jms/clustered-static-discovery/src/main/resources/activemq/server3/artemis-roles.properties b/examples/jms/clustered-static-discovery/src/main/resources/activemq/server3/artemis-roles.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/clustered-static-discovery/src/main/resources/activemq/server3/artemis-roles.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/clustered-static-discovery/src/main/resources/activemq/server3/artemis-users.properties b/examples/jms/clustered-static-discovery/src/main/resources/activemq/server3/artemis-users.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/clustered-static-discovery/src/main/resources/activemq/server3/artemis-users.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/clustered-static-discovery/src/main/resources/activemq/server3/broker.xml b/examples/jms/clustered-static-discovery/src/main/resources/activemq/server3/broker.xml index c8879a41b2..0ebc2d0064 100644 --- a/examples/jms/clustered-static-discovery/src/main/resources/activemq/server3/broker.xml +++ b/examples/jms/clustered-static-discovery/src/main/resources/activemq/server3/broker.xml @@ -26,14 +26,13 @@ + ${data.dir:./data}/bindings - ${data.dir}/server3/data/messaging/bindings + ${data.dir:./data}/journal - ${data.dir}/server3/data/messaging/journal + ${data.dir:./data}/largemessages - ${data.dir}/server3/data/messaging/largemessages - - ${data.dir}/server3/data/messaging/paging + ${data.dir:./data}/paging diff --git a/examples/jms/clustered-static-oneway/pom.xml b/examples/jms/clustered-static-oneway/pom.xml index 1c44be407f..991a6248f3 100644 --- a/examples/jms/clustered-static-oneway/pom.xml +++ b/examples/jms/clustered-static-oneway/pom.xml @@ -37,8 +37,8 @@ under the License. - org.apache.activemq.examples.jms - common + org.apache.activemq + artemis-cli ${project.version} @@ -57,7 +57,7 @@ under the License. artemis-maven-plugin - create + create0 create @@ -67,7 +67,7 @@ under the License. - create2 + create1 create @@ -77,7 +77,7 @@ under the License. - create3 + create2 create @@ -86,6 +86,51 @@ under the License. ${basedir}/target/classes/activemq/server2 + + start0 + + cli + + + true + ${basedir}/target/server0 + tcp://localhost:61616 + + run + + server0 + + + + start1 + + cli + + + true + ${basedir}/target/server1 + tcp://localhost:61617 + + run + + server1 + + + + start2 + + cli + + + true + ${basedir}/target/server2 + tcp://localhost:61618 + + run + + server2 + + runClient @@ -93,10 +138,41 @@ under the License. org.apache.activemq.artemis.jms.example.ClusterStaticOnewayExample + + + + stop0 + + cli + + + ${basedir}/target/server0 - ${basedir}/target/server0 - ${basedir}/target/server1 - ${basedir}/target/server2 + stop + + + + + stop1 + + cli + + + ${basedir}/target/server1 + + stop + + + + + stop2 + + cli + + + ${basedir}/target/server2 + + stop @@ -113,5 +189,4 @@ under the License. - diff --git a/examples/jms/clustered-static-oneway/src/main/java/org/apache/activemq/artemis/jms/example/ClusterStaticOnewayExample.java b/examples/jms/clustered-static-oneway/src/main/java/org/apache/activemq/artemis/jms/example/ClusterStaticOnewayExample.java index fd1f4e5ca8..e061722845 100644 --- a/examples/jms/clustered-static-oneway/src/main/java/org/apache/activemq/artemis/jms/example/ClusterStaticOnewayExample.java +++ b/examples/jms/clustered-static-oneway/src/main/java/org/apache/activemq/artemis/jms/example/ClusterStaticOnewayExample.java @@ -16,6 +16,8 @@ */ package org.apache.activemq.artemis.jms.example; +import org.apache.activemq.artemis.util.ServerUtil; + import javax.jms.Connection; import javax.jms.ConnectionFactory; import javax.jms.MessageConsumer; @@ -26,21 +28,13 @@ import javax.jms.TextMessage; import javax.naming.InitialContext; import java.util.Hashtable; -import org.apache.activemq.artemis.common.example.ActiveMQExample; - /** * A simple example that demonstrates server side load-balancing of messages between the queue instances on different * nodes of the cluster. The cluster is created from a static list of nodes. */ -public class ClusterStaticOnewayExample extends ActiveMQExample +public class ClusterStaticOnewayExample { - public static void main(final String[] args) - { - new ClusterStaticOnewayExample().run(args); - } - - @Override - public boolean runExample() throws Exception + public static void main(final String[] args) throws Exception { Connection initialConnection = null; @@ -51,13 +45,13 @@ public class ClusterStaticOnewayExample extends ActiveMQExample Connection connection2 = null; InitialContext ic0 = null; - Thread.sleep(5000); + try { // Step 1. Get an initial context for looking up JNDI from server 0 Hashtable properties = new Hashtable(); properties.put("java.naming.factory.initial", "org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory"); - properties.put("connectionFactory.ConnectionFactory", DEFAULT_TCP1); + properties.put("connectionFactory.ConnectionFactory", "tcp://localhost:61616"); properties.put("queue.queue/exampleQueue", "exampleQueue"); ic0 = new InitialContext(properties); @@ -106,9 +100,9 @@ public class ClusterStaticOnewayExample extends ActiveMQExample Thread.sleep(4000); - int con0Node = getServer(connection0); - int con1Node = getServer(connection1); - int con2Node = getServer(connection2); + int con0Node = ServerUtil.getServer(connection0); + int con1Node = ServerUtil.getServer(connection1); + int con2Node = ServerUtil.getServer(connection2); System.out.println("con0Node = " + con0Node); System.out.println("con1Node = " + con1Node); @@ -116,11 +110,10 @@ public class ClusterStaticOnewayExample extends ActiveMQExample if(con0Node + con1Node + con2Node != 3) { - System.out.println("connections not load balanced"); - return false; + throw new IllegalStateException("connections not load balanced"); } // Step 13. We create a JMS MessageProducer object on server 0 - Session sendSession = getServerConnection(0, connection0, connection1, connection2).createSession(false, Session.AUTO_ACKNOWLEDGE); + Session sendSession = ServerUtil.getServerConnection(0, connection0, connection1, connection2).createSession(false, Session.AUTO_ACKNOWLEDGE); MessageProducer producer = sendSession.createProducer(queue); @@ -156,8 +149,6 @@ public class ClusterStaticOnewayExample extends ActiveMQExample System.out.println("Got message: " + message2.getText() + " from node " + con2Node); } - - return true; } finally { @@ -189,5 +180,4 @@ public class ClusterStaticOnewayExample extends ActiveMQExample } } } - } diff --git a/examples/jms/clustered-static-oneway/src/main/resources/activemq/server0/artemis-roles.properties b/examples/jms/clustered-static-oneway/src/main/resources/activemq/server0/artemis-roles.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/clustered-static-oneway/src/main/resources/activemq/server0/artemis-roles.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/clustered-static-oneway/src/main/resources/activemq/server0/artemis-users.properties b/examples/jms/clustered-static-oneway/src/main/resources/activemq/server0/artemis-users.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/clustered-static-oneway/src/main/resources/activemq/server0/artemis-users.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/clustered-static-oneway/src/main/resources/activemq/server0/broker.xml b/examples/jms/clustered-static-oneway/src/main/resources/activemq/server0/broker.xml index cace0be89e..2d77bb142a 100644 --- a/examples/jms/clustered-static-oneway/src/main/resources/activemq/server0/broker.xml +++ b/examples/jms/clustered-static-oneway/src/main/resources/activemq/server0/broker.xml @@ -26,14 +26,13 @@ + ${data.dir:./data}/bindings - ${data.dir}/server0/data/messaging/bindings + ${data.dir:./data}/journal - ${data.dir}/server0/data/messaging/journal + ${data.dir:./data}/largemessages - ${data.dir}/server0/data/messaging/largemessages - - ${data.dir}/server0/data/messaging/paging + ${data.dir:./data}/paging diff --git a/examples/jms/clustered-static-oneway/src/main/resources/activemq/server1/artemis-roles.properties b/examples/jms/clustered-static-oneway/src/main/resources/activemq/server1/artemis-roles.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/clustered-static-oneway/src/main/resources/activemq/server1/artemis-roles.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/clustered-static-oneway/src/main/resources/activemq/server1/artemis-users.properties b/examples/jms/clustered-static-oneway/src/main/resources/activemq/server1/artemis-users.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/clustered-static-oneway/src/main/resources/activemq/server1/artemis-users.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/clustered-static-oneway/src/main/resources/activemq/server1/broker.xml b/examples/jms/clustered-static-oneway/src/main/resources/activemq/server1/broker.xml index d6918f6468..9b5fdf8125 100644 --- a/examples/jms/clustered-static-oneway/src/main/resources/activemq/server1/broker.xml +++ b/examples/jms/clustered-static-oneway/src/main/resources/activemq/server1/broker.xml @@ -26,14 +26,13 @@ + ${data.dir:./data}/bindings - ${data.dir}/server1/data/messaging/bindings + ${data.dir:./data}/journal - ${data.dir}/server1/data/messaging/journal + ${data.dir:./data}/largemessages - ${data.dir}/server1/data/messaging/largemessages - - ${data.dir}/server1/data/messaging/paging + ${data.dir:./data}/paging diff --git a/examples/jms/clustered-static-oneway/src/main/resources/activemq/server2/artemis-roles.properties b/examples/jms/clustered-static-oneway/src/main/resources/activemq/server2/artemis-roles.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/clustered-static-oneway/src/main/resources/activemq/server2/artemis-roles.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/clustered-static-oneway/src/main/resources/activemq/server2/artemis-users.properties b/examples/jms/clustered-static-oneway/src/main/resources/activemq/server2/artemis-users.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/clustered-static-oneway/src/main/resources/activemq/server2/artemis-users.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/clustered-static-oneway/src/main/resources/activemq/server2/broker.xml b/examples/jms/clustered-static-oneway/src/main/resources/activemq/server2/broker.xml index 9f2e15aa30..147a9b9875 100644 --- a/examples/jms/clustered-static-oneway/src/main/resources/activemq/server2/broker.xml +++ b/examples/jms/clustered-static-oneway/src/main/resources/activemq/server2/broker.xml @@ -26,14 +26,13 @@ + ${data.dir:./data}/bindings - ${data.dir}/server2/data/messaging/bindings + ${data.dir:./data}/journal - ${data.dir}/server2/data/messaging/journal + ${data.dir:./data}/largemessages - ${data.dir}/server2/data/messaging/largemessages - - ${data.dir}/server2/data/messaging/paging + ${data.dir:./data}/paging diff --git a/examples/jms/clustered-topic/pom.xml b/examples/jms/clustered-topic/pom.xml index 63a7c2b564..418d98f32d 100644 --- a/examples/jms/clustered-topic/pom.xml +++ b/examples/jms/clustered-topic/pom.xml @@ -36,11 +36,6 @@ under the License. - - org.apache.activemq.examples.jms - common - ${project.version} - org.apache.geronimo.specs geronimo-jms_2.0_spec @@ -57,7 +52,7 @@ under the License. artemis-maven-plugin - create + create0 create @@ -67,7 +62,7 @@ under the License. - create2 + create1 create @@ -76,6 +71,36 @@ under the License. ${basedir}/target/classes/activemq/server1 + + start0 + + cli + + + true + ${basedir}/target/server0 + tcp://localhost:61616 + + run + + server0 + + + + start1 + + cli + + + true + ${basedir}/target/server1 + tcp://localhost:61617 + + run + + server1 + + runClient @@ -83,9 +108,29 @@ under the License. org.apache.activemq.artemis.jms.example.ClusteredTopicExample + + + + stop0 + + cli + + + ${basedir}/target/server0 - ${basedir}/target/server0 - ${basedir}/target/server1 + stop + + + + + stop1 + + cli + + + ${basedir}/target/server1 + + stop diff --git a/examples/jms/clustered-topic/src/main/java/org/apache/activemq/artemis/jms/example/ClusteredTopicExample.java b/examples/jms/clustered-topic/src/main/java/org/apache/activemq/artemis/jms/example/ClusteredTopicExample.java index eae93666b1..31b3d412c5 100644 --- a/examples/jms/clustered-topic/src/main/java/org/apache/activemq/artemis/jms/example/ClusteredTopicExample.java +++ b/examples/jms/clustered-topic/src/main/java/org/apache/activemq/artemis/jms/example/ClusteredTopicExample.java @@ -26,21 +26,13 @@ import javax.jms.Topic; import javax.naming.InitialContext; import java.util.Hashtable; -import org.apache.activemq.artemis.common.example.ActiveMQExample; - /** * A simple example that shows a JMS Topic clustered across two nodes of a cluster. * Messages are sent on one node and received by consumers on both nodes. */ -public class ClusteredTopicExample extends ActiveMQExample +public class ClusteredTopicExample { - public static void main(final String[] args) - { - new ClusteredTopicExample().run(args); - } - - @Override - public boolean runExample() throws Exception + public static void main(final String[] args) throws Exception { Connection connection0 = null; @@ -55,7 +47,7 @@ public class ClusteredTopicExample extends ActiveMQExample // Step 1. Get an initial context for looking up JNDI from server 0 Hashtable properties = new Hashtable(); properties.put("java.naming.factory.initial", "org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory"); - properties.put("connectionFactory.ConnectionFactory", DEFAULT_TCP1); + properties.put("connectionFactory.ConnectionFactory", "tcp://localhost:61616"); properties.put("topic.topic/exampleTopic", "exampleTopic"); ic0 = new InitialContext(properties); @@ -68,7 +60,7 @@ public class ClusteredTopicExample extends ActiveMQExample // Step 4. Get an initial context for looking up JNDI from server 1 properties = new Hashtable(); properties.put("java.naming.factory.initial", "org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory"); - properties.put("connectionFactory.ConnectionFactory", DEFAULT_TCP2); + properties.put("connectionFactory.ConnectionFactory", "tcp://localhost:61617"); ic1 = new InitialContext(properties); // Step 5. Look-up a JMS Connection Factory object from JNDI on server 1 @@ -128,8 +120,6 @@ public class ClusteredTopicExample extends ActiveMQExample System.out.println("Got message: " + message1.getText() + " from node 1"); } - - return true; } finally { @@ -155,5 +145,4 @@ public class ClusteredTopicExample extends ActiveMQExample } } } - } diff --git a/examples/jms/clustered-topic/src/main/resources/activemq/server0/artemis-roles.properties b/examples/jms/clustered-topic/src/main/resources/activemq/server0/artemis-roles.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/clustered-topic/src/main/resources/activemq/server0/artemis-roles.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/clustered-topic/src/main/resources/activemq/server0/artemis-users.properties b/examples/jms/clustered-topic/src/main/resources/activemq/server0/artemis-users.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/clustered-topic/src/main/resources/activemq/server0/artemis-users.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/clustered-topic/src/main/resources/activemq/server0/broker.xml b/examples/jms/clustered-topic/src/main/resources/activemq/server0/broker.xml index 604bcf8169..452b412c27 100644 --- a/examples/jms/clustered-topic/src/main/resources/activemq/server0/broker.xml +++ b/examples/jms/clustered-topic/src/main/resources/activemq/server0/broker.xml @@ -29,14 +29,13 @@ under the License. + ${data.dir:./data}/bindings - ${data.dir}/server0/data/messaging/bindings + ${data.dir:./data}/journal - ${data.dir}/server0/data/messaging/journal + ${data.dir:./data}/largemessages - ${data.dir}/server0/data/messaging/largemessages - - ${data.dir}/server0/data/messaging/paging + ${data.dir:./data}/paging diff --git a/examples/jms/clustered-topic/src/main/resources/activemq/server1/artemis-roles.properties b/examples/jms/clustered-topic/src/main/resources/activemq/server1/artemis-roles.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/clustered-topic/src/main/resources/activemq/server1/artemis-roles.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/clustered-topic/src/main/resources/activemq/server1/artemis-users.properties b/examples/jms/clustered-topic/src/main/resources/activemq/server1/artemis-users.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/clustered-topic/src/main/resources/activemq/server1/artemis-users.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/clustered-topic/src/main/resources/activemq/server1/broker.xml b/examples/jms/clustered-topic/src/main/resources/activemq/server1/broker.xml index 1f5f25da26..c1a763b150 100644 --- a/examples/jms/clustered-topic/src/main/resources/activemq/server1/broker.xml +++ b/examples/jms/clustered-topic/src/main/resources/activemq/server1/broker.xml @@ -29,14 +29,13 @@ under the License. + ${data.dir:./data}/bindings - ${data.dir}/server1/data/messaging/bindings + ${data.dir:./data}/journal - ${data.dir}/server1/data/messaging/journal + ${data.dir:./data}/largemessages - ${data.dir}/server1/data/messaging/largemessages - - ${data.dir}/server1/data/messaging/paging + ${data.dir:./data}/paging diff --git a/examples/jms/colocated-failover-scale-down/pom.xml b/examples/jms/colocated-failover-scale-down/pom.xml index a0778b0543..ea1fb1095a 100644 --- a/examples/jms/colocated-failover-scale-down/pom.xml +++ b/examples/jms/colocated-failover-scale-down/pom.xml @@ -37,8 +37,8 @@ under the License. - org.apache.activemq.examples.jms - common + org.apache.activemq + artemis-cli ${project.version} @@ -57,7 +57,7 @@ under the License. artemis-maven-plugin - create + create0 create @@ -67,7 +67,7 @@ under the License. - create2 + create1 create diff --git a/examples/jms/colocated-failover-scale-down/src/main/java/org/apache/activemq/artemis/jms/example/ColocatedFailoverScaleDownExample.java b/examples/jms/colocated-failover-scale-down/src/main/java/org/apache/activemq/artemis/jms/example/ColocatedFailoverScaleDownExample.java index 678fbf9843..29f54c3207 100644 --- a/examples/jms/colocated-failover-scale-down/src/main/java/org/apache/activemq/artemis/jms/example/ColocatedFailoverScaleDownExample.java +++ b/examples/jms/colocated-failover-scale-down/src/main/java/org/apache/activemq/artemis/jms/example/ColocatedFailoverScaleDownExample.java @@ -16,6 +16,8 @@ */ package org.apache.activemq.artemis.jms.example; +import org.apache.activemq.artemis.util.ServerUtil; + import javax.jms.Connection; import javax.jms.ConnectionFactory; import javax.jms.MessageConsumer; @@ -24,23 +26,20 @@ import javax.jms.Queue; import javax.jms.Session; import javax.jms.TextMessage; import javax.naming.InitialContext; +import java.lang.IllegalStateException; import java.util.Hashtable; -import org.apache.activemq.artemis.common.example.ActiveMQExample; - /** * A simple example that demonstrates server side load-balancing of messages between the queue instances on different * nodes of the cluster. */ -public class ColocatedFailoverScaleDownExample extends ActiveMQExample +public class ColocatedFailoverScaleDownExample { - public static void main(final String[] args) throws Exception - { - new ColocatedFailoverScaleDownExample().run(args); - } + private static Process server0; - @Override - public boolean runExample() throws Exception + private static Process server1; + + public static void main(final String[] args) throws Exception { final int numMessages = 30; @@ -52,15 +51,18 @@ public class ColocatedFailoverScaleDownExample extends ActiveMQExample try { + server0 = ServerUtil.startServer(args[0], ColocatedFailoverScaleDownExample.class.getSimpleName() + "0", 0, 5000); + server1 = ServerUtil.startServer(args[1], ColocatedFailoverScaleDownExample.class.getSimpleName() + "1", 1, 5000); + // Step 1. Get an initial context for looking up JNDI for both servers Hashtable properties = new Hashtable(); properties.put("java.naming.factory.initial", "org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory"); - properties.put("connectionFactory.ConnectionFactory", DEFAULT_TCP2); + properties.put("connectionFactory.ConnectionFactory", "tcp://localhost:61617"); initialContext1 = new InitialContext(properties); properties = new Hashtable(); properties.put("java.naming.factory.initial", "org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory"); - properties.put("connectionFactory.ConnectionFactory", DEFAULT_TCP1 + "?ha=true&retryInterval=1000&retryIntervalMultiplier=1.0&reconnectAttempts=-1"); + properties.put("connectionFactory.ConnectionFactory", "tcp://localhost:61616?ha=true&retryInterval=1000&retryIntervalMultiplier=1.0&reconnectAttempts=-1"); properties.put("queue.queue/exampleQueue", "exampleQueue"); initialContext = new InitialContext(properties); @@ -94,10 +96,9 @@ public class ColocatedFailoverScaleDownExample extends ActiveMQExample // Step 7. Crash server #0, the live server, and wait a little while to make sure // it has really crashed - killServer(0); + ServerUtil.killServer(server0); Thread.sleep(5000); - // Step 8. start the connection ready to receive messages connection1.start(); @@ -111,11 +112,13 @@ public class ColocatedFailoverScaleDownExample extends ActiveMQExample for (int i = 0; i < numMessages * 2; i++) { message0 = (TextMessage)consumer.receive(5000); + if (message0 == null) + { + throw new IllegalStateException("Message not received!"); + } System.out.println("Got message: " + message0.getText()); } message0.acknowledge(); - - return true; } finally { @@ -139,7 +142,9 @@ public class ColocatedFailoverScaleDownExample extends ActiveMQExample { initialContext1.close(); } + + ServerUtil.killServer(server0); + ServerUtil.killServer(server1); } } - } diff --git a/examples/jms/colocated-failover-scale-down/src/main/resources/activemq/server0/artemis-roles.properties b/examples/jms/colocated-failover-scale-down/src/main/resources/activemq/server0/artemis-roles.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/colocated-failover-scale-down/src/main/resources/activemq/server0/artemis-roles.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/colocated-failover-scale-down/src/main/resources/activemq/server0/artemis-users.properties b/examples/jms/colocated-failover-scale-down/src/main/resources/activemq/server0/artemis-users.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/colocated-failover-scale-down/src/main/resources/activemq/server0/artemis-users.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/colocated-failover-scale-down/src/main/resources/activemq/server0/broker.xml b/examples/jms/colocated-failover-scale-down/src/main/resources/activemq/server0/broker.xml index 8c68c8d78a..60201cadee 100644 --- a/examples/jms/colocated-failover-scale-down/src/main/resources/activemq/server0/broker.xml +++ b/examples/jms/colocated-failover-scale-down/src/main/resources/activemq/server0/broker.xml @@ -29,14 +29,13 @@ under the License. + ${data.dir:../data}/bindings - ../../server0/data/messaging/bindings + ${data.dir:../data}/journal - ../../server0/data/messaging/journal + ${data.dir:../data}/largemessages - ../../server0/data/messaging/largemessages - - ../../server0/data/messaging/paging + ${data.dir:../data}/paging @@ -91,7 +90,9 @@ under the License. 2000 1 true - + + true + diff --git a/examples/jms/colocated-failover-scale-down/src/main/resources/activemq/server1/artemis-roles.properties b/examples/jms/colocated-failover-scale-down/src/main/resources/activemq/server1/artemis-roles.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/colocated-failover-scale-down/src/main/resources/activemq/server1/artemis-roles.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/colocated-failover-scale-down/src/main/resources/activemq/server1/artemis-users.properties b/examples/jms/colocated-failover-scale-down/src/main/resources/activemq/server1/artemis-users.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/colocated-failover-scale-down/src/main/resources/activemq/server1/artemis-users.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/colocated-failover-scale-down/src/main/resources/activemq/server1/broker.xml b/examples/jms/colocated-failover-scale-down/src/main/resources/activemq/server1/broker.xml index 6ad15ef6ac..7892fc142e 100644 --- a/examples/jms/colocated-failover-scale-down/src/main/resources/activemq/server1/broker.xml +++ b/examples/jms/colocated-failover-scale-down/src/main/resources/activemq/server1/broker.xml @@ -29,14 +29,13 @@ under the License. + ${data.dir:../data}/bindings - ../../server1/data/messaging/bindings + ${data.dir:../data}/journal - ../../server1/data/messaging/journal + ${data.dir:../data}/largemessages - ../../server1/data/messaging/largemessages - - ../../server1/data/messaging/paging + ${data.dir:../data}/paging diff --git a/examples/jms/colocated-failover/pom.xml b/examples/jms/colocated-failover/pom.xml index fb697b2ea4..a501d385b2 100644 --- a/examples/jms/colocated-failover/pom.xml +++ b/examples/jms/colocated-failover/pom.xml @@ -37,8 +37,8 @@ under the License. - org.apache.activemq.examples.jms - common + org.apache.activemq + artemis-cli ${project.version} @@ -57,7 +57,7 @@ under the License. artemis-maven-plugin - create + create0 create @@ -67,7 +67,7 @@ under the License. - create2 + create1 create @@ -102,5 +102,4 @@ under the License. - diff --git a/examples/jms/colocated-failover/src/main/java/org/apache/activemq/artemis/jms/example/ColocatedFailoverExample.java b/examples/jms/colocated-failover/src/main/java/org/apache/activemq/artemis/jms/example/ColocatedFailoverExample.java index de823a48dc..ad62419bf8 100644 --- a/examples/jms/colocated-failover/src/main/java/org/apache/activemq/artemis/jms/example/ColocatedFailoverExample.java +++ b/examples/jms/colocated-failover/src/main/java/org/apache/activemq/artemis/jms/example/ColocatedFailoverExample.java @@ -16,6 +16,8 @@ */ package org.apache.activemq.artemis.jms.example; +import org.apache.activemq.artemis.util.ServerUtil; + import javax.jms.Connection; import javax.jms.ConnectionFactory; import javax.jms.MessageConsumer; @@ -24,23 +26,20 @@ import javax.jms.Queue; import javax.jms.Session; import javax.jms.TextMessage; import javax.naming.InitialContext; +import java.lang.IllegalStateException; import java.util.Hashtable; -import org.apache.activemq.artemis.common.example.ActiveMQExample; - /** * A simple example that demonstrates a colocated server * */ -public class ColocatedFailoverExample extends ActiveMQExample +public class ColocatedFailoverExample { - public static void main(final String[] args) throws Exception - { - new ColocatedFailoverExample().run(args); - } + private static Process server0; - @Override - public boolean runExample() throws Exception + private static Process server1; + + public static void main(final String[] args) throws Exception { final int numMessages = 30; @@ -52,17 +51,20 @@ public class ColocatedFailoverExample extends ActiveMQExample try { + server0 = ServerUtil.startServer(args[0], ColocatedFailoverExample.class.getSimpleName() + "0", 0, 5000); + server1 = ServerUtil.startServer(args[1], ColocatedFailoverExample.class.getSimpleName() + "1", 1, 5000); + // Step 1. Get an initial context for looking up JNDI for both servers Hashtable properties = new Hashtable(); properties.put("java.naming.factory.initial", "org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory"); - properties.put("connectionFactory.ConnectionFactory", DEFAULT_TCP2); - initialContext1 = new InitialContext(properties); + properties.put("connectionFactory.ConnectionFactory", "tcp://localhost:61616?ha=true&retryInterval=1000&retryIntervalMultiplier=1.0&reconnectAttempts=-1"); + properties.put("queue.queue/exampleQueue", "exampleQueue"); + initialContext = new InitialContext(properties); properties = new Hashtable(); properties.put("java.naming.factory.initial", "org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory"); - properties.put("connectionFactory.ConnectionFactory", DEFAULT_TCP1 + "?ha=true&retryInterval=1000&retryIntervalMultiplier=1.0&reconnectAttempts=-1"); - properties.put("queue.queue/exampleQueue", "exampleQueue"); - initialContext = new InitialContext(properties); + properties.put("connectionFactory.ConnectionFactory", "tcp://localhost:61617"); + initialContext1 = new InitialContext(properties); // Step 2. Look up the JMS resources from JNDI Queue queue = (Queue)initialContext.lookup("queue/exampleQueue"); @@ -94,9 +96,7 @@ public class ColocatedFailoverExample extends ActiveMQExample // Step 7. Crash server #0, the live server, and wait a little while to make sure // it has really crashed - killServer(0); - Thread.sleep(5000); - + ServerUtil.killServer(server0); // Step 8. start the connection ready to receive messages connection.start(); @@ -111,6 +111,10 @@ public class ColocatedFailoverExample extends ActiveMQExample for (int i = 0; i < numMessages; i++) { message0 = (TextMessage)consumer.receive(5000); + if (message0 == null) + { + throw new IllegalStateException("Message not received!"); + } System.out.println("Got message: " + message0.getText()); } message0.acknowledge(); @@ -124,8 +128,6 @@ public class ColocatedFailoverExample extends ActiveMQExample System.out.println("Got message: " + message0.getText()); } message0.acknowledge(); - - return true; } finally { @@ -149,7 +151,9 @@ public class ColocatedFailoverExample extends ActiveMQExample { initialContext1.close(); } + + ServerUtil.killServer(server0); + ServerUtil.killServer(server1); } } - } diff --git a/examples/jms/colocated-failover/src/main/resources/activemq/server0/artemis-roles.properties b/examples/jms/colocated-failover/src/main/resources/activemq/server0/artemis-roles.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/colocated-failover/src/main/resources/activemq/server0/artemis-roles.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/colocated-failover/src/main/resources/activemq/server0/artemis-users.properties b/examples/jms/colocated-failover/src/main/resources/activemq/server0/artemis-users.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/colocated-failover/src/main/resources/activemq/server0/artemis-users.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/colocated-failover/src/main/resources/activemq/server0/broker.xml b/examples/jms/colocated-failover/src/main/resources/activemq/server0/broker.xml index 554d01f543..b38d7647fe 100644 --- a/examples/jms/colocated-failover/src/main/resources/activemq/server0/broker.xml +++ b/examples/jms/colocated-failover/src/main/resources/activemq/server0/broker.xml @@ -29,14 +29,13 @@ under the License. + ${data.dir:../data}/bindings - ../../server0/data/messaging/bindings + ${data.dir:../data}/journal - ../../server0/data/messaging/journal + ${data.dir:../data}/largemessages - ../../server0/data/messaging/largemessages - - ../../server0/data/messaging/paging + ${data.dir:../data}/paging @@ -87,7 +86,9 @@ under the License. 2000 1 true - + + true + diff --git a/examples/jms/colocated-failover/src/main/resources/activemq/server1/artemis-roles.properties b/examples/jms/colocated-failover/src/main/resources/activemq/server1/artemis-roles.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/colocated-failover/src/main/resources/activemq/server1/artemis-roles.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/colocated-failover/src/main/resources/activemq/server1/artemis-users.properties b/examples/jms/colocated-failover/src/main/resources/activemq/server1/artemis-users.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/colocated-failover/src/main/resources/activemq/server1/artemis-users.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/colocated-failover/src/main/resources/activemq/server1/broker.xml b/examples/jms/colocated-failover/src/main/resources/activemq/server1/broker.xml index 2fda160a71..f0dd08894b 100644 --- a/examples/jms/colocated-failover/src/main/resources/activemq/server1/broker.xml +++ b/examples/jms/colocated-failover/src/main/resources/activemq/server1/broker.xml @@ -29,14 +29,13 @@ under the License. + ${data.dir:../data}/bindings - ../../server1/data/messaging/bindings + ${data.dir:../data}/journal - ../../server1/data/messaging/journal + ${data.dir:../data}/largemessages - ../../server1/data/messaging/largemessages - - ../../server1/data/messaging/paging + ${data.dir:../data}/paging diff --git a/examples/jms/common/pom.xml b/examples/jms/common/pom.xml deleted file mode 100644 index 4681cac28a..0000000000 --- a/examples/jms/common/pom.xml +++ /dev/null @@ -1,65 +0,0 @@ - - - - - 4.0.0 - - - org.apache.activemq.examples.jms - jms-examples - 1.0.1-SNAPSHOT - - - common - jar - ActiveMQ Artemis Examples common - - - ${project.basedir}/../../.. - - - - - org.apache.geronimo.specs - geronimo-jms_2.0_spec - - - org.apache.activemq - artemis-commons - ${project.version} - - - org.apache.activemq - artemis-core-client - ${project.version} - - - org.apache.activemq - artemis-jms-client - ${project.version} - - - io.netty - netty-all - ${netty.version} - - - - diff --git a/examples/jms/common/src/main/java/org/apache/activemq/artemis/common/example/ActiveMQExample.java b/examples/jms/common/src/main/java/org/apache/activemq/artemis/common/example/ActiveMQExample.java deleted file mode 100644 index b3b791b5c2..0000000000 --- a/examples/jms/common/src/main/java/org/apache/activemq/artemis/common/example/ActiveMQExample.java +++ /dev/null @@ -1,274 +0,0 @@ -/* - * 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.common.example; - -import javax.jms.Connection; -import java.util.HashMap; -import java.util.logging.Logger; - -import org.apache.activemq.artemis.api.core.TransportConfiguration; -import org.apache.activemq.artemis.api.core.client.ClientSession; -import org.apache.activemq.artemis.api.jms.ActiveMQJMSClient; -import org.apache.activemq.artemis.api.jms.JMSFactoryType; -import org.apache.activemq.artemis.core.remoting.impl.netty.NettyConnectorFactory; -import org.apache.activemq.artemis.jms.client.ActiveMQConnection; -import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory; - -/** - * This cass is a base class for all the tests where we have a few utilities to start and stop servers * - */ -public abstract class ActiveMQExample -{ - protected static final Logger log = Logger.getLogger(ActiveMQExample.class.getName()); - public static final int DEFAULT_PORT = 61616; - - public static final String DEFAULT_TCP1 = "tcp://localhost:61616"; - public static final String DEFAULT_TCP2 = "tcp://localhost:61617"; - public static final String DEFAULT_TCP3 = "tcp://localhost:61618"; - public static final String DEFAULT_TCP4 = "tcp://localhost:61619"; - - protected boolean failure = false; - - protected String[] serversArgs; - - protected Process[] processes; - - - // This is to make sure we stop the servers when the example is shutdown - // as we start the servers with the example - Thread hook; - - public void run(String servers[]) - { - try - { - setupServers(servers); - if (!runExample()) - { - failure = true; - } - } - catch (Throwable throwable) - { - failure = true; - throwable.printStackTrace(); - } - finally - { - try - { - stopAllServers(); - } - catch (Throwable ignored) - { - ignored.printStackTrace(); - } - } - - reportResultAndExit(); - - } - public abstract boolean runExample() throws Exception; - - public void close() throws Exception - { - - if (hook != null) - { - Runtime.getRuntime().removeShutdownHook(hook); - hook = null; - } - stopAllServers(); - } - - /** This will start the servers */ - private final ActiveMQExample setupServers(String[] serversArgs) throws Exception - { - hook = new Thread() - { - public void run() - { - try - { - System.out.println("Shutting down servers!!!"); - System.out.flush(); - ActiveMQExample.this.stopAllServers(); - } - catch (Exception e) - { - e.printStackTrace(); - } - } - }; - - Runtime.getRuntime().addShutdownHook(hook); - this.serversArgs = serversArgs; - - if (serversArgs == null) - { - serversArgs = new String[0]; - } - - processes = new Process[serversArgs.length]; - startServers(serversArgs); - - return this; - } - - protected void startServers(String[] serversArgs) throws Exception - { - for (int i = 0; i < serversArgs.length; i++) - { - startServer(i, 5000); - } - } - - protected void stopAllServers() throws Exception - { - if (processes != null) - { - for (int i = 0; i < processes.length; i++) - { - killServer(i); - } - } - } - - protected void killServer(final int id) throws Exception - { - if (id > processes.length) - { - System.out.println("**********************************"); - System.out.println("Kill server " + id + " manually, will wait 5 seconds for that being done"); - Thread.sleep(5000); - } - - if (processes[id] != null) - { - System.out.println("**********************************"); - System.out.println("Kill server " + id); - processes[id].destroyForcibly(); - processes[id].waitFor(); -// processes[id].destroy(); - processes[id] = null; - Thread.sleep(1000); - } - } - - protected void reStartServer(final int id, final long timeout) throws Exception - { - startServer(id, timeout); - } - - protected void startServer(final int id, final long timeout) throws Exception - { - if (id > processes.length) - { - System.out.println("**********************************"); - System.out.println("Start server " + id + " manually"); - Thread.sleep(5000); - } - else - { - // if started before, will kill it - if (processes[id] != null) - { - killServer(id); - } - } - - processes[id] = ExampleUtil.startServer(serversArgs[id], "Server_" + id); - - if (timeout != 0) - { - waitForServerStart(id, timeout); - } - else - { - // just some time wait to wait server to form clusters.. etc - Thread.sleep(500); - } - } - - protected void waitForServerStart(int id, long timeoutParameter) throws InterruptedException - { - // wait for restart - long timeout = System.currentTimeMillis() + timeoutParameter; - while (System.currentTimeMillis() < timeout) - { - try - { - HashMap params = new HashMap(); - params.put("host", "localhost"); - params.put("port", DEFAULT_PORT + id); - TransportConfiguration transportConfiguration = new TransportConfiguration(NettyConnectorFactory.class.getName(), params); - ActiveMQConnectionFactory cf = ActiveMQJMSClient.createConnectionFactoryWithoutHA(JMSFactoryType.CF, transportConfiguration); - cf.createConnection().close(); - System.out.println("server " + id + " started"); - } - catch (Exception e) - { - System.out.println("awaiting server " + id + " start at " + (DEFAULT_PORT + id)); - Thread.sleep(500); - continue; - } - break; - } - } - - protected int getServer(Connection connection) - { - ClientSession session = ((ActiveMQConnection) connection).getInitialSession(); - TransportConfiguration transportConfiguration = session.getSessionFactory().getConnectorConfiguration(); - String port = (String) transportConfiguration.getParams().get("port"); - return Integer.valueOf(port) - DEFAULT_PORT; - } - - protected Connection getServerConnection(int server, Connection... connections) - { - for (Connection connection : connections) - { - ClientSession session = ((ActiveMQConnection) connection).getInitialSession(); - TransportConfiguration transportConfiguration = session.getSessionFactory().getConnectorConfiguration(); - String port = (String) transportConfiguration.getParams().get("port"); - if(Integer.valueOf(port) == server + 61616) - { - return connection; - } - } - return null; - } - - private void reportResultAndExit() - { - if (failure) - { - System.err.println(); - System.err.println("#####################"); - System.err.println("### FAILURE! ###"); - System.err.println("#####################"); - throw new RuntimeException("failure in running example"); - } - else - { - System.out.println(); - System.out.println("#####################"); - System.out.println("### SUCCESS! ###"); - System.out.println("#####################"); - } - } -} diff --git a/examples/jms/common/src/main/java/org/apache/activemq/artemis/common/example/ExampleUtil.java b/examples/jms/common/src/main/java/org/apache/activemq/artemis/common/example/ExampleUtil.java deleted file mode 100644 index b9bb25d2ff..0000000000 --- a/examples/jms/common/src/main/java/org/apache/activemq/artemis/common/example/ExampleUtil.java +++ /dev/null @@ -1,122 +0,0 @@ -/** - * 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.common.example; - -import java.io.BufferedReader; -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; - -public class ExampleUtil -{ - public static Process startServer(String artemisInstance, String serverName) throws Exception - { - boolean IS_WINDOWS = System.getProperty("os.name").toLowerCase().trim().startsWith("win"); - - ProcessBuilder builder = null; - if (IS_WINDOWS) - { - builder = new ProcessBuilder("cmd", "/c", "artemis.cmd", "run"); - } - else - { - builder = new ProcessBuilder("./artemis", "run"); - } - - builder.directory(new File(artemisInstance + "/bin")); - - Process process = builder.start(); - - ProcessLogger outputLogger = new ProcessLogger(true, - process.getInputStream(), - serverName + "::Out", - false); - outputLogger.start(); - - // Adding a reader to System.err, so the VM won't hang on a System.err.println as identified on this forum thread: - // http://www.jboss.org/index.html?module=bb&op=viewtopic&t=151815 - ProcessLogger errorLogger = new ProcessLogger(true, - process.getErrorStream(), - serverName + "::Err", - true); - errorLogger.start(); - - return process; - } - - - /** - * Redirect the input stream to a logger (as debug logs) - */ - static class ProcessLogger extends Thread - { - private final InputStream is; - - private final String logName; - - private final boolean print; - - private final boolean sendToErr; - - boolean failed = false; - - ProcessLogger(final boolean print, - final InputStream is, - final String logName, - final boolean sendToErr) throws ClassNotFoundException - { - this.is = is; - this.print = print; - this.logName = logName; - this.sendToErr = sendToErr; - setDaemon(false); - } - - @Override - public void run() - { - try - { - InputStreamReader isr = new InputStreamReader(is); - BufferedReader br = new BufferedReader(isr); - String line; - while ((line = br.readLine()) != null) - { - if (print) - { - if (sendToErr) - { - System.err.println(logName + " err:" + line); - } - else - { - System.out.println(logName + " out:" + line); - } - } - } - } - catch (IOException e) - { - // ok, stream closed - } - - } - } - -} diff --git a/examples/jms/consumer-rate-limit/pom.xml b/examples/jms/consumer-rate-limit/pom.xml index d262b3b833..b6442a009a 100644 --- a/examples/jms/consumer-rate-limit/pom.xml +++ b/examples/jms/consumer-rate-limit/pom.xml @@ -36,11 +36,6 @@ under the License. - - org.apache.activemq.examples.jms - common - ${project.version} - org.apache.geronimo.specs geronimo-jms_2.0_spec @@ -61,9 +56,18 @@ under the License. create + + + start + + cli + - ${basedir}/target/server0 - ${basedir}/target/classes/activemq/server0 + true + tcp://localhost:61616 + + run + @@ -73,8 +77,16 @@ under the License. org.apache.activemq.artemis.jms.example.ConsumerRateLimitExample + + + + stop + + cli + + - ${basedir}/target/server0 + stop diff --git a/examples/jms/consumer-rate-limit/readme.html b/examples/jms/consumer-rate-limit/readme.html index 2baefb3a0d..6492b37a4a 100644 --- a/examples/jms/consumer-rate-limit/readme.html +++ b/examples/jms/consumer-rate-limit/readme.html @@ -28,25 +28,15 @@ under the License.

JMS Message Consumer Rate Limiting

With ActiveMQ Artemis you can specify a maximum consume rate at which a JMS MessageConsumer will consume messages. - This can be specified when creating or deploying the connection factory. See activemq-jms.xml

+ This can be specified when creating or configuring the connection factory. See jndi.properties.

If this value is specified then ActiveMQ Artemis will ensure that messages are never consumed at a rate higher than - the specified rate. This is a form of consumer throttling.

+ the specified rate. This is a form of consumer throttling.

Example step-by-step

-

In this example we specify a consumer-max-rate of 10 messages per second in the activemq-jms.xml - file when deploying the connection factory:

+

In this example we specify a consumer-max-rate of 10 messages per second in the jndi.properties + file when configuring the connection factory:

      
-   <connection-factory name="ConnectionFactory">
-      <connector-ref connector-name="netty-connector"/>
-      <entries>
-         <entry name="ConnectionFactory"/>       
-      </entries>
-      
-      <!-- We limit consumers created on this connection factory to consume messages at a maximum rate
-      of 10 messages per sec -->
-      <consumer-max-rate>50</producer-max-rate>
-      
-   </connection-factory>
+connectionFactory.ConnectionFactory=tcp://localhost:61616?consumerMaxRate=10
      
      

We then simply consume as many messages as we can in 10 seconds and note how many messages are actually consumed.

@@ -89,32 +79,32 @@ under the License.
            MessageConsumer consumer = session.createConsumer(queue);
         
- +
  • Start the connection
  • - +
                
          connection.start();
                
             
    - +
  • Send a bunch of messages
  •             
          final int numMessages = 150;
    -         
    +
          for (int i = 0; i < numMessages; i++)
          {
             TextMessage message = session.createTextMessage("This is text message: " + i);
     
             producer.send(message);
    -     }           
    +     }
                
             
    - +
  • Consume as many messages as we can in 10 seconds
  • - +
                
        final long duration = 10000;
    @@ -131,7 +121,7 @@ under the License.
           {
              return false;
           }
    -      
    +
           i++;
        }
     
    @@ -141,19 +131,19 @@ under the License.
     
        System.out.println("We consumed " + i + " messages in " + (end - start) + " milliseconds");
     
    -   System.out.println("Actual consume rate was " + rate + " messages per second");           
    +   System.out.println("Actual consume rate was " + rate + " messages per second");
                
             
    - +
  • This should produce output something like:
  • - +
                
         [java] Sent messages
         [java] Will now try and consume as many as we can in 10 seconds ...
         [java] We consumed 100 messages in 10001 milliseconds
         [java] Actual consume rate was 9.99900009999 messages per second
    -                 
    +
                
             
    @@ -167,7 +157,7 @@ under the License. { initialContext.close(); } - + if (connection != null) { connection.close(); diff --git a/examples/jms/consumer-rate-limit/src/main/java/org/apache/activemq/artemis/jms/example/ConsumerRateLimitExample.java b/examples/jms/consumer-rate-limit/src/main/java/org/apache/activemq/artemis/jms/example/ConsumerRateLimitExample.java index b239ebdf07..a8a66f9f71 100644 --- a/examples/jms/consumer-rate-limit/src/main/java/org/apache/activemq/artemis/jms/example/ConsumerRateLimitExample.java +++ b/examples/jms/consumer-rate-limit/src/main/java/org/apache/activemq/artemis/jms/example/ConsumerRateLimitExample.java @@ -24,22 +24,15 @@ import javax.jms.Queue; import javax.jms.Session; import javax.jms.TextMessage; import javax.naming.InitialContext; - -import org.apache.activemq.artemis.common.example.ActiveMQExample; +import java.lang.Exception; /** * This example demonstrates how a message consumer can be limited to consumer messages at a maximum rate * specified in messages per sec. */ -public class ConsumerRateLimitExample extends ActiveMQExample +public class ConsumerRateLimitExample { - public static void main(final String[] args) - { - new ConsumerRateLimitExample().run(args); - } - - @Override - public boolean runExample() throws Exception + public static void main(final String[] args) throws Exception { Connection connection = null; InitialContext initialContext = null; @@ -100,7 +93,7 @@ public class ConsumerRateLimitExample extends ActiveMQExample if (message == null) { - return false; + throw new RuntimeException("Message was null"); } i++; @@ -113,8 +106,6 @@ public class ConsumerRateLimitExample extends ActiveMQExample System.out.println("We consumed " + i + " messages in " + (end - start) + " milliseconds"); System.out.println("Actual consume rate was " + rate + " messages per second"); - - return true; } finally { @@ -130,5 +121,4 @@ public class ConsumerRateLimitExample extends ActiveMQExample } } } - } diff --git a/examples/jms/consumer-rate-limit/src/main/resources/activemq/server0/artemis-roles.properties b/examples/jms/consumer-rate-limit/src/main/resources/activemq/server0/artemis-roles.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/consumer-rate-limit/src/main/resources/activemq/server0/artemis-roles.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/consumer-rate-limit/src/main/resources/activemq/server0/artemis-users.properties b/examples/jms/consumer-rate-limit/src/main/resources/activemq/server0/artemis-users.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/consumer-rate-limit/src/main/resources/activemq/server0/artemis-users.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/consumer-rate-limit/src/main/resources/activemq/server0/broker.xml b/examples/jms/consumer-rate-limit/src/main/resources/activemq/server0/broker.xml deleted file mode 100644 index 7690094861..0000000000 --- a/examples/jms/consumer-rate-limit/src/main/resources/activemq/server0/broker.xml +++ /dev/null @@ -1,60 +0,0 @@ - - - - - - - - - - - - - ${data.dir}/server0/data/messaging/bindings - - ${data.dir}/server0/data/messaging/journal - - ${data.dir}/server0/data/messaging/largemessages - - ${data.dir}/server0/data/messaging/paging - - - - tcp://localhost:61616 - - - - - - - - - - - - - - - - - - diff --git a/examples/jms/dead-letter/pom.xml b/examples/jms/dead-letter/pom.xml index c383d9efba..94f2c4c40e 100644 --- a/examples/jms/dead-letter/pom.xml +++ b/examples/jms/dead-letter/pom.xml @@ -36,11 +36,6 @@ under the License. - - org.apache.activemq.examples.jms - common - ${project.version} - org.apache.geronimo.specs geronimo-jms_2.0_spec @@ -61,9 +56,18 @@ under the License. create +
    + + start + + cli + - ${basedir}/target/server0 - ${basedir}/target/classes/activemq/server0 + true + tcp://localhost:61616 + + run + @@ -73,8 +77,16 @@ under the License. org.apache.activemq.artemis.jms.example.DeadLetterExample + + + + stop + + cli + + - ${basedir}/target/server0 + stop diff --git a/examples/jms/dead-letter/src/main/java/org/apache/activemq/artemis/jms/example/DeadLetterExample.java b/examples/jms/dead-letter/src/main/java/org/apache/activemq/artemis/jms/example/DeadLetterExample.java index 974e5e4dac..fb976ab70c 100644 --- a/examples/jms/dead-letter/src/main/java/org/apache/activemq/artemis/jms/example/DeadLetterExample.java +++ b/examples/jms/dead-letter/src/main/java/org/apache/activemq/artemis/jms/example/DeadLetterExample.java @@ -25,20 +25,12 @@ import javax.jms.Session; import javax.jms.TextMessage; import javax.naming.InitialContext; -import org.apache.activemq.artemis.common.example.ActiveMQExample; - /** * An example showing how messages are moved to dead letter destination when they are unsuccessfully delivered multiple times */ -public class DeadLetterExample extends ActiveMQExample +public class DeadLetterExample { - public static void main(final String[] args) - { - new DeadLetterExample().run(args); - } - - @Override - public boolean runExample() throws Exception + public static void main(final String[] args) throws Exception { Connection connection = null; InitialContext initialContext = null; @@ -115,8 +107,8 @@ public class DeadLetterExample extends ActiveMQExample // Step 20. The message sent to the queue was moved to the dead letter queue after 3 unsuccessful deliveries System.out.println("Received message from " + deadLetterQueue.getQueueName() + - ": " + - messageReceived.getText()); + ": " + + messageReceived.getText()); // The message received from the dead letter queue has the same content than the undelivered message but its // JMS headers @@ -132,8 +124,6 @@ public class DeadLetterExample extends ActiveMQExample // Step 23. This time, we commit the session, the delivery from the dead letter queue is successful! session.commit(); - - return true; } finally { @@ -148,5 +138,4 @@ public class DeadLetterExample extends ActiveMQExample } } } - } diff --git a/examples/jms/dead-letter/src/main/resources/activemq/server0/broker.xml b/examples/jms/dead-letter/src/main/resources/activemq/server0/broker.xml index 3180b7efb7..fdf88cc33f 100644 --- a/examples/jms/dead-letter/src/main/resources/activemq/server0/broker.xml +++ b/examples/jms/dead-letter/src/main/resources/activemq/server0/broker.xml @@ -32,13 +32,13 @@ under the License. - ${data.dir}/server0/data/messaging/bindings + ${data.dir:../data}/bindings - ${data.dir}/server0/data/messaging/journal + ${data.dir:../data}/journal - ${data.dir}/server0/data/messaging/largemessages + ${data.dir:../data}/largemessages - ${data.dir}/server0/data/messaging/paging + ${data.dir:../data}/paging diff --git a/examples/jms/delayed-redelivery/pom.xml b/examples/jms/delayed-redelivery/pom.xml index 4264468a00..764efdad41 100644 --- a/examples/jms/delayed-redelivery/pom.xml +++ b/examples/jms/delayed-redelivery/pom.xml @@ -36,11 +36,6 @@ under the License. - - org.apache.activemq.examples.jms - common - ${project.version} - org.apache.geronimo.specs geronimo-jms_2.0_spec @@ -61,9 +56,18 @@ under the License. create + + + start + + cli + - ${basedir}/target/server0 - ${basedir}/target/classes/activemq/server0 + true + tcp://localhost:61616 + + run + @@ -73,8 +77,16 @@ under the License. org.apache.activemq.artemis.jms.example.DelayedRedeliveryExample + + + + stop + + cli + + - ${basedir}/target/server0 + stop diff --git a/examples/jms/delayed-redelivery/src/main/java/org/apache/activemq/artemis/jms/example/DelayedRedeliveryExample.java b/examples/jms/delayed-redelivery/src/main/java/org/apache/activemq/artemis/jms/example/DelayedRedeliveryExample.java index 54e3b530e9..6a2d15d49d 100644 --- a/examples/jms/delayed-redelivery/src/main/java/org/apache/activemq/artemis/jms/example/DelayedRedeliveryExample.java +++ b/examples/jms/delayed-redelivery/src/main/java/org/apache/activemq/artemis/jms/example/DelayedRedeliveryExample.java @@ -25,23 +25,15 @@ import javax.jms.Session; import javax.jms.TextMessage; import javax.naming.InitialContext; -import org.apache.activemq.artemis.common.example.ActiveMQExample; - /** * This example demonstrates how ActiveMQ Artemis can be configured with a redelivery delay in the event a message * is redelivered. * * Please see the readme.html for more information */ -public class DelayedRedeliveryExample extends ActiveMQExample +public class DelayedRedeliveryExample { - public static void main(final String[] args) - { - new DelayedRedeliveryExample().run(args); - } - - @Override - public boolean runExample() throws Exception + public static void main(final String[] args) throws Exception { Connection connection = null; InitialContext initialContext = null; @@ -96,7 +88,7 @@ public class DelayedRedeliveryExample extends ActiveMQExample if (messageReceived != null) { - return false; + throw new IllegalStateException("Expected to recieve message."); } System.out.println("Redelivery has been delayed so received message is " + messageReceived); @@ -118,13 +110,11 @@ public class DelayedRedeliveryExample extends ActiveMQExample long end = System.currentTimeMillis(); System.out.println("3nd delivery from " + queue.getQueueName() + - ": " + - messageReceived.getText() + - " after " + - (end - start) + - " milliseconds."); - - return true; + ": " + + messageReceived.getText() + + " after " + + (end - start) + + " milliseconds."); } finally { @@ -139,5 +129,4 @@ public class DelayedRedeliveryExample extends ActiveMQExample } } } - } diff --git a/examples/jms/delayed-redelivery/src/main/resources/activemq/server0/broker.xml b/examples/jms/delayed-redelivery/src/main/resources/activemq/server0/broker.xml index d23db3d8ae..3e41664a4c 100644 --- a/examples/jms/delayed-redelivery/src/main/resources/activemq/server0/broker.xml +++ b/examples/jms/delayed-redelivery/src/main/resources/activemq/server0/broker.xml @@ -32,13 +32,13 @@ under the License. - ${data.dir}/server0/data/messaging/bindings + ${data.dir:../data}/bindings - ${data.dir}/server0/data/messaging/journal + ${data.dir:../data}/journal - ${data.dir}/server0/data/messaging/largemessages + ${data.dir:../data}/largemessages - ${data.dir}/server0/data/messaging/paging + ${data.dir:../data}/paging diff --git a/examples/jms/divert/pom.xml b/examples/jms/divert/pom.xml index 260569e353..46dfbc6177 100644 --- a/examples/jms/divert/pom.xml +++ b/examples/jms/divert/pom.xml @@ -36,11 +36,6 @@ under the License. - - org.apache.activemq.examples.jms - common - ${project.version} - org.apache.activemq artemis-server @@ -62,7 +57,7 @@ under the License. artemis-maven-plugin - create + create0 create @@ -72,7 +67,7 @@ under the License. - create2 + create1 create @@ -81,6 +76,35 @@ under the License. ${basedir}/target/classes/activemq/server1 + + start0 + + cli + + + true + tcp://localhost:61616 + + run + + server0 + + + + start1 + + cli + + + true + ${basedir}/target/server1 + tcp://localhost:61617 + + run + + server1 + + runClient @@ -88,9 +112,29 @@ under the License. org.apache.activemq.artemis.jms.example.DivertExample + + + + stop0 + + cli + + + ${basedir}/target/server0 - ${basedir}/target/server0 - ${basedir}/target/server1 + stop + + + + + stop1 + + cli + + + ${basedir}/target/server1 + + stop diff --git a/examples/jms/divert/src/main/java/org/apache/activemq/artemis/jms/example/DivertExample.java b/examples/jms/divert/src/main/java/org/apache/activemq/artemis/jms/example/DivertExample.java index 503aadde44..9cbaaa6268 100644 --- a/examples/jms/divert/src/main/java/org/apache/activemq/artemis/jms/example/DivertExample.java +++ b/examples/jms/divert/src/main/java/org/apache/activemq/artemis/jms/example/DivertExample.java @@ -28,23 +28,15 @@ import javax.jms.Topic; import javax.naming.InitialContext; import java.util.Hashtable; -import org.apache.activemq.artemis.common.example.ActiveMQExample; - /** * This examples demonstrates the use of ActiveMQ Artemis "Diverts" to transparently divert or copy messages * from one address to another. * * Please see the readme.html for more information. */ -public class DivertExample extends ActiveMQExample +public class DivertExample { - public static void main(final String[] args) - { - new DivertExample().run(args); - } - - @Override - public boolean runExample() throws Exception + public static void main(final String[] args) throws Exception { Connection connectionLondon = null; @@ -58,7 +50,7 @@ public class DivertExample extends ActiveMQExample // Step 1. Create an initial context to perform the JNDI lookup on the London server Hashtable properties = new Hashtable(); properties.put("java.naming.factory.initial", "org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory"); - properties.put("connectionFactory.ConnectionFactory", DEFAULT_TCP1); + properties.put("connectionFactory.ConnectionFactory", "tcp://localhost:61616"); properties.put("queue.queue/orders", "orders"); properties.put("topic.topic/priceUpdates", "priceUpdates"); properties.put("topic.topic/spyTopic", "spyTopic"); @@ -77,7 +69,7 @@ public class DivertExample extends ActiveMQExample // Step 6. Create an initial context to perform the JNDI lookup on the New York server properties = new Hashtable(); properties.put("java.naming.factory.initial", "org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory"); - properties.put("connectionFactory.ConnectionFactory", DEFAULT_TCP2); + properties.put("connectionFactory.ConnectionFactory2", "tcp://localhost:61617"); properties.put("topic.topic/newYorkPriceUpdates", "newYorkPriceUpdates"); initialContextNewYork = new InitialContext(properties); @@ -94,7 +86,7 @@ public class DivertExample extends ActiveMQExample ConnectionFactory cfLondon = (ConnectionFactory)initialContextLondon.lookup("ConnectionFactory"); // Step 9. Perform a lookup on the Connection Factory on the New York server - ConnectionFactory cfNewYork = (ConnectionFactory)initialContextNewYork.lookup("ConnectionFactory"); + ConnectionFactory cfNewYork = (ConnectionFactory)initialContextNewYork.lookup("ConnectionFactory2"); // Step 10. Create a JMS Connection on the London server connectionLondon = cfLondon.createConnection(); @@ -181,7 +173,7 @@ public class DivertExample extends ActiveMQExample if (priceUpdate1 != null) { - return false; + throw new IllegalStateException("Message is not null"); } System.out.println("Did not received price update in New York, look it's: " + priceUpdate1); @@ -190,7 +182,7 @@ public class DivertExample extends ActiveMQExample if (priceUpdate2 != null) { - return false; + throw new IllegalStateException("Message is not null"); } System.out.println("Did not received price update in New York, look it's: " + priceUpdate2); @@ -211,7 +203,7 @@ public class DivertExample extends ActiveMQExample if (message != null) { - return false; + throw new IllegalStateException("Message is not null"); } System.out.println("Didn't receive local price update, look, it's: " + message); @@ -231,8 +223,6 @@ public class DivertExample extends ActiveMQExample System.out.println("Received forwarded price update on server 2: " + priceUpdate2.getText()); System.out.println("Time of forward: " + priceUpdate2.getLongProperty("time_of_forward")); - - return true; } finally { @@ -255,5 +245,4 @@ public class DivertExample extends ActiveMQExample } } } - } diff --git a/examples/jms/divert/src/main/resources/activemq/server0/broker.xml b/examples/jms/divert/src/main/resources/activemq/server0/broker.xml index 7c25065111..7ce362aaaa 100644 --- a/examples/jms/divert/src/main/resources/activemq/server0/broker.xml +++ b/examples/jms/divert/src/main/resources/activemq/server0/broker.xml @@ -40,16 +40,13 @@ under the License. - + ${data.dir:../data}/bindings + ${data.dir:../data}/journal - ${data.dir}/server0/data/messaging/bindings + ${data.dir:../data}/largemessages - ${data.dir}/server0/data/messaging/journal - - ${data.dir}/server0/data/messaging/largemessages - - ${data.dir}/server0/data/messaging/paging + ${data.dir:../data}/paging diff --git a/examples/jms/divert/src/main/resources/activemq/server1/broker.xml b/examples/jms/divert/src/main/resources/activemq/server1/broker.xml index d624897313..315d13bc61 100644 --- a/examples/jms/divert/src/main/resources/activemq/server1/broker.xml +++ b/examples/jms/divert/src/main/resources/activemq/server1/broker.xml @@ -32,13 +32,13 @@ under the License. - ${data.dir}/server1/data/messaging/bindings + ${data.dir:../data}/bindings - ${data.dir}/server1/data/messaging/journal + ${data.dir:../data}/journal - ${data.dir}/server1/data/messaging/largemessages + ${data.dir:../data}/largemessages - ${data.dir}/server1/data/messaging/paging + ${data.dir:../data}/paging diff --git a/examples/jms/durable-subscription/pom.xml b/examples/jms/durable-subscription/pom.xml index 1d408de57e..9571cd8c8e 100644 --- a/examples/jms/durable-subscription/pom.xml +++ b/examples/jms/durable-subscription/pom.xml @@ -36,11 +36,6 @@ under the License. - - org.apache.activemq.examples.jms - common - ${project.version} - org.apache.geronimo.specs geronimo-jms_2.0_spec @@ -61,9 +56,18 @@ under the License. create + + + start + + cli + - ${basedir}/target/server0 - ${basedir}/target/classes/activemq/server0 + true + tcp://localhost:61616 + + run + @@ -73,8 +77,16 @@ under the License. org.apache.activemq.artemis.jms.example.DurableSubscriptionExample + + + + stop + + cli + + - ${basedir}/target/server0 + stop diff --git a/examples/jms/durable-subscription/src/main/java/org/apache/activemq/artemis/jms/example/DurableSubscriptionExample.java b/examples/jms/durable-subscription/src/main/java/org/apache/activemq/artemis/jms/example/DurableSubscriptionExample.java index c40cc699be..2a8eabf114 100644 --- a/examples/jms/durable-subscription/src/main/java/org/apache/activemq/artemis/jms/example/DurableSubscriptionExample.java +++ b/examples/jms/durable-subscription/src/main/java/org/apache/activemq/artemis/jms/example/DurableSubscriptionExample.java @@ -25,20 +25,12 @@ import javax.jms.Topic; import javax.jms.TopicSubscriber; import javax.naming.InitialContext; -import org.apache.activemq.artemis.common.example.ActiveMQExample; - /** * A simple JMS example that shows how to use a durable subscription. */ -public class DurableSubscriptionExample extends ActiveMQExample +public class DurableSubscriptionExample { - public static void main(final String[] args) - { - new DurableSubscriptionExample().run(args); - } - - @Override - public boolean runExample() throws Exception + public static void main(final String[] args) throws Exception { Connection connection = null; InitialContext initialContext = null; @@ -111,8 +103,6 @@ public class DurableSubscriptionExample extends ActiveMQExample // Step 18. Delete the durable subscription session.unsubscribe("subscriber-1"); - - return true; } finally { diff --git a/examples/jms/durable-subscription/src/main/resources/activemq/server0/broker.xml b/examples/jms/durable-subscription/src/main/resources/activemq/server0/broker.xml index 6b661e4d37..2b2ba2e1fb 100644 --- a/examples/jms/durable-subscription/src/main/resources/activemq/server0/broker.xml +++ b/examples/jms/durable-subscription/src/main/resources/activemq/server0/broker.xml @@ -29,13 +29,13 @@ under the License. - ${data.dir}/server0/data/messaging/bindings + ${data.dir:../data}/bindings - ${data.dir}/server0/data/messaging/journal + ${data.dir:../data}/journal - ${data.dir}/server0/data/messaging/largemessages + ${data.dir:../data}/largemessages - ${data.dir}/server0/data/messaging/paging + ${data.dir:../data}/paging diff --git a/examples/jms/embedded-simple/pom.xml b/examples/jms/embedded-simple/pom.xml index 9836ff6670..a1dae0930b 100644 --- a/examples/jms/embedded-simple/pom.xml +++ b/examples/jms/embedded-simple/pom.xml @@ -36,11 +36,6 @@ under the License. - - org.apache.activemq.examples.jms - common - ${project.version} - org.apache.activemq artemis-server diff --git a/examples/jms/embedded-simple/src/main/java/org/apache/activemq/artemis/jms/example/EmbeddedExample.java b/examples/jms/embedded-simple/src/main/java/org/apache/activemq/artemis/jms/example/EmbeddedExample.java index c148dca651..2bf15a2a39 100644 --- a/examples/jms/embedded-simple/src/main/java/org/apache/activemq/artemis/jms/example/EmbeddedExample.java +++ b/examples/jms/embedded-simple/src/main/java/org/apache/activemq/artemis/jms/example/EmbeddedExample.java @@ -16,6 +16,12 @@ */ package org.apache.activemq.artemis.jms.example; +import org.apache.activemq.artemis.api.jms.JMSFactoryType; +import org.apache.activemq.artemis.core.config.impl.SecurityConfiguration; +import org.apache.activemq.artemis.jms.server.JMSServerManager; +import org.apache.activemq.artemis.jms.server.embedded.EmbeddedJMS; +import org.apache.activemq.artemis.spi.core.security.ActiveMQSecurityManagerImpl; + import javax.jms.Connection; import javax.jms.ConnectionFactory; import javax.jms.MessageConsumer; @@ -27,81 +33,58 @@ import java.util.ArrayList; import java.util.Date; import java.util.List; -import org.apache.activemq.artemis.api.jms.JMSFactoryType; -import org.apache.activemq.artemis.common.example.ActiveMQExample; -import org.apache.activemq.artemis.core.config.impl.SecurityConfiguration; -import org.apache.activemq.artemis.jms.server.JMSServerManager; -import org.apache.activemq.artemis.jms.server.embedded.EmbeddedJMS; -import org.apache.activemq.artemis.spi.core.security.ActiveMQSecurityManagerImpl; - /** * This example demonstrates how to run an ActiveMQ Artemis embedded with JMS */ -public class EmbeddedExample extends ActiveMQExample +public class EmbeddedExample { - public static void main(final String[] args) throws Exception { - new EmbeddedExample().runExample(); - } + EmbeddedJMS jmsServer = new EmbeddedJMS(); - @Override - public boolean runExample() throws Exception - { + SecurityConfiguration securityConfig = new SecurityConfiguration(); + securityConfig.addUser("guest", "guest"); + securityConfig.addRole("guest", "guest"); + securityConfig.setDefaultUser("guest"); + jmsServer.setSecurityManager(new ActiveMQSecurityManagerImpl(securityConfig)); + + jmsServer.start(); + System.out.println("Started Embedded JMS Server"); + + JMSServerManager jmsServerManager = jmsServer.getJMSServerManager(); + List connectors = new ArrayList(); + connectors.add("in-vm"); + jmsServerManager.createConnectionFactory("ConnectionFactory", false, JMSFactoryType.CF, connectors, "ConnectionFactory"); + jmsServerManager.createQueue(false, "exampleQueue", null, false, "queue/exampleQueue"); + + ConnectionFactory cf = (ConnectionFactory) jmsServer.lookup("ConnectionFactory"); + Queue queue = (Queue) jmsServer.lookup("queue/exampleQueue"); + + // Step 10. Send and receive a message using JMS API + Connection connection = null; try { - EmbeddedJMS jmsServer = new EmbeddedJMS(); - - SecurityConfiguration securityConfig = new SecurityConfiguration(); - securityConfig.addUser("guest", "guest"); - securityConfig.addRole("guest", "guest"); - securityConfig.setDefaultUser("guest"); - jmsServer.setSecurityManager(new ActiveMQSecurityManagerImpl(securityConfig)); - - jmsServer.start(); - System.out.println("Started Embedded JMS Server"); - - JMSServerManager jmsServerManager = jmsServer.getJMSServerManager(); - List connectors = new ArrayList(); - connectors.add("in-vm"); - jmsServerManager.createConnectionFactory("ConnectionFactory", false, JMSFactoryType.CF, connectors, "ConnectionFactory"); - jmsServerManager.createQueue(false, "exampleQueue", null, false, "queue/exampleQueue"); - - ConnectionFactory cf = (ConnectionFactory)jmsServer.lookup("ConnectionFactory"); - Queue queue = (Queue)jmsServer.lookup("queue/exampleQueue"); - - // Step 10. Send and receive a message using JMS API - Connection connection = null; - try - { - connection = cf.createConnection(); - Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); - MessageProducer producer = session.createProducer(queue); - TextMessage message = session.createTextMessage("Hello sent at " + new Date()); - System.out.println("Sending message: " + message.getText()); - producer.send(message); - MessageConsumer messageConsumer = session.createConsumer(queue); - connection.start(); - TextMessage messageReceived = (TextMessage)messageConsumer.receive(1000); - System.out.println("Received message:" + messageReceived.getText()); - } - finally - { - if (connection != null) - { - connection.close(); - } - - // Step 11. Stop the JMS server - jmsServer.stop(); - System.out.println("Stopped the JMS Server"); - } + connection = cf.createConnection(); + Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); + MessageProducer producer = session.createProducer(queue); + TextMessage message = session.createTextMessage("Hello sent at " + new Date()); + System.out.println("Sending message: " + message.getText()); + producer.send(message); + MessageConsumer messageConsumer = session.createConsumer(queue); + connection.start(); + TextMessage messageReceived = (TextMessage) messageConsumer.receive(1000); + System.out.println("Received message:" + messageReceived.getText()); } - catch (Exception e) + finally { - e.printStackTrace(); - return false; + if (connection != null) + { + connection.close(); + } + + // Step 11. Stop the JMS server + jmsServer.stop(); + System.out.println("Stopped the JMS Server"); } - return true; } } diff --git a/examples/jms/embedded/pom.xml b/examples/jms/embedded/pom.xml index e39c4a46c0..8d81f45394 100644 --- a/examples/jms/embedded/pom.xml +++ b/examples/jms/embedded/pom.xml @@ -36,11 +36,6 @@ under the License. - - org.apache.activemq.examples.jms - common - ${project.version} - org.apache.activemq artemis-server diff --git a/examples/jms/embedded/src/main/java/org/apache/activemq/artemis/jms/example/EmbeddedExample.java b/examples/jms/embedded/src/main/java/org/apache/activemq/artemis/jms/example/EmbeddedExample.java index 0c029adf13..2a97c0f3b6 100644 --- a/examples/jms/embedded/src/main/java/org/apache/activemq/artemis/jms/example/EmbeddedExample.java +++ b/examples/jms/embedded/src/main/java/org/apache/activemq/artemis/jms/example/EmbeddedExample.java @@ -27,7 +27,6 @@ import java.util.ArrayList; import java.util.Date; import org.apache.activemq.artemis.api.core.TransportConfiguration; -import org.apache.activemq.artemis.common.example.ActiveMQExample; import org.apache.activemq.artemis.core.config.Configuration; import org.apache.activemq.artemis.core.config.impl.ConfigurationImpl; import org.apache.activemq.artemis.core.remoting.impl.netty.NettyAcceptorFactory; @@ -43,95 +42,78 @@ import org.apache.activemq.artemis.jms.server.embedded.EmbeddedJMS; /** * This example demonstrates how to run an ActiveMQ Artemis embedded with JMS */ -public final class EmbeddedExample extends ActiveMQExample +public final class EmbeddedExample { public static void main(final String[] args) throws Exception { - new EmbeddedExample().runExample(); - } + // Step 1. Create ActiveMQ Artemis core configuration, and set the properties accordingly + Configuration configuration = new ConfigurationImpl(); + configuration.setPersistenceEnabled(false); + configuration.setJournalDirectory("target/data/journal"); + configuration.setSecurityEnabled(false); + configuration.getAcceptorConfigurations().add(new TransportConfiguration(NettyAcceptorFactory.class.getName())); - @Override - public boolean runExample() throws Exception - { + TransportConfiguration connectorConfig = new TransportConfiguration(NettyConnectorFactory.class.getName()); + + configuration.getConnectorConfigurations().put("connector", connectorConfig); + + + // Step 2. Create the JMS configuration + JMSConfiguration jmsConfig = new JMSConfigurationImpl(); + + // Step 3. Configure the JMS ConnectionFactory + ArrayList connectorNames = new ArrayList(); + connectorNames.add("connector"); + ConnectionFactoryConfiguration cfConfig = new ConnectionFactoryConfigurationImpl() + .setName("cf") + .setConnectorNames(connectorNames) + .setBindings("cf"); + jmsConfig.getConnectionFactoryConfigurations().add(cfConfig); + + // Step 4. Configure the JMS Queue + JMSQueueConfiguration queueConfig = new JMSQueueConfigurationImpl() + .setName("queue1") + .setDurable(false) + .setBindings("queue/queue1"); + jmsConfig.getQueueConfigurations().add(queueConfig); + + // Step 5. Start the JMS Server using the ActiveMQ Artemis core server and the JMS configuration + EmbeddedJMS jmsServer = new EmbeddedJMS(); + jmsServer.setConfiguration(configuration); + jmsServer.setJmsConfiguration(jmsConfig); + jmsServer.start(); + System.out.println("Started Embedded JMS Server"); + + // Step 6. Lookup JMS resources defined in the configuration + ConnectionFactory cf = (ConnectionFactory) jmsServer.lookup("cf"); + Queue queue = (Queue) jmsServer.lookup("queue/queue1"); + + // Step 7. Send and receive a message using JMS API + Connection connection = null; try { - - // Step 1. Create ActiveMQ Artemis core configuration, and set the properties accordingly - Configuration configuration = new ConfigurationImpl(); - configuration.setPersistenceEnabled(false); - configuration.setJournalDirectory("target/data/journal"); - configuration.setSecurityEnabled(false); - configuration.getAcceptorConfigurations() - .add(new TransportConfiguration(NettyAcceptorFactory.class.getName())); - - TransportConfiguration connectorConfig = new TransportConfiguration(NettyConnectorFactory.class.getName()); - - configuration.getConnectorConfigurations().put("connector", connectorConfig); - - - // Step 2. Create the JMS configuration - JMSConfiguration jmsConfig = new JMSConfigurationImpl(); - - // Step 3. Configure the JMS ConnectionFactory - ArrayList connectorNames = new ArrayList(); - connectorNames.add("connector"); - ConnectionFactoryConfiguration cfConfig = new ConnectionFactoryConfigurationImpl() - .setName("cf") - .setConnectorNames(connectorNames) - .setBindings("cf"); - jmsConfig.getConnectionFactoryConfigurations().add(cfConfig); - - // Step 4. Configure the JMS Queue - JMSQueueConfiguration queueConfig = new JMSQueueConfigurationImpl() - .setName("queue1") - .setDurable(false) - .setBindings("queue/queue1"); - jmsConfig.getQueueConfigurations().add(queueConfig); - - // Step 5. Start the JMS Server using the ActiveMQ Artemis core server and the JMS configuration - EmbeddedJMS jmsServer = new EmbeddedJMS(); - jmsServer.setConfiguration(configuration); - jmsServer.setJmsConfiguration(jmsConfig); - jmsServer.start(); - System.out.println("Started Embedded JMS Server"); - - // Step 6. Lookup JMS resources defined in the configuration - ConnectionFactory cf = (ConnectionFactory)jmsServer.lookup("cf"); - Queue queue = (Queue)jmsServer.lookup("queue/queue1"); - - // Step 7. Send and receive a message using JMS API - Connection connection = null; - try - { - connection = cf.createConnection(); - Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); - MessageProducer producer = session.createProducer(queue); - TextMessage message = session.createTextMessage("Hello sent at " + new Date()); - System.out.println("Sending message: " + message.getText()); - producer.send(message); - MessageConsumer messageConsumer = session.createConsumer(queue); - connection.start(); - TextMessage messageReceived = (TextMessage)messageConsumer.receive(1000); - System.out.println("Received message:" + messageReceived.getText()); - } - finally - { - if (connection != null) - { - connection.close(); - } - - // Step 11. Stop the JMS server - jmsServer.stop(); - System.out.println("Stopped the JMS Server"); - } + connection = cf.createConnection(); + Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); + MessageProducer producer = session.createProducer(queue); + TextMessage message = session.createTextMessage("Hello sent at " + new Date()); + System.out.println("Sending message: " + message.getText()); + producer.send(message); + MessageConsumer messageConsumer = session.createConsumer(queue); + connection.start(); + TextMessage messageReceived = (TextMessage) messageConsumer.receive(1000); + System.out.println("Received message:" + messageReceived.getText()); } - catch (Exception e) + finally { - e.printStackTrace(); - return false; + if (connection != null) + { + connection.close(); + } + + // Step 11. Stop the JMS server + jmsServer.stop(); + System.out.println("Stopped the JMS Server"); } - return true; } } diff --git a/examples/jms/expiry/pom.xml b/examples/jms/expiry/pom.xml index 6133af4dfe..9c539996c4 100644 --- a/examples/jms/expiry/pom.xml +++ b/examples/jms/expiry/pom.xml @@ -36,11 +36,6 @@ under the License. - - org.apache.activemq.examples.jms - common - ${project.version} - org.apache.geronimo.specs geronimo-jms_2.0_spec @@ -61,9 +56,18 @@ under the License. create + + + start + + cli + - ${basedir}/target/server0 - ${basedir}/target/classes/activemq/server0 + true + tcp://localhost:61616 + + run + @@ -73,8 +77,16 @@ under the License. org.apache.activemq.artemis.jms.example.ExpiryExample + + + + stop + + cli + + - ${basedir}/target/server0 + stop diff --git a/examples/jms/expiry/src/main/java/org/apache/activemq/artemis/jms/example/ExpiryExample.java b/examples/jms/expiry/src/main/java/org/apache/activemq/artemis/jms/example/ExpiryExample.java index 026458c629..dfb4324fd4 100644 --- a/examples/jms/expiry/src/main/java/org/apache/activemq/artemis/jms/example/ExpiryExample.java +++ b/examples/jms/expiry/src/main/java/org/apache/activemq/artemis/jms/example/ExpiryExample.java @@ -25,20 +25,12 @@ import javax.jms.Session; import javax.jms.TextMessage; import javax.naming.InitialContext; -import org.apache.activemq.artemis.common.example.ActiveMQExample; - /** * An example showing how messages are moved to an expiry queue when they expire. */ -public class ExpiryExample extends ActiveMQExample +public class ExpiryExample { - public static void main(final String[] args) - { - new ExpiryExample().run(args); - } - - @Override - public boolean runExample() throws Exception + public static void main(final String[] args) throws Exception { Connection connection = null; InitialContext initialContext = null; @@ -116,8 +108,6 @@ public class ExpiryExample extends ActiveMQExample System.out.println("*Origin destination* of the expired message: " + messageReceived.getStringProperty("_AMQ_ORIG_ADDRESS")); // Step 21. the actual expiration time is stored in the _AMQ_ACTUAL_EXPIRY property System.out.println("*Actual expiration time* of the expired message: " + messageReceived.getLongProperty("_AMQ_ACTUAL_EXPIRY")); - - return true; } finally { @@ -132,5 +122,4 @@ public class ExpiryExample extends ActiveMQExample } } } - } diff --git a/examples/jms/expiry/src/main/resources/activemq/server0/broker.xml b/examples/jms/expiry/src/main/resources/activemq/server0/broker.xml index 3333732716..49070974c1 100644 --- a/examples/jms/expiry/src/main/resources/activemq/server0/broker.xml +++ b/examples/jms/expiry/src/main/resources/activemq/server0/broker.xml @@ -32,13 +32,13 @@ under the License. - ${data.dir}/server0/data/messaging/bindings + ${data.dir:../data}/bindings - ${data.dir}/server0/data/messaging/journal + ${data.dir:../data}/journal - ${data.dir}/server0/data/messaging/largemessages + ${data.dir:../data}/largemessages - ${data.dir}/server0/data/messaging/paging + ${data.dir:../data}/paging diff --git a/examples/jms/ha-policy-autobackup/pom.xml b/examples/jms/ha-policy-autobackup/pom.xml index 649adf06ec..cace530748 100644 --- a/examples/jms/ha-policy-autobackup/pom.xml +++ b/examples/jms/ha-policy-autobackup/pom.xml @@ -37,8 +37,8 @@ under the License. - org.apache.activemq.examples.jms - common + org.apache.activemq + artemis-cli ${project.version} diff --git a/examples/jms/ha-policy-autobackup/src/main/java/org/apache/activemq/artemis/jms/example/HAPolicyAutoBackupExample.java b/examples/jms/ha-policy-autobackup/src/main/java/org/apache/activemq/artemis/jms/example/HAPolicyAutoBackupExample.java index 10f858f9bd..d56175068e 100644 --- a/examples/jms/ha-policy-autobackup/src/main/java/org/apache/activemq/artemis/jms/example/HAPolicyAutoBackupExample.java +++ b/examples/jms/ha-policy-autobackup/src/main/java/org/apache/activemq/artemis/jms/example/HAPolicyAutoBackupExample.java @@ -16,6 +16,12 @@ */ package org.apache.activemq.artemis.jms.example; +import org.apache.activemq.artemis.api.core.TransportConfiguration; +import org.apache.activemq.artemis.api.core.client.ClusterTopologyListener; +import org.apache.activemq.artemis.api.core.client.TopologyMember; +import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory; +import org.apache.activemq.artemis.util.ServerUtil; + import javax.jms.Connection; import javax.jms.ConnectionFactory; import javax.jms.MessageConsumer; @@ -30,26 +36,17 @@ import java.util.List; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; -import org.apache.activemq.artemis.api.core.TransportConfiguration; -import org.apache.activemq.artemis.api.core.client.ClusterTopologyListener; -import org.apache.activemq.artemis.api.core.client.TopologyMember; -import org.apache.activemq.artemis.common.example.ActiveMQExample; -import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory; - /** * A simple example that demonstrates server side load-balancing of messages between the queue instances on different * nodes of the cluster. - * */ -public class HAPolicyAutoBackupExample extends ActiveMQExample +public class HAPolicyAutoBackupExample { - public static void main(final String[] args) throws Exception - { - new HAPolicyAutoBackupExample().run(args); - } + private static Process server0; - @Override - public boolean runExample() throws Exception + private static Process server1; + + public static void main(final String[] args) throws Exception { Connection connection0 = null; @@ -61,16 +58,19 @@ public class HAPolicyAutoBackupExample extends ActiveMQExample try { + server0 = ServerUtil.startServer(args[0], HAPolicyAutoBackupExample.class.getSimpleName() + "0", 0, 5000); + server1 = ServerUtil.startServer(args[1], HAPolicyAutoBackupExample.class.getSimpleName() + "1", 1, 5000); + // Step 1. Get an initial context for looking up JNDI from server 0 and 1 Hashtable properties = new Hashtable(); properties.put("java.naming.factory.initial", "org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory"); - properties.put("connectionFactory.ConnectionFactory", DEFAULT_TCP1 + "?ha=true&retryInterval=1000&retryIntervalMultiplier=1.0&reconnectAttempts=-1"); + properties.put("connectionFactory.ConnectionFactory", "tcp://localhost:61616?ha=true&retryInterval=1000&retryIntervalMultiplier=1.0&reconnectAttempts=-1"); properties.put("queue.queue/exampleQueue", "exampleQueue"); ic0 = new InitialContext(properties); properties = new Hashtable(); properties.put("java.naming.factory.initial", "org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory"); - properties.put("connectionFactory.ConnectionFactory", DEFAULT_TCP2 + "?ha=true&retryInterval=1000&retryIntervalMultiplier=1.0&reconnectAttempts=-1"); + properties.put("connectionFactory.ConnectionFactory", "tcp://localhost:61617?ha=true&retryInterval=1000&retryIntervalMultiplier=1.0&reconnectAttempts=-1"); ic1 = new InitialContext(properties); // Step 2. Look-up the JMS Queue object from JNDI @@ -99,7 +99,6 @@ public class HAPolicyAutoBackupExample extends ActiveMQExample MessageConsumer consumer0 = session0.createConsumer(queue); MessageConsumer consumer1 = session1.createConsumer(queue); - // Step 11. We create a JMS MessageProducer object on server 0 MessageProducer producer = session0.createProducer(queue); @@ -129,7 +128,7 @@ public class HAPolicyAutoBackupExample extends ActiveMQExample consumer1.close(); // Step 15.now kill server1, messages will be scaled down to server0 - killServer(1); + ServerUtil.killServer(server1); Thread.sleep(40000); // Step 16. we now receive the messages that were on server1 but were scaled down to server0 @@ -139,8 +138,6 @@ public class HAPolicyAutoBackupExample extends ActiveMQExample System.out.println("Got message: " + message0.getText() + " from node 1"); } - - return true; } finally { @@ -155,10 +152,13 @@ public class HAPolicyAutoBackupExample extends ActiveMQExample { connection1.close(); } + + ServerUtil.killServer(server0); + ServerUtil.killServer(server1); } } - private void waitForBackups(ConnectionFactory cf0, int backups) throws InterruptedException + private static void waitForBackups(ConnectionFactory cf0, int backups) throws InterruptedException { final CountDownLatch latch = new CountDownLatch(backups); ((ActiveMQConnectionFactory) cf0).getServerLocator().addClusterTopologyListener(new ClusterTopologyListener() @@ -181,5 +181,4 @@ public class HAPolicyAutoBackupExample extends ActiveMQExample }); latch.await(30000, TimeUnit.MILLISECONDS); } - } diff --git a/examples/jms/ha-policy-autobackup/src/main/resources/activemq/server0/artemis-roles.properties b/examples/jms/ha-policy-autobackup/src/main/resources/activemq/server0/artemis-roles.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/ha-policy-autobackup/src/main/resources/activemq/server0/artemis-roles.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/ha-policy-autobackup/src/main/resources/activemq/server0/artemis-users.properties b/examples/jms/ha-policy-autobackup/src/main/resources/activemq/server0/artemis-users.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/ha-policy-autobackup/src/main/resources/activemq/server0/artemis-users.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/ha-policy-autobackup/src/main/resources/activemq/server1/artemis-roles.properties b/examples/jms/ha-policy-autobackup/src/main/resources/activemq/server1/artemis-roles.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/ha-policy-autobackup/src/main/resources/activemq/server1/artemis-roles.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/ha-policy-autobackup/src/main/resources/activemq/server1/artemis-users.properties b/examples/jms/ha-policy-autobackup/src/main/resources/activemq/server1/artemis-users.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/ha-policy-autobackup/src/main/resources/activemq/server1/artemis-users.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/http-transport/pom.xml b/examples/jms/http-transport/pom.xml index b13f8009b6..0d9c91d2c5 100644 --- a/examples/jms/http-transport/pom.xml +++ b/examples/jms/http-transport/pom.xml @@ -36,11 +36,6 @@ under the License. - - org.apache.activemq.examples.jms - common - ${project.version} - org.apache.geronimo.specs geronimo-jms_2.0_spec @@ -61,9 +56,18 @@ under the License. create + + + start + + cli + - ${basedir}/target/server0 - ${basedir}/target/classes/activemq/server0 + true + tcp://localhost:8080?http-enabled=true + + run + @@ -73,8 +77,16 @@ under the License. org.apache.activemq.artemis.jms.example.HttpTransportExample + + + + stop + + cli + + - ${basedir}/target/server0 + stop diff --git a/examples/jms/http-transport/src/main/java/org/apache/activemq/artemis/jms/example/HttpTransportExample.java b/examples/jms/http-transport/src/main/java/org/apache/activemq/artemis/jms/example/HttpTransportExample.java index 834800798e..cd2e17529d 100644 --- a/examples/jms/http-transport/src/main/java/org/apache/activemq/artemis/jms/example/HttpTransportExample.java +++ b/examples/jms/http-transport/src/main/java/org/apache/activemq/artemis/jms/example/HttpTransportExample.java @@ -25,20 +25,12 @@ import javax.jms.Session; import javax.jms.TextMessage; import javax.naming.InitialContext; -import org.apache.activemq.artemis.common.example.ActiveMQExample; - /** * A simple JMS Queue example that uses HTTP protocol. */ -public class HttpTransportExample extends ActiveMQExample +public class HttpTransportExample { - public static void main(final String[] args) - { - new HttpTransportExample().run(args); - } - - @Override - public boolean runExample() throws Exception + public static void main(final String[] args) throws Exception { Connection connection = null; InitialContext initialContext = null; @@ -84,8 +76,6 @@ public class HttpTransportExample extends ActiveMQExample System.out.println("Received message: " + messageReceived.getText()); initialContext.close(); - - return true; } finally { @@ -100,5 +90,4 @@ public class HttpTransportExample extends ActiveMQExample } } } - } diff --git a/examples/jms/http-transport/src/main/resources/activemq/server0/broker.xml b/examples/jms/http-transport/src/main/resources/activemq/server0/broker.xml index f6062b638a..ea39ccd01f 100644 --- a/examples/jms/http-transport/src/main/resources/activemq/server0/broker.xml +++ b/examples/jms/http-transport/src/main/resources/activemq/server0/broker.xml @@ -29,20 +29,18 @@ under the License. - ${data.dir}/server0/data/messaging/bindings + ${data.dir:../data}/bindings - ${data.dir}/server0/data/messaging/journal + ${data.dir:../data}/journal - ${data.dir}/server0/data/messaging/largemessages + ${data.dir:../data}/largemessages - ${data.dir}/server0/data/messaging/paging + ${data.dir:../data}/paging tcp://localhost:8080 - - tcp://localhost:61616 diff --git a/examples/jms/instantiate-connection-factory/pom.xml b/examples/jms/instantiate-connection-factory/pom.xml index 17e55431eb..774b2b2a98 100644 --- a/examples/jms/instantiate-connection-factory/pom.xml +++ b/examples/jms/instantiate-connection-factory/pom.xml @@ -36,11 +36,6 @@ under the License. - - org.apache.activemq.examples.jms - common - ${project.version} - org.apache.activemq artemis-core-client @@ -71,9 +66,18 @@ under the License. create + + + start + + cli + - ${basedir}/target/server0 - ${basedir}/target/classes/activemq/server0 + true + tcp://localhost:61616 + + run + @@ -83,8 +87,16 @@ under the License. org.apache.activemq.artemis.jms.example.InstantiateConnectionFactoryExample + + + + stop + + cli + + - ${basedir}/target/server0 + stop diff --git a/examples/jms/instantiate-connection-factory/src/main/java/org/apache/activemq/artemis/jms/example/InstantiateConnectionFactoryExample.java b/examples/jms/instantiate-connection-factory/src/main/java/org/apache/activemq/artemis/jms/example/InstantiateConnectionFactoryExample.java index 85ee7d9525..b0acce48b3 100644 --- a/examples/jms/instantiate-connection-factory/src/main/java/org/apache/activemq/artemis/jms/example/InstantiateConnectionFactoryExample.java +++ b/examples/jms/instantiate-connection-factory/src/main/java/org/apache/activemq/artemis/jms/example/InstantiateConnectionFactoryExample.java @@ -29,7 +29,6 @@ import java.util.Map; import org.apache.activemq.artemis.api.core.TransportConfiguration; import org.apache.activemq.artemis.api.jms.ActiveMQJMSClient; import org.apache.activemq.artemis.api.jms.JMSFactoryType; -import org.apache.activemq.artemis.common.example.ActiveMQExample; import org.apache.activemq.artemis.core.remoting.impl.netty.NettyConnectorFactory; import org.apache.activemq.artemis.core.remoting.impl.netty.TransportConstants; @@ -40,15 +39,9 @@ import org.apache.activemq.artemis.core.remoting.impl.netty.TransportConstants; * * For more information please see the readme.html file. */ -public class InstantiateConnectionFactoryExample extends ActiveMQExample +public class InstantiateConnectionFactoryExample { - public static void main(final String[] args) - { - new InstantiateConnectionFactoryExample().run(args); - } - - @Override - public boolean runExample() throws Exception + public static void main(final String[] args) throws Exception { Connection connection = null; try @@ -95,8 +88,6 @@ public class InstantiateConnectionFactoryExample extends ActiveMQExample TextMessage messageReceived = (TextMessage)messageConsumer.receive(5000); System.out.println("Received message: " + messageReceived.getText()); - - return true; } finally { @@ -106,5 +97,4 @@ public class InstantiateConnectionFactoryExample extends ActiveMQExample } } } - } diff --git a/examples/jms/instantiate-connection-factory/src/main/resources/activemq/server0/artemis-roles.properties b/examples/jms/instantiate-connection-factory/src/main/resources/activemq/server0/artemis-roles.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/instantiate-connection-factory/src/main/resources/activemq/server0/artemis-roles.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/instantiate-connection-factory/src/main/resources/activemq/server0/artemis-users.properties b/examples/jms/instantiate-connection-factory/src/main/resources/activemq/server0/artemis-users.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/instantiate-connection-factory/src/main/resources/activemq/server0/artemis-users.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/instantiate-connection-factory/src/main/resources/activemq/server0/broker.xml b/examples/jms/instantiate-connection-factory/src/main/resources/activemq/server0/broker.xml deleted file mode 100644 index 7690094861..0000000000 --- a/examples/jms/instantiate-connection-factory/src/main/resources/activemq/server0/broker.xml +++ /dev/null @@ -1,60 +0,0 @@ - - - - - - - - - - - - - ${data.dir}/server0/data/messaging/bindings - - ${data.dir}/server0/data/messaging/journal - - ${data.dir}/server0/data/messaging/largemessages - - ${data.dir}/server0/data/messaging/paging - - - - tcp://localhost:61616 - - - - - - - - - - - - - - - - - - diff --git a/examples/jms/interceptor/pom.xml b/examples/jms/interceptor/pom.xml index 5d7a2a0953..530a7b9e0a 100644 --- a/examples/jms/interceptor/pom.xml +++ b/examples/jms/interceptor/pom.xml @@ -36,11 +36,6 @@ under the License. - - org.apache.activemq.examples.jms - common - ${project.version} - org.apache.activemq artemis-jms-client @@ -66,9 +61,18 @@ under the License. create + + + start + + cli + - ${basedir}/target/server0 - ${basedir}/target/classes/activemq/server0 + true + tcp://localhost:61616 + + run + @@ -78,8 +82,16 @@ under the License. org.apache.activemq.artemis.jms.example.InterceptorExample + + + + stop + + cli + + - ${basedir}/target/server0 + stop diff --git a/examples/jms/interceptor/src/main/java/org/apache/activemq/artemis/jms/example/InterceptorExample.java b/examples/jms/interceptor/src/main/java/org/apache/activemq/artemis/jms/example/InterceptorExample.java index f6e8d999dd..1a277268d7 100644 --- a/examples/jms/interceptor/src/main/java/org/apache/activemq/artemis/jms/example/InterceptorExample.java +++ b/examples/jms/interceptor/src/main/java/org/apache/activemq/artemis/jms/example/InterceptorExample.java @@ -25,20 +25,12 @@ import javax.jms.Session; import javax.jms.TextMessage; import javax.naming.InitialContext; -import org.apache.activemq.artemis.common.example.ActiveMQExample; - /** * A simple JMS example that shows how to implement and use interceptors with ActiveMQ Artemis. */ -public class InterceptorExample extends ActiveMQExample +public class InterceptorExample { - public static void main(final String[] args) - { - new InterceptorExample().run(args); - } - - @Override - public boolean runExample() throws Exception + public static void main(final String[] args) throws Exception { Connection connection = null; InitialContext initialContext = null; @@ -66,8 +58,8 @@ public class InterceptorExample extends ActiveMQExample TextMessage message = session.createTextMessage("This is a text message"); System.out.println("Sending message [" + message.getText() + - "] with String property: " + - message.getStringProperty("newproperty")); + "] with String property: " + + message.getStringProperty("newproperty")); // Step 8. Send the Message producer.send(message); @@ -82,10 +74,8 @@ public class InterceptorExample extends ActiveMQExample TextMessage messageReceived = (TextMessage)messageConsumer.receive(5000); System.out.println("Received message [" + messageReceived.getText() + - "] with String property: " + - messageReceived.getStringProperty("newproperty")); - - return true; + "] with String property: " + + messageReceived.getStringProperty("newproperty")); } finally { @@ -100,5 +90,4 @@ public class InterceptorExample extends ActiveMQExample } } } - } diff --git a/examples/jms/interceptor/src/main/resources/activemq/server0/broker.xml b/examples/jms/interceptor/src/main/resources/activemq/server0/broker.xml index 1ff8a1fc83..fc82158db4 100644 --- a/examples/jms/interceptor/src/main/resources/activemq/server0/broker.xml +++ b/examples/jms/interceptor/src/main/resources/activemq/server0/broker.xml @@ -29,13 +29,13 @@ under the License. - ${data.dir}/server0/data/messaging/bindings + ${data.dir:../data}/bindings - ${data.dir}/server0/data/messaging/journal + ${data.dir:../data}/journal - ${data.dir}/server0/data/messaging/largemessages + ${data.dir:../data}/largemessages - ${data.dir}/server0/data/messaging/paging + ${data.dir:../data}/paging diff --git a/examples/jms/jms-auto-closeable/pom.xml b/examples/jms/jms-auto-closeable/pom.xml index 6cceae6798..17376ab6a8 100644 --- a/examples/jms/jms-auto-closeable/pom.xml +++ b/examples/jms/jms-auto-closeable/pom.xml @@ -36,11 +36,6 @@ under the License. - - org.apache.activemq.examples.jms - common - ${project.version} - org.apache.geronimo.specs geronimo-jms_2.0_spec @@ -61,9 +56,18 @@ under the License. create + + + start + + cli + - ${basedir}/target/server0 - ${basedir}/target/classes/activemq/server0 + true + tcp://localhost:61616 + + run + @@ -73,8 +77,16 @@ under the License. org.apache.activemq.artemis.jms.example.JMSAutoCloseableExample + + + + stop + + cli + + - ${basedir}/target/server0 + stop diff --git a/examples/jms/jms-auto-closeable/src/main/java/org/apache/activemq/artemis/jms/example/JMSAutoCloseableExample.java b/examples/jms/jms-auto-closeable/src/main/java/org/apache/activemq/artemis/jms/example/JMSAutoCloseableExample.java index 68bd1eb0c3..555e8ff1d1 100644 --- a/examples/jms/jms-auto-closeable/src/main/java/org/apache/activemq/artemis/jms/example/JMSAutoCloseableExample.java +++ b/examples/jms/jms-auto-closeable/src/main/java/org/apache/activemq/artemis/jms/example/JMSAutoCloseableExample.java @@ -18,21 +18,14 @@ package org.apache.activemq.artemis.jms.example; import javax.jms.*; import javax.naming.InitialContext; - -import org.apache.activemq.artemis.common.example.ActiveMQExample; +import java.lang.Exception; /** * A simple JMS example that shows how AutoCloseable is used by JMS 2 resources. */ -public class JMSAutoCloseableExample extends ActiveMQExample +public class JMSAutoCloseableExample { - public static void main(final String[] args) - { - new JMSAutoCloseableExample().run(args); - } - - @Override - public boolean runExample() throws Exception + public static void main(final String[] args) throws Exception { InitialContext initialContext = null; try @@ -48,9 +41,9 @@ public class JMSAutoCloseableExample extends ActiveMQExample // Step 4.Create a JMS Context using the try-with-resources statement try - ( - JMSContext jmsContext = cf.createContext() - ) + ( + JMSContext jmsContext = cf.createContext() + ) { // Step 5. create a jms producer JMSProducer jmsProducer = jmsContext.createProducer(); @@ -64,8 +57,6 @@ public class JMSAutoCloseableExample extends ActiveMQExample //JMSCcontext will have been closed by the time we get to this point System.out.println("expected exception from jmsProducer.send: " + e.getMessage()); } - - return true; } finally { diff --git a/examples/jms/jms-auto-closeable/src/main/resources/activemq/server0/artemis-roles.properties b/examples/jms/jms-auto-closeable/src/main/resources/activemq/server0/artemis-roles.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/jms-auto-closeable/src/main/resources/activemq/server0/artemis-roles.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/jms-auto-closeable/src/main/resources/activemq/server0/artemis-users.properties b/examples/jms/jms-auto-closeable/src/main/resources/activemq/server0/artemis-users.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/jms-auto-closeable/src/main/resources/activemq/server0/artemis-users.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/jms-auto-closeable/src/main/resources/activemq/server0/broker.xml b/examples/jms/jms-auto-closeable/src/main/resources/activemq/server0/broker.xml deleted file mode 100644 index 0f0eebc7c7..0000000000 --- a/examples/jms/jms-auto-closeable/src/main/resources/activemq/server0/broker.xml +++ /dev/null @@ -1,59 +0,0 @@ - - - - - - - - - - - - - ${data.dir}/server0/data/messaging/bindings - - ${data.dir}/server0/data/messaging/journal - - ${data.dir}/server0/data/messaging/largemessages - - ${data.dir}/server0/data/messaging/paging - - - - tcp://localhost:61616 - - - - - - - - - - - - - - - - - diff --git a/examples/jms/jms-bridge/pom.xml b/examples/jms/jms-bridge/pom.xml index 54ea63e485..ac21a8ce2b 100644 --- a/examples/jms/jms-bridge/pom.xml +++ b/examples/jms/jms-bridge/pom.xml @@ -27,7 +27,7 @@ under the License. 1.0.1-SNAPSHOT - artemis-jms-jms-bridge-example + artemis-jms-bridge-example jar ActiveMQ Artemis JMS Bridge Example @@ -36,11 +36,6 @@ under the License. - - org.apache.activemq.examples.jms - common - ${project.version} - org.apache.activemq artemis-jms-server @@ -62,7 +57,7 @@ under the License. artemis-maven-plugin - create + create0 create @@ -72,7 +67,7 @@ under the License. - create2 + create1 create @@ -81,6 +76,36 @@ under the License. ${basedir}/target/classes/activemq/server1 + + start0 + + cli + + + true + ${basedir}/target/server0 + tcp://localhost:61616 + + run + + server0 + + + + start1 + + cli + + + true + ${basedir}/target/server1 + tcp://localhost:61617 + + run + + server1 + + runClient @@ -88,9 +113,29 @@ under the License. org.apache.activemq.artemis.jms.example.JMSBridgeExample + + + + stop0 + + cli + + + ${basedir}/target/server0 - ${basedir}/target/server0 - ${basedir}/target/server1 + stop + + + + + stop1 + + cli + + + ${basedir}/target/server1 + + stop @@ -98,7 +143,7 @@ under the License. org.apache.activemq.examples.jms - artemis-jms-jms-bridge-example + artemis-jms-bridge-example ${project.version} diff --git a/examples/jms/jms-bridge/src/main/java/org/apache/activemq/artemis/jms/example/JMSBridgeExample.java b/examples/jms/jms-bridge/src/main/java/org/apache/activemq/artemis/jms/example/JMSBridgeExample.java index 659d37bcb0..13d30e702f 100644 --- a/examples/jms/jms-bridge/src/main/java/org/apache/activemq/artemis/jms/example/JMSBridgeExample.java +++ b/examples/jms/jms-bridge/src/main/java/org/apache/activemq/artemis/jms/example/JMSBridgeExample.java @@ -27,7 +27,6 @@ import javax.jms.Topic; import javax.naming.InitialContext; import java.util.Hashtable; -import org.apache.activemq.artemis.common.example.ActiveMQExample; import org.apache.activemq.artemis.jms.bridge.JMSBridge; import org.apache.activemq.artemis.jms.bridge.QualityOfServiceMode; import org.apache.activemq.artemis.jms.bridge.impl.JMSBridgeImpl; @@ -39,22 +38,16 @@ import org.apache.activemq.artemis.jms.bridge.impl.JNDIDestinationFactory; * The source and target destinations are located on 2 different ActiveMQ Artemis server. * The source and target queues are bridged by a JMS Bridge configured and running on the "target" server. */ -public class JMSBridgeExample extends ActiveMQExample +public class JMSBridgeExample { public static void main(final String[] args) throws Exception { - new JMSBridgeExample().run(args); - } - - @Override - public boolean runExample() throws Exception - { - String sourceServer = ActiveMQExample.DEFAULT_TCP1; - String targetServer = ActiveMQExample.DEFAULT_TCP2; + String sourceServer = "tcp://localhost:61616"; + String targetServer = "tcp://localhost:61617"; System.out.println("client will publish messages to " + sourceServer + - " and receives message from " + - targetServer); + " and receives message from " + + targetServer); // Step 1. Create JNDI contexts for source and target servers InitialContext sourceContext = JMSBridgeExample.createContext(sourceServer); @@ -65,23 +58,23 @@ public class JMSBridgeExample extends ActiveMQExample // Step 2. Create and start a JMS Bridge // Note, the Bridge needs a transaction manager, in this instance we will use the JBoss TM JMSBridge jmsBridge = new JMSBridgeImpl( - new JNDIConnectionFactoryFactory(sourceJndiParams, "ConnectionFactory"), - new JNDIConnectionFactoryFactory(targetJndiParams, "ConnectionFactory"), - new JNDIDestinationFactory(sourceJndiParams, "source/topic"), - new JNDIDestinationFactory(targetJndiParams, "target/queue"), - null, - null, - null, - null, - null, - 5000, - 10, - QualityOfServiceMode.DUPLICATES_OK, - 1, - -1, - null, - null, - true); + new JNDIConnectionFactoryFactory(sourceJndiParams, "ConnectionFactory"), + new JNDIConnectionFactoryFactory(targetJndiParams, "ConnectionFactory"), + new JNDIDestinationFactory(sourceJndiParams, "source/topic"), + new JNDIDestinationFactory(targetJndiParams, "target/queue"), + null, + null, + null, + null, + null, + 5000, + 10, + QualityOfServiceMode.DUPLICATES_OK, + 1, + -1, + null, + null, + true); Connection sourceConnection = null; Connection targetConnection = null; @@ -135,7 +128,7 @@ public class JMSBridgeExample extends ActiveMQExample // Step 12. Be sure to close the resources! if(jmsBridge != null) { - jmsBridge.stop(); + jmsBridge.stop(); } if (sourceContext != null) { @@ -154,8 +147,6 @@ public class JMSBridgeExample extends ActiveMQExample targetConnection.close(); } } - - return true; } private static InitialContext createContext(final String server) throws Exception diff --git a/examples/jms/jms-bridge/src/main/resources/activemq/server0/broker.xml b/examples/jms/jms-bridge/src/main/resources/activemq/server0/broker.xml index d1e96e7de0..df456d704b 100644 --- a/examples/jms/jms-bridge/src/main/resources/activemq/server0/broker.xml +++ b/examples/jms/jms-bridge/src/main/resources/activemq/server0/broker.xml @@ -28,13 +28,13 @@ under the License. - ${data.dir}/server0/data/messaging/bindings + ${data.dir:../data}/bindings - ${data.dir}/server0/data/messaging/journal + ${data.dir:../data}/journal - ${data.dir}/server0/data/messaging/largemessages + ${data.dir:../data}/largemessages - ${data.dir}/server0/data/messaging/paging + ${data.dir:../data}/paging tcp://localhost:61616 @@ -50,4 +50,4 @@ under the License. - + diff --git a/examples/jms/jms-bridge/src/main/resources/activemq/server1/broker.xml b/examples/jms/jms-bridge/src/main/resources/activemq/server1/broker.xml index aada805f2f..e65720cfb7 100644 --- a/examples/jms/jms-bridge/src/main/resources/activemq/server1/broker.xml +++ b/examples/jms/jms-bridge/src/main/resources/activemq/server1/broker.xml @@ -28,17 +28,16 @@ under the License. - ${data.dir}/server1/data/messaging/bindings + ${data.dir:../data}/bindings - ${data.dir}/server1/data/messaging/journal + ${data.dir:../data}/journal - ${data.dir}/server1/data/messaging/largemessages + ${data.dir:../data}/largemessages - ${data.dir}/server1/data/messaging/paging + ${data.dir:../data}/paging - tcp://localhost:5455 - tcp://localhost:61617 + tcp://localhost:61617 diff --git a/examples/jms/jms-completion-listener/pom.xml b/examples/jms/jms-completion-listener/pom.xml index 042b3de01f..ef5fb76209 100644 --- a/examples/jms/jms-completion-listener/pom.xml +++ b/examples/jms/jms-completion-listener/pom.xml @@ -36,11 +36,6 @@ under the License. - - org.apache.activemq.examples.jms - common - ${project.version} - org.apache.geronimo.specs geronimo-jms_2.0_spec @@ -61,9 +56,18 @@ under the License. create + + + start + + cli + - ${basedir}/target/server0 - ${basedir}/target/classes/activemq/server0 + true + tcp://localhost:61616 + + run + @@ -73,8 +77,16 @@ under the License. org.apache.activemq.artemis.jms.example.JMSCompletionListenerExample + + + + stop + + cli + + - ${basedir}/target/server0 + stop diff --git a/examples/jms/jms-completion-listener/src/main/java/org/apache/activemq/artemis/jms/example/JMSCompletionListenerExample.java b/examples/jms/jms-completion-listener/src/main/java/org/apache/activemq/artemis/jms/example/JMSCompletionListenerExample.java index a166000756..47a61cb57a 100644 --- a/examples/jms/jms-completion-listener/src/main/java/org/apache/activemq/artemis/jms/example/JMSCompletionListenerExample.java +++ b/examples/jms/jms-completion-listener/src/main/java/org/apache/activemq/artemis/jms/example/JMSCompletionListenerExample.java @@ -24,23 +24,17 @@ import javax.jms.Message; import javax.jms.Queue; import javax.naming.InitialContext; -import org.apache.activemq.artemis.common.example.ActiveMQExample; - +import java.lang.Exception; +import java.lang.IllegalStateException; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; /** * A JMS Completion Listener Example. */ -public class JMSCompletionListenerExample extends ActiveMQExample +public class JMSCompletionListenerExample { - public static void main(final String[] args) - { - new JMSCompletionListenerExample().run(args); - } - - @Override - public boolean runExample() throws Exception + public static void main(final String[] args) throws Exception { InitialContext initialContext = null; JMSContext jmsContext = null; @@ -84,7 +78,10 @@ public class JMSCompletionListenerExample extends ActiveMQExample producer.send(queue, "this is a string"); //Step 7. wait for the Completion handler - return latch.await(5, TimeUnit.SECONDS); + if (!latch.await(5, TimeUnit.SECONDS)) + { + throw new IllegalStateException("Completion listener not called as expected."); + } } finally { diff --git a/examples/jms/jms-completion-listener/src/main/resources/activemq/server0/artemis-roles.properties b/examples/jms/jms-completion-listener/src/main/resources/activemq/server0/artemis-roles.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/jms-completion-listener/src/main/resources/activemq/server0/artemis-roles.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/jms-completion-listener/src/main/resources/activemq/server0/artemis-users.properties b/examples/jms/jms-completion-listener/src/main/resources/activemq/server0/artemis-users.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/jms-completion-listener/src/main/resources/activemq/server0/artemis-users.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/jms-completion-listener/src/main/resources/activemq/server0/broker.xml b/examples/jms/jms-completion-listener/src/main/resources/activemq/server0/broker.xml deleted file mode 100644 index 7690094861..0000000000 --- a/examples/jms/jms-completion-listener/src/main/resources/activemq/server0/broker.xml +++ /dev/null @@ -1,60 +0,0 @@ - - - - - - - - - - - - - ${data.dir}/server0/data/messaging/bindings - - ${data.dir}/server0/data/messaging/journal - - ${data.dir}/server0/data/messaging/largemessages - - ${data.dir}/server0/data/messaging/paging - - - - tcp://localhost:61616 - - - - - - - - - - - - - - - - - - diff --git a/examples/jms/jms-context/pom.xml b/examples/jms/jms-context/pom.xml index 7363d880db..d586367bec 100644 --- a/examples/jms/jms-context/pom.xml +++ b/examples/jms/jms-context/pom.xml @@ -36,11 +36,6 @@ under the License. - - org.apache.activemq.examples.jms - common - ${project.version} - org.apache.geronimo.specs geronimo-jms_2.0_spec @@ -61,9 +56,18 @@ under the License. create + + + start + + cli + - ${basedir}/target/server0 - ${basedir}/target/classes/activemq/server0 + true + tcp://localhost:61616 + + run + @@ -73,8 +77,16 @@ under the License. org.apache.activemq.artemis.jms.example.JMSContextExample + + + + stop + + cli + + - ${basedir}/target/server0 + stop diff --git a/examples/jms/jms-context/src/main/java/org/apache/activemq/artemis/jms/example/JMSContextExample.java b/examples/jms/jms-context/src/main/java/org/apache/activemq/artemis/jms/example/JMSContextExample.java index 81e7a9dbca..bb8457f49d 100644 --- a/examples/jms/jms-context/src/main/java/org/apache/activemq/artemis/jms/example/JMSContextExample.java +++ b/examples/jms/jms-context/src/main/java/org/apache/activemq/artemis/jms/example/JMSContextExample.java @@ -21,21 +21,14 @@ import javax.jms.DeliveryMode; import javax.jms.JMSContext; import javax.jms.Queue; import javax.naming.InitialContext; - -import org.apache.activemq.artemis.common.example.ActiveMQExample; +import java.lang.Exception; /** * A simple JMS Queue example that creates a producer and consumer on a queue and sends then receives a message. */ -public class JMSContextExample extends ActiveMQExample +public class JMSContextExample { - public static void main(final String[] args) - { - new JMSContextExample().run(args); - } - - @Override - public boolean runExample() throws Exception + public static void main(final String[] args) throws Exception { InitialContext initialContext = null; JMSContext jmsContext = null; @@ -60,8 +53,6 @@ public class JMSContextExample extends ActiveMQExample String payLoad = jmsContext.createConsumer(queue).receiveBody(String.class); System.out.println("payLoad = " + payLoad); - - return true; } finally { diff --git a/examples/jms/jms-context/src/main/resources/activemq/server0/artemis-roles.properties b/examples/jms/jms-context/src/main/resources/activemq/server0/artemis-roles.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/jms-context/src/main/resources/activemq/server0/artemis-roles.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/jms-context/src/main/resources/activemq/server0/artemis-users.properties b/examples/jms/jms-context/src/main/resources/activemq/server0/artemis-users.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/jms-context/src/main/resources/activemq/server0/artemis-users.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/jms-context/src/main/resources/activemq/server0/broker.xml b/examples/jms/jms-context/src/main/resources/activemq/server0/broker.xml deleted file mode 100644 index 7690094861..0000000000 --- a/examples/jms/jms-context/src/main/resources/activemq/server0/broker.xml +++ /dev/null @@ -1,60 +0,0 @@ - - - - - - - - - - - - - ${data.dir}/server0/data/messaging/bindings - - ${data.dir}/server0/data/messaging/journal - - ${data.dir}/server0/data/messaging/largemessages - - ${data.dir}/server0/data/messaging/paging - - - - tcp://localhost:61616 - - - - - - - - - - - - - - - - - - diff --git a/examples/jms/jms-shared-consumer/pom.xml b/examples/jms/jms-shared-consumer/pom.xml index 5939114675..af55f861f3 100644 --- a/examples/jms/jms-shared-consumer/pom.xml +++ b/examples/jms/jms-shared-consumer/pom.xml @@ -36,11 +36,6 @@ under the License. - - org.apache.activemq.examples.jms - common - ${project.version} - org.apache.geronimo.specs geronimo-jms_2.0_spec @@ -61,9 +56,18 @@ under the License. create + + + start + + cli + - ${basedir}/target/server0 - ${basedir}/target/classes/activemq/server0 + true + tcp://localhost:61616 + + run + @@ -73,8 +77,16 @@ under the License. org.apache.activemq.artemis.jms.example.JMSSharedConsumerExample + + + + stop + + cli + + - ${basedir}/target/server0 + stop diff --git a/examples/jms/jms-shared-consumer/src/main/java/org/apache/activemq/artemis/jms/example/JMSSharedConsumerExample.java b/examples/jms/jms-shared-consumer/src/main/java/org/apache/activemq/artemis/jms/example/JMSSharedConsumerExample.java index 5c50063ad9..c45f79bfb2 100644 --- a/examples/jms/jms-shared-consumer/src/main/java/org/apache/activemq/artemis/jms/example/JMSSharedConsumerExample.java +++ b/examples/jms/jms-shared-consumer/src/main/java/org/apache/activemq/artemis/jms/example/JMSSharedConsumerExample.java @@ -23,20 +23,12 @@ import javax.jms.JMSProducer; import javax.jms.Topic; import javax.naming.InitialContext; -import org.apache.activemq.artemis.common.example.ActiveMQExample; - /** * A JMS Example that uses shared consumers. */ -public class JMSSharedConsumerExample extends ActiveMQExample +public class JMSSharedConsumerExample { public static void main(final String[] args) throws Exception - { - new JMSSharedConsumerExample().run(args); - } - - @Override - public boolean runExample() throws Exception { InitialContext initialContext = null; JMSContext jmsContext = null; @@ -80,8 +72,6 @@ public class JMSSharedConsumerExample extends ActiveMQExample body = jmsConsumer2.receiveBody(String.class, 5000); System.out.println("body = " + body); - - return true; } finally { diff --git a/examples/jms/jms-shared-consumer/src/main/resources/activemq/server0/broker.xml b/examples/jms/jms-shared-consumer/src/main/resources/activemq/server0/broker.xml index 0ee3f9dc0c..2b2ba2e1fb 100644 --- a/examples/jms/jms-shared-consumer/src/main/resources/activemq/server0/broker.xml +++ b/examples/jms/jms-shared-consumer/src/main/resources/activemq/server0/broker.xml @@ -29,15 +29,16 @@ under the License. - ${data.dir}/server0/data/messaging/bindings + ${data.dir:../data}/bindings - ${data.dir}/server0/data/messaging/journal + ${data.dir:../data}/journal - ${data.dir}/server0/data/messaging/largemessages + ${data.dir:../data}/largemessages - ${data.dir}/server0/data/messaging/paging + ${data.dir:../data}/paging + tcp://localhost:61616 @@ -45,7 +46,7 @@ under the License. - + diff --git a/examples/jms/jmx/pom.xml b/examples/jms/jmx/pom.xml index f9a3e9abac..802025d726 100644 --- a/examples/jms/jmx/pom.xml +++ b/examples/jms/jmx/pom.xml @@ -36,11 +36,6 @@ under the License. - - org.apache.activemq.examples.jms - common - ${project.version} - org.apache.activemq artemis-core-client @@ -76,6 +71,19 @@ under the License. -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=3000 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false + + start + + cli + + + true + tcp://localhost:61616 + + run + + + runClient @@ -83,8 +91,16 @@ under the License. org.apache.activemq.artemis.jms.example.JMXExample + + + + stop + + cli + + - ${basedir}/target/server0 + stop diff --git a/examples/jms/jmx/src/main/java/org/apache/activemq/artemis/jms/example/JMXExample.java b/examples/jms/jmx/src/main/java/org/apache/activemq/artemis/jms/example/JMXExample.java index ebdad1b871..8d36d53fff 100644 --- a/examples/jms/jmx/src/main/java/org/apache/activemq/artemis/jms/example/JMXExample.java +++ b/examples/jms/jmx/src/main/java/org/apache/activemq/artemis/jms/example/JMXExample.java @@ -36,22 +36,15 @@ import javax.naming.InitialContext; import org.apache.activemq.artemis.api.core.management.ObjectNameBuilder; import org.apache.activemq.artemis.api.jms.management.JMSQueueControl; -import org.apache.activemq.artemis.common.example.ActiveMQExample; /** * An example that shows how to manage ActiveMQ Artemis using JMX. */ -public class JMXExample extends ActiveMQExample +public class JMXExample { private static final String JMX_URL = "service:jmx:rmi:///jndi/rmi://localhost:3000/jmxrmi"; - public static void main(final String[] args) - { - new JMXExample().run(args); - } - - @Override - public boolean runExample() throws Exception + public static void main(final String[] args) throws Exception { QueueConnection connection = null; InitialContext initialContext = null; @@ -94,7 +87,7 @@ public class JMXExample extends ActiveMQExample // Step 12. Create a JMSQueueControl proxy to manage the queue on the server JMSQueueControl queueControl = MBeanServerInvocationHandler.newProxyInstance(mbsc, on, - JMSQueueControl.class, + JMSQueueControl.class, false); // Step 13. Display the number of messages in the queue System.out.println(queueControl.getName() + " contains " + queueControl.getMessageCount() + " messages"); @@ -119,8 +112,6 @@ public class JMXExample extends ActiveMQExample // The call will timeout after 5000ms and messageReceived will be null TextMessage messageReceived = (TextMessage)messageConsumer.receive(5000); System.out.println("Received message: " + messageReceived); - - return true; } finally { @@ -135,5 +126,4 @@ public class JMXExample extends ActiveMQExample } } } - } diff --git a/examples/jms/large-message/pom.xml b/examples/jms/large-message/pom.xml index dd3af5b953..cc354e6513 100644 --- a/examples/jms/large-message/pom.xml +++ b/examples/jms/large-message/pom.xml @@ -37,8 +37,8 @@ under the License. - org.apache.activemq.examples.jms - common + org.apache.activemq + artemis-cli ${project.version} @@ -61,10 +61,6 @@ under the License. create - - ${basedir}/target/server0 - ${basedir}/target/classes/activemq/server0 - runClient diff --git a/examples/jms/large-message/src/main/java/org/apache/activemq/artemis/jms/example/LargeMessageExample.java b/examples/jms/large-message/src/main/java/org/apache/activemq/artemis/jms/example/LargeMessageExample.java index d154ed73af..b7cf3de1fc 100644 --- a/examples/jms/large-message/src/main/java/org/apache/activemq/artemis/jms/example/LargeMessageExample.java +++ b/examples/jms/large-message/src/main/java/org/apache/activemq/artemis/jms/example/LargeMessageExample.java @@ -16,6 +16,8 @@ */ package org.apache.activemq.artemis.jms.example; +import org.apache.activemq.artemis.util.ServerUtil; + import javax.jms.BytesMessage; import javax.jms.Connection; import javax.jms.ConnectionFactory; @@ -32,19 +34,12 @@ import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; -import org.apache.activemq.artemis.common.example.ActiveMQExample; - /** * This example demonstrates the ability of ActiveMQ Artemis to send and consume a very large message, much * bigger than can fit in RAM. */ -public class LargeMessageExample extends ActiveMQExample +public class LargeMessageExample { - public static void main(final String[] args) - { - new LargeMessageExample().run(args); - } - /** * The message we will send is size 2GiB, even though we are only running in 50MB of RAM on both * client and server. @@ -54,14 +49,16 @@ public class LargeMessageExample extends ActiveMQExample */ private static final long FILE_SIZE = 2L * 1024 * 1024 * 1024; // 2 GiB message - @Override - public boolean runExample() throws Exception + public static void main(final String[] args) throws Exception { + Process server = null; Connection connection = null; InitialContext initialContext = null; try { + server = ServerUtil.startServer(args[0], LargeMessageExample.class.getSimpleName(), 0, 5000); + // Step 1. Create an initial context to perform the JNDI lookup. initialContext = new InitialContext(); @@ -83,8 +80,8 @@ public class LargeMessageExample extends ActiveMQExample // Step 5. Create a huge file - this will form the body of the message we will send. System.out.println("Creating a file to send of size " + FILE_SIZE + - " bytes. This may take a little while... " + - "If this is too big for your disk you can easily change the FILE_SIZE in the example."); + " bytes. This may take a little while... " + + "If this is too big for your disk you can easily change the FILE_SIZE in the example."); File fileInput = new File("huge_message_to_send.dat"); @@ -122,12 +119,9 @@ public class LargeMessageExample extends ActiveMQExample initialContext.close(); - killServer(0); + ServerUtil.killServer(server); - // Give the server a little time to shutdown properly - Thread.sleep(5000); - - reStartServer(0, 60000); + server = ServerUtil.startServer(args[0], "LargeMessageExample", 0, 5000); System.out.println("Server restarted."); @@ -154,7 +148,7 @@ public class LargeMessageExample extends ActiveMQExample BytesMessage messageReceived = (BytesMessage)messageConsumer.receive(120000); System.out.println("Received message with: " + messageReceived.getLongProperty("_AMQ_LARGE_SIZE") + - " bytes. Now streaming to file on disk."); + " bytes. Now streaming to file on disk."); // Step 13. We set an OutputStream on the message. This causes the message body to be written to the // OutputStream until there are no more bytes to be written. @@ -174,8 +168,6 @@ public class LargeMessageExample extends ActiveMQExample fileOutputStream.close(); System.out.println("File streamed to disk. Size of received file on disk is " + outputFile.length()); - - return true; } finally { @@ -189,6 +181,8 @@ public class LargeMessageExample extends ActiveMQExample { connection.close(); } + + ServerUtil.killServer(server); } } @@ -198,7 +192,7 @@ public class LargeMessageExample extends ActiveMQExample * @throws FileNotFoundException * @throws IOException */ - private void createFile(final File file, final long fileSize) throws IOException + private static void createFile(final File file, final long fileSize) throws IOException { FileOutputStream fileOut = new FileOutputStream(file); BufferedOutputStream buffOut = new BufferedOutputStream(fileOut); diff --git a/examples/jms/large-message/src/main/resources/activemq/server0/artemis-roles.properties b/examples/jms/large-message/src/main/resources/activemq/server0/artemis-roles.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/large-message/src/main/resources/activemq/server0/artemis-roles.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/large-message/src/main/resources/activemq/server0/artemis-users.properties b/examples/jms/large-message/src/main/resources/activemq/server0/artemis-users.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/large-message/src/main/resources/activemq/server0/artemis-users.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/large-message/src/main/resources/activemq/server0/broker.xml b/examples/jms/large-message/src/main/resources/activemq/server0/broker.xml deleted file mode 100644 index 7690094861..0000000000 --- a/examples/jms/large-message/src/main/resources/activemq/server0/broker.xml +++ /dev/null @@ -1,60 +0,0 @@ - - - - - - - - - - - - - ${data.dir}/server0/data/messaging/bindings - - ${data.dir}/server0/data/messaging/journal - - ${data.dir}/server0/data/messaging/largemessages - - ${data.dir}/server0/data/messaging/paging - - - - tcp://localhost:61616 - - - - - - - - - - - - - - - - - - diff --git a/examples/jms/last-value-queue/pom.xml b/examples/jms/last-value-queue/pom.xml index 61f9b7b892..15e9d38818 100644 --- a/examples/jms/last-value-queue/pom.xml +++ b/examples/jms/last-value-queue/pom.xml @@ -36,11 +36,6 @@ under the License. - - org.apache.activemq.examples.jms - common - ${project.version} - org.apache.geronimo.specs geronimo-jms_2.0_spec @@ -61,9 +56,18 @@ under the License. create + + + start + + cli + - ${basedir}/target/server0 - ${basedir}/target/classes/activemq/server0 + true + tcp://localhost:61616 + + run + @@ -73,8 +77,16 @@ under the License. org.apache.activemq.artemis.jms.example.LastValueQueueExample + + + + stop + + cli + + - ${basedir}/target/server0 + stop diff --git a/examples/jms/last-value-queue/src/main/java/org/apache/activemq/artemis/jms/example/LastValueQueueExample.java b/examples/jms/last-value-queue/src/main/java/org/apache/activemq/artemis/jms/example/LastValueQueueExample.java index ed0b6f87ec..72b001b295 100644 --- a/examples/jms/last-value-queue/src/main/java/org/apache/activemq/artemis/jms/example/LastValueQueueExample.java +++ b/examples/jms/last-value-queue/src/main/java/org/apache/activemq/artemis/jms/example/LastValueQueueExample.java @@ -28,21 +28,13 @@ import javax.jms.Session; import javax.jms.TextMessage; import javax.naming.InitialContext; -import org.apache.activemq.artemis.common.example.ActiveMQExample; - /** * This example shows how to configure and use a Last-Value queues. * Only the last message with a well-defined property is hold by the queue. */ -public class LastValueQueueExample extends ActiveMQExample +public class LastValueQueueExample { - public static void main(final String[] args) - { - new LastValueQueueExample().run(args); - } - - @Override - public boolean runExample() throws Exception + public static void main(final String[] args) throws Exception { Connection connection = null; InitialContext initialContext = null; @@ -108,8 +100,6 @@ public class LastValueQueueExample extends ActiveMQExample System.out.format("Received message: %s%n", messageReceived); initialContext.close(); - - return true; } finally { @@ -124,5 +114,4 @@ public class LastValueQueueExample extends ActiveMQExample } } } - } diff --git a/examples/jms/management-notifications/pom.xml b/examples/jms/management-notifications/pom.xml index 9e023e062a..8caa70f5b6 100644 --- a/examples/jms/management-notifications/pom.xml +++ b/examples/jms/management-notifications/pom.xml @@ -36,11 +36,6 @@ under the License. - - org.apache.activemq.examples.jms - common - ${project.version} - org.apache.geronimo.specs geronimo-jms_2.0_spec @@ -61,9 +56,18 @@ under the License. create + + + start + + cli + - ${basedir}/target/server0 - ${basedir}/target/classes/activemq/server0 + true + tcp://localhost:61616 + + run + @@ -73,8 +77,16 @@ under the License. org.apache.activemq.artemis.jms.example.ManagementNotificationExample + + + + stop + + cli + + - ${basedir}/target/server0 + stop diff --git a/examples/jms/management-notifications/src/main/java/org/apache/activemq/artemis/jms/example/ManagementNotificationExample.java b/examples/jms/management-notifications/src/main/java/org/apache/activemq/artemis/jms/example/ManagementNotificationExample.java index bdbceb9183..9b26ae4136 100644 --- a/examples/jms/management-notifications/src/main/java/org/apache/activemq/artemis/jms/example/ManagementNotificationExample.java +++ b/examples/jms/management-notifications/src/main/java/org/apache/activemq/artemis/jms/example/ManagementNotificationExample.java @@ -30,20 +30,12 @@ import javax.jms.Session; import javax.jms.Topic; import javax.naming.InitialContext; -import org.apache.activemq.artemis.common.example.ActiveMQExample; - /** * An example that shows how to receive management notifications using JMS messages. */ -public class ManagementNotificationExample extends ActiveMQExample +public class ManagementNotificationExample { - public static void main(final String[] args) - { - new ManagementNotificationExample().run(args); - } - - @Override - public boolean runExample() throws Exception + public static void main(final String[] args) throws Exception { Connection connection = null; InitialContext initialContext = null; @@ -112,8 +104,6 @@ public class ManagementNotificationExample extends ActiveMQExample // sleep a little bit to be sure to receive the notification for the security // authentication violation before leaving the example Thread.sleep(2000); - - return true; } finally { diff --git a/examples/jms/management/pom.xml b/examples/jms/management/pom.xml index 1797ce188e..d287c28184 100644 --- a/examples/jms/management/pom.xml +++ b/examples/jms/management/pom.xml @@ -37,8 +37,8 @@ under the License. - org.apache.activemq.examples.jms - common + org.apache.activemq + artemis-jms-client ${project.version} @@ -61,9 +61,18 @@ under the License. create + + + start + + cli + - ${basedir}/target/server0 - ${basedir}/target/classes/activemq/server0 + true + tcp://localhost:61616 + + run + @@ -73,8 +82,16 @@ under the License. org.apache.activemq.artemis.jms.example.ManagementExample + + + + stop + + cli + + - ${basedir}/target/server0 + stop diff --git a/examples/jms/management/src/main/java/org/apache/activemq/artemis/jms/example/ManagementExample.java b/examples/jms/management/src/main/java/org/apache/activemq/artemis/jms/example/ManagementExample.java index 4ed1a5919c..fd92ddcb5e 100644 --- a/examples/jms/management/src/main/java/org/apache/activemq/artemis/jms/example/ManagementExample.java +++ b/examples/jms/management/src/main/java/org/apache/activemq/artemis/jms/example/ManagementExample.java @@ -30,20 +30,13 @@ import javax.naming.InitialContext; import org.apache.activemq.artemis.api.jms.ActiveMQJMSClient; import org.apache.activemq.artemis.api.jms.management.JMSManagementHelper; -import org.apache.activemq.artemis.common.example.ActiveMQExample; /** * An example that shows how to manage ActiveMQ Artemis using JMS messages. */ -public class ManagementExample extends ActiveMQExample +public class ManagementExample { - public static void main(final String[] args) - { - new ManagementExample().run(args); - } - - @Override - public boolean runExample() throws Exception + public static void main(final String[] args) throws Exception { QueueConnection connection = null; InitialContext initialContext = null; @@ -131,8 +124,6 @@ public class ManagementExample extends ActiveMQExample // there is none to consume. The call will timeout after 5000ms and messageReceived will be null TextMessage messageReceived = (TextMessage)messageConsumer.receive(5000); System.out.println("Received message: " + messageReceived); - - return true; } finally { diff --git a/examples/jms/message-counters/pom.xml b/examples/jms/message-counters/pom.xml index f4d8753f02..7cd17e3508 100644 --- a/examples/jms/message-counters/pom.xml +++ b/examples/jms/message-counters/pom.xml @@ -37,8 +37,8 @@ under the License. - org.apache.activemq.examples.jms - common + org.apache.activemq + artemis-jms-client ${project.version} @@ -67,12 +67,22 @@ under the License. create - ${basedir}/target/server0 - ${basedir}/target/classes/activemq/server0 - -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=3001 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false + + start + + cli + + + true + tcp://localhost:61616 + + run + + + runClient @@ -80,8 +90,16 @@ under the License. org.apache.activemq.artemis.jms.example.MessageCounterExample + + + + stop + + cli + + - ${basedir}/target/server0 + stop diff --git a/examples/jms/message-counters/src/main/java/org/apache/activemq/artemis/jms/example/MessageCounterExample.java b/examples/jms/message-counters/src/main/java/org/apache/activemq/artemis/jms/example/MessageCounterExample.java index 5f8e4e0038..1e9865f1a9 100644 --- a/examples/jms/message-counters/src/main/java/org/apache/activemq/artemis/jms/example/MessageCounterExample.java +++ b/examples/jms/message-counters/src/main/java/org/apache/activemq/artemis/jms/example/MessageCounterExample.java @@ -37,22 +37,15 @@ import javax.naming.InitialContext; import org.apache.activemq.artemis.api.core.management.MessageCounterInfo; import org.apache.activemq.artemis.api.core.management.ObjectNameBuilder; import org.apache.activemq.artemis.api.jms.management.JMSQueueControl; -import org.apache.activemq.artemis.common.example.ActiveMQExample; /** * An example showing how to use message counters to have information on a queue. */ -public class MessageCounterExample extends ActiveMQExample +public class MessageCounterExample { private static final String JMX_URL = "service:jmx:rmi:///jndi/rmi://localhost:3001/jmxrmi"; - public static void main(final String[] args) - { - new MessageCounterExample().run(args); - } - - @Override - public boolean runExample() throws Exception + public static void main(final String[] args) throws Exception { QueueConnection connection = null; InitialContext initialContext = null; @@ -84,7 +77,7 @@ public class MessageCounterExample extends ActiveMQExample // Step 7. Use JMX to retrieve the message counters using the JMSQueueControl ObjectName on = ObjectNameBuilder.DEFAULT.getJMSQueueObjectName(queue.getQueueName()); JMXConnector connector = - JMXConnectorFactory.connect(new JMXServiceURL(JMX_URL), new HashMap()); + JMXConnectorFactory.connect(new JMXServiceURL(JMX_URL), new HashMap()); MBeanServerConnection mbsc = connector.getMBeanServerConnection(); JMSQueueControl queueControl = MBeanServerInvocationHandler.newProxyInstance(mbsc, on, @@ -125,8 +118,6 @@ public class MessageCounterExample extends ActiveMQExample counters = queueControl.listMessageCounter(); messageCounter = MessageCounterInfo.fromJSON(counters); displayMessageCounter(messageCounter); - - return true; } finally { @@ -142,7 +133,7 @@ public class MessageCounterExample extends ActiveMQExample } } - private void displayMessageCounter(final MessageCounterInfo counter) + private static void displayMessageCounter(final MessageCounterInfo counter) { System.out.format("%s (sample updated at %s)%n", counter.getName(), counter.getUdpateTimestamp()); System.out.format(" %s message(s) added to the queue (since last sample: %s)%n", diff --git a/examples/jms/message-group/pom.xml b/examples/jms/message-group/pom.xml index e2e6b145d7..cfd67fbe68 100644 --- a/examples/jms/message-group/pom.xml +++ b/examples/jms/message-group/pom.xml @@ -36,11 +36,6 @@ under the License. - - org.apache.activemq.examples.jms - common - ${project.version} - org.apache.geronimo.specs geronimo-jms_2.0_spec @@ -61,9 +56,18 @@ under the License. create + + + start + + cli + - ${basedir}/target/server0 - ${basedir}/target/classes/activemq/server0 + true + tcp://localhost:61616 + + run + @@ -73,8 +77,16 @@ under the License. org.apache.activemq.artemis.jms.example.MessageGroupExample + + + + stop + + cli + + - ${basedir}/target/server0 + stop diff --git a/examples/jms/message-group/src/main/java/org/apache/activemq/artemis/jms/example/MessageGroupExample.java b/examples/jms/message-group/src/main/java/org/apache/activemq/artemis/jms/example/MessageGroupExample.java index d621646c25..ea7e447ff8 100644 --- a/examples/jms/message-group/src/main/java/org/apache/activemq/artemis/jms/example/MessageGroupExample.java +++ b/examples/jms/message-group/src/main/java/org/apache/activemq/artemis/jms/example/MessageGroupExample.java @@ -31,25 +31,14 @@ import javax.jms.Session; import javax.jms.TextMessage; import javax.naming.InitialContext; -import org.apache.activemq.artemis.common.example.ActiveMQExample; - /** * A simple JMS Queue example that sends and receives message groups. */ -public class MessageGroupExample extends ActiveMQExample +public class MessageGroupExample { - private final Map messageReceiverMap = new ConcurrentHashMap(); - - private boolean result = true; - - public static void main(final String[] args) - { - new MessageGroupExample().run(args); - } - - @Override - public boolean runExample() throws Exception + public static void main(final String[] args) throws Exception { + final Map messageReceiverMap = new ConcurrentHashMap(); Connection connection = null; InitialContext initialContext = null; try @@ -74,9 +63,9 @@ public class MessageGroupExample extends ActiveMQExample // Step 7. Create two consumers MessageConsumer consumer1 = session.createConsumer(queue); - consumer1.setMessageListener(new SimpleMessageListener("consumer-1")); + consumer1.setMessageListener(new SimpleMessageListener("consumer-1", messageReceiverMap)); MessageConsumer consumer2 = session.createConsumer(queue); - consumer2.setMessageListener(new SimpleMessageListener("consumer-2")); + consumer2.setMessageListener(new SimpleMessageListener("consumer-2", messageReceiverMap)); // Step 8. Create and send 10 text messages with group id 'Group-0' int msgCount = 10; @@ -103,12 +92,9 @@ public class MessageGroupExample extends ActiveMQExample String receiver = messageReceiverMap.get(grpMsg.getText()); if (!trueReceiver.equals(receiver)) { - System.out.println("Group message [" + grpMsg.getText() + "[ went to wrong receiver: " + receiver); - result = false; + throw new IllegalStateException("Group message [" + grpMsg.getText() + "[ went to wrong receiver: " + receiver); } } - - return result; } finally { @@ -123,29 +109,30 @@ public class MessageGroupExample extends ActiveMQExample } } } +} - private class SimpleMessageListener implements MessageListener +class SimpleMessageListener implements MessageListener +{ + private final String name; + private final Map messageReceiverMap; + + public SimpleMessageListener(final String listenerName, Map messageReceiverMap) { - private final String name; - - public SimpleMessageListener(final String listenerName) - { - name = listenerName; - } - - public void onMessage(final Message message) - { - try - { - TextMessage msg = (TextMessage)message; - System.out.format("Message: [%s] received by %s%n", msg.getText(), name); - messageReceiverMap.put(msg.getText(), name); - } - catch (JMSException e) - { - e.printStackTrace(); - } - } + name = listenerName; + this.messageReceiverMap = messageReceiverMap; } -} + public void onMessage(final Message message) + { + try + { + TextMessage msg = (TextMessage)message; + System.out.format("Message: [%s] received by %s%n", msg.getText(), name); + messageReceiverMap.put(msg.getText(), name); + } + catch (JMSException e) + { + e.printStackTrace(); + } + } +} \ No newline at end of file diff --git a/examples/jms/message-group/src/main/resources/activemq/server0/artemis-roles.properties b/examples/jms/message-group/src/main/resources/activemq/server0/artemis-roles.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/message-group/src/main/resources/activemq/server0/artemis-roles.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/message-group/src/main/resources/activemq/server0/artemis-users.properties b/examples/jms/message-group/src/main/resources/activemq/server0/artemis-users.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/message-group/src/main/resources/activemq/server0/artemis-users.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/message-group/src/main/resources/activemq/server0/broker.xml b/examples/jms/message-group/src/main/resources/activemq/server0/broker.xml deleted file mode 100644 index 7690094861..0000000000 --- a/examples/jms/message-group/src/main/resources/activemq/server0/broker.xml +++ /dev/null @@ -1,60 +0,0 @@ - - - - - - - - - - - - - ${data.dir}/server0/data/messaging/bindings - - ${data.dir}/server0/data/messaging/journal - - ${data.dir}/server0/data/messaging/largemessages - - ${data.dir}/server0/data/messaging/paging - - - - tcp://localhost:61616 - - - - - - - - - - - - - - - - - - diff --git a/examples/jms/message-group2/pom.xml b/examples/jms/message-group2/pom.xml index 54258f96b7..6f23575c39 100644 --- a/examples/jms/message-group2/pom.xml +++ b/examples/jms/message-group2/pom.xml @@ -36,11 +36,6 @@ under the License. - - org.apache.activemq.examples.jms - common - ${project.version} - org.apache.geronimo.specs geronimo-jms_2.0_spec @@ -61,9 +56,18 @@ under the License. create + + + start + + cli + - ${basedir}/target/server0 - ${basedir}/target/classes/activemq/server0 + true + tcp://localhost:61616 + + run + @@ -73,8 +77,16 @@ under the License. org.apache.activemq.artemis.jms.example.MessageGroup2Example + + + + stop + + cli + + - ${basedir}/target/server0 + stop diff --git a/examples/jms/message-group2/src/main/java/org/apache/activemq/artemis/jms/example/MessageGroup2Example.java b/examples/jms/message-group2/src/main/java/org/apache/activemq/artemis/jms/example/MessageGroup2Example.java index 78b5164848..d53a125fef 100644 --- a/examples/jms/message-group2/src/main/java/org/apache/activemq/artemis/jms/example/MessageGroup2Example.java +++ b/examples/jms/message-group2/src/main/java/org/apache/activemq/artemis/jms/example/MessageGroup2Example.java @@ -31,24 +31,16 @@ import javax.jms.Session; import javax.jms.TextMessage; import javax.naming.InitialContext; -import org.apache.activemq.artemis.common.example.ActiveMQExample; - /** * A simple JMS Queue example that sends and receives message groups. */ -public class MessageGroup2Example extends ActiveMQExample +public class MessageGroup2Example { - private final Map messageReceiverMap = new ConcurrentHashMap(); private boolean result = true; - public static void main(String[] args) - { - new MessageGroup2Example().run(args); - } - - @Override - public boolean runExample() throws Exception + public static void main(String[] args) throws Exception { + final Map messageReceiverMap = new ConcurrentHashMap(); Connection connection = null; InitialContext initialContext = null; try @@ -75,9 +67,9 @@ public class MessageGroup2Example extends ActiveMQExample //Step 7. Create two consumers MessageConsumer consumer1 = session.createConsumer(queue); - consumer1.setMessageListener(new SimpleMessageListener("consumer-1")); + consumer1.setMessageListener(new SimpleMessageListener("consumer-1", messageReceiverMap)); MessageConsumer consumer2 = session.createConsumer(queue); - consumer2.setMessageListener(new SimpleMessageListener("consumer-2")); + consumer2.setMessageListener(new SimpleMessageListener("consumer-2", messageReceiverMap)); //Step 8. Create and send 10 text messages with each producer int msgCount = 10; @@ -106,18 +98,14 @@ public class MessageGroup2Example extends ActiveMQExample String receiver = messageReceiverMap.get("producer1 message " + i); if (!trueReceiver.equals(receiver)) { - System.out.println("Group message [producer1 message " + i + "] went to wrong receiver: " + receiver); - result = false; + throw new IllegalStateException("Group message [producer1 message " + i + "] went to wrong receiver: " + receiver); } receiver = messageReceiverMap.get("producer2 message " + i); if (!trueReceiver.equals(receiver)) { - System.out.println("Group message [producer2 message " + i + "] went to wrong receiver: " + receiver); - result = false; + throw new IllegalStateException("Group message [producer2 message " + i + "] went to wrong receiver: " + receiver); } } - - return result; } finally { @@ -132,31 +120,32 @@ public class MessageGroup2Example extends ActiveMQExample } } } +} - private class SimpleMessageListener implements MessageListener +class SimpleMessageListener implements MessageListener +{ + private final String name; + final Map messageReceiverMap; + + public SimpleMessageListener(String listenerName, Map messageReceiverMap) { - private final String name; - - public SimpleMessageListener(String listenerName) - { - name = listenerName; - } - - public void onMessage(Message message) - { - try - { - TextMessage msg = (TextMessage)message; - System.out.format("Message: [%s] received by %s%n", - msg.getText(), - name); - messageReceiverMap.put(msg.getText(), name); - } - catch (JMSException e) - { - e.printStackTrace(); - } - } + name = listenerName; + this.messageReceiverMap = messageReceiverMap; } + public void onMessage(Message message) + { + try + { + TextMessage msg = (TextMessage)message; + System.out.format("Message: [%s] received by %s%n", + msg.getText(), + name); + messageReceiverMap.put(msg.getText(), name); + } + catch (JMSException e) + { + e.printStackTrace(); + } + } } \ No newline at end of file diff --git a/examples/jms/message-group2/src/main/resources/activemq/server0/artemis-roles.properties b/examples/jms/message-group2/src/main/resources/activemq/server0/artemis-roles.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/message-group2/src/main/resources/activemq/server0/artemis-roles.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/message-group2/src/main/resources/activemq/server0/artemis-users.properties b/examples/jms/message-group2/src/main/resources/activemq/server0/artemis-users.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/message-group2/src/main/resources/activemq/server0/artemis-users.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/message-group2/src/main/resources/activemq/server0/broker.xml b/examples/jms/message-group2/src/main/resources/activemq/server0/broker.xml deleted file mode 100644 index 7690094861..0000000000 --- a/examples/jms/message-group2/src/main/resources/activemq/server0/broker.xml +++ /dev/null @@ -1,60 +0,0 @@ - - - - - - - - - - - - - ${data.dir}/server0/data/messaging/bindings - - ${data.dir}/server0/data/messaging/journal - - ${data.dir}/server0/data/messaging/largemessages - - ${data.dir}/server0/data/messaging/paging - - - - tcp://localhost:61616 - - - - - - - - - - - - - - - - - - diff --git a/examples/jms/message-priority/pom.xml b/examples/jms/message-priority/pom.xml index 5b354733f1..6956310388 100644 --- a/examples/jms/message-priority/pom.xml +++ b/examples/jms/message-priority/pom.xml @@ -36,11 +36,6 @@ under the License. - - org.apache.activemq.examples.jms - common - ${project.version} - org.apache.geronimo.specs geronimo-jms_2.0_spec @@ -61,9 +56,18 @@ under the License. create + + + start + + cli + - ${basedir}/target/server0 - ${basedir}/target/classes/activemq/server0 + true + tcp://localhost:61616 + + run + @@ -73,8 +77,16 @@ under the License. org.apache.activemq.artemis.jms.example.MessagePriorityExample + + + + stop + + cli + + - ${basedir}/target/server0 + stop diff --git a/examples/jms/message-priority/src/main/java/org/apache/activemq/artemis/jms/example/MessagePriorityExample.java b/examples/jms/message-priority/src/main/java/org/apache/activemq/artemis/jms/example/MessagePriorityExample.java index bdf98cd852..6435efe739 100644 --- a/examples/jms/message-priority/src/main/java/org/apache/activemq/artemis/jms/example/MessagePriorityExample.java +++ b/examples/jms/message-priority/src/main/java/org/apache/activemq/artemis/jms/example/MessagePriorityExample.java @@ -17,6 +17,7 @@ package org.apache.activemq.artemis.jms.example; import java.util.ArrayList; +import java.util.concurrent.atomic.AtomicBoolean; import javax.jms.Connection; import javax.jms.ConnectionFactory; @@ -31,25 +32,15 @@ import javax.jms.Session; import javax.jms.TextMessage; import javax.naming.InitialContext; -import org.apache.activemq.artemis.common.example.ActiveMQExample; - /** * A simple JMS example that shows the delivery order of messages with priorities. */ -public class MessagePriorityExample extends ActiveMQExample +public class MessagePriorityExample { - private volatile boolean result = true; - - private final ArrayList msgReceived = new ArrayList(); - - public static void main(final String[] args) - { - new MessagePriorityExample().run(args); - } - - @Override - public boolean runExample() throws Exception + public static void main(final String[] args) throws Exception { + AtomicBoolean result = new AtomicBoolean(true); + final ArrayList msgReceived = new ArrayList(); Connection connection = null; InitialContext initialContext = null; try @@ -74,7 +65,7 @@ public class MessagePriorityExample extends ActiveMQExample // Step 7. Create a JMS Message Consumer MessageConsumer redConsumer = session.createConsumer(queue); - redConsumer.setMessageListener(new SimpleMessageListener()); + redConsumer.setMessageListener(new SimpleMessageListener(msgReceived, result)); // Step 8. Create three messages TextMessage[] sentMessages = new TextMessage[3]; @@ -85,16 +76,16 @@ public class MessagePriorityExample extends ActiveMQExample // Step 9. Send the Messages, each has a different priority producer.send(sentMessages[0]); System.out.println("Message sent: " + sentMessages[0].getText() + - " with priority: " + - sentMessages[0].getJMSPriority()); + " with priority: " + + sentMessages[0].getJMSPriority()); producer.send(sentMessages[1], DeliveryMode.NON_PERSISTENT, 5, 0); System.out.println("Message sent: " + sentMessages[1].getText() + - "with priority: " + - sentMessages[1].getJMSPriority()); + "with priority: " + + sentMessages[1].getJMSPriority()); producer.send(sentMessages[2], DeliveryMode.NON_PERSISTENT, 9, 0); System.out.println("Message sent: " + sentMessages[2].getText() + - "with priority: " + - sentMessages[2].getJMSPriority()); + "with priority: " + + sentMessages[2].getJMSPriority()); // Step 10. Start the connection now. connection.start(); @@ -108,12 +99,12 @@ public class MessagePriorityExample extends ActiveMQExample TextMessage rm = msgReceived.get(i); if (!rm.getText().equals(sentMessages[2 - i].getText())) { - System.err.println("Priority is broken!"); - result = false; + throw new IllegalStateException("Priority is broken!"); } } - return result; + if (!result.get()) + throw new IllegalStateException(); } finally { @@ -128,28 +119,31 @@ public class MessagePriorityExample extends ActiveMQExample } } } +} - public class SimpleMessageListener implements MessageListener +class SimpleMessageListener implements MessageListener +{ + ArrayList msgReceived; + AtomicBoolean result; + + public SimpleMessageListener(ArrayList msgReceived, AtomicBoolean result) { + this.msgReceived = msgReceived; + this.result = result; + } - public SimpleMessageListener() + public void onMessage(final Message msg) + { + TextMessage textMessage = (TextMessage)msg; + try { + System.out.println("Received message : [" + textMessage.getText() + "]"); } - - public void onMessage(final Message msg) + catch (JMSException e) { - TextMessage textMessage = (TextMessage)msg; - try - { - System.out.println("Received message : [" + textMessage.getText() + "]"); - } - catch (JMSException e) - { - result = false; - } - msgReceived.add(textMessage); + result.set(false); } - + msgReceived.add(textMessage); } } diff --git a/examples/jms/message-priority/src/main/resources/activemq/server0/artemis-roles.properties b/examples/jms/message-priority/src/main/resources/activemq/server0/artemis-roles.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/message-priority/src/main/resources/activemq/server0/artemis-roles.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/message-priority/src/main/resources/activemq/server0/artemis-users.properties b/examples/jms/message-priority/src/main/resources/activemq/server0/artemis-users.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/message-priority/src/main/resources/activemq/server0/artemis-users.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/message-priority/src/main/resources/activemq/server0/broker.xml b/examples/jms/message-priority/src/main/resources/activemq/server0/broker.xml deleted file mode 100644 index 7690094861..0000000000 --- a/examples/jms/message-priority/src/main/resources/activemq/server0/broker.xml +++ /dev/null @@ -1,60 +0,0 @@ - - - - - - - - - - - - - ${data.dir}/server0/data/messaging/bindings - - ${data.dir}/server0/data/messaging/journal - - ${data.dir}/server0/data/messaging/largemessages - - ${data.dir}/server0/data/messaging/paging - - - - tcp://localhost:61616 - - - - - - - - - - - - - - - - - - diff --git a/examples/jms/multiple-failover-failback/pom.xml b/examples/jms/multiple-failover-failback/pom.xml index 0e429b7f6e..4ae6e9edf9 100644 --- a/examples/jms/multiple-failover-failback/pom.xml +++ b/examples/jms/multiple-failover-failback/pom.xml @@ -37,8 +37,8 @@ under the License. - org.apache.activemq.examples.jms - common + org.apache.activemq + artemis-cli ${project.version} @@ -57,13 +57,16 @@ under the License. artemis-maven-plugin - create + create0 create ${basedir}/target/server0 - ${basedir}/target/classes/activemq/server0 + true + false + ../data + true @@ -73,7 +76,10 @@ under the License. ${basedir}/target/server1 - ${basedir}/target/classes/activemq/server1 + true + true + ../data + true @@ -83,7 +89,9 @@ under the License. ${basedir}/target/server2 - ${basedir}/target/classes/activemq/server2 + true + true + ../data diff --git a/examples/jms/multiple-failover-failback/src/main/java/org/apache/activemq/artemis/jms/example/MultipleFailoverFailbackExample.java b/examples/jms/multiple-failover-failback/src/main/java/org/apache/activemq/artemis/jms/example/MultipleFailoverFailbackExample.java index 9ea1dc9642..dcfb685874 100644 --- a/examples/jms/multiple-failover-failback/src/main/java/org/apache/activemq/artemis/jms/example/MultipleFailoverFailbackExample.java +++ b/examples/jms/multiple-failover-failback/src/main/java/org/apache/activemq/artemis/jms/example/MultipleFailoverFailbackExample.java @@ -16,6 +16,8 @@ */ package org.apache.activemq.artemis.jms.example; +import org.apache.activemq.artemis.util.ServerUtil; + import javax.jms.Connection; import javax.jms.ConnectionFactory; import javax.jms.JMSException; @@ -26,28 +28,9 @@ import javax.jms.Session; import javax.jms.TextMessage; import javax.naming.InitialContext; -import org.apache.activemq.artemis.common.example.ActiveMQExample; - -public class MultipleFailoverFailbackExample extends ActiveMQExample +public class MultipleFailoverFailbackExample { public static void main(final String[] args) throws Exception - { - new MultipleFailoverFailbackExample().run(args); - } - - protected void startServers(String[] serversArgs) throws Exception - { - for (int i = 0; i < serversArgs.length; i++) - { - startServer(i, i == 0 ? 5000 : 0); - } - - Thread.sleep(5000); - } - - - @Override - public boolean runExample() throws Exception { final int numMessages = 30; @@ -55,8 +38,15 @@ public class MultipleFailoverFailbackExample extends ActiveMQExample InitialContext initialContext = null; + Process[] servers = new Process[3]; + try { + for (int i = 0; i < args.length; i++) + { + servers[i] = ServerUtil.startServer(args[i], MultipleFailoverFailbackExample.class.getSimpleName() + i, i, 5000); + } + // Step 1. Get an initial context for looking up JNDI from the server #1 initialContext = new InitialContext(); @@ -103,9 +93,7 @@ public class MultipleFailoverFailbackExample extends ActiveMQExample // Step 10. Crash server #1, the live server, and wait a little while to make sure // it has really crashed - Thread.sleep(2000); - killServer(0); - Thread.sleep(5000); + ServerUtil.killServer(servers[0]); // Step 11. Acknowledging the 2nd half of the sent messages will fail as failover to the // backup server has occurred @@ -126,8 +114,7 @@ public class MultipleFailoverFailbackExample extends ActiveMQExample } message0.acknowledge(); - Thread.sleep(2000); - startServer(0, 10000); + servers[0] = ServerUtil.startServer(args[0], MultipleFailoverFailbackExample.class.getSimpleName() + 0, 0, 5000); // Step 11. Acknowledging the 2nd half of the sent messages will fail as failover to the // backup server has occurred @@ -147,8 +134,6 @@ public class MultipleFailoverFailbackExample extends ActiveMQExample System.out.printf("Got message: %s (redelivered?: %s)%n", message0.getText(), message0.getJMSRedelivered()); } message0.acknowledge(); - - return true; } finally { @@ -163,6 +148,11 @@ public class MultipleFailoverFailbackExample extends ActiveMQExample { initialContext.close(); } + + for (int i = 0; i < args.length; i++) + { + ServerUtil.killServer(servers[i]); + } } } } diff --git a/examples/jms/multiple-failover-failback/src/main/resources/activemq/server0/artemis-roles.properties b/examples/jms/multiple-failover-failback/src/main/resources/activemq/server0/artemis-roles.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/multiple-failover-failback/src/main/resources/activemq/server0/artemis-roles.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/multiple-failover-failback/src/main/resources/activemq/server0/artemis-users.properties b/examples/jms/multiple-failover-failback/src/main/resources/activemq/server0/artemis-users.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/multiple-failover-failback/src/main/resources/activemq/server0/artemis-users.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/multiple-failover-failback/src/main/resources/activemq/server0/broker.xml b/examples/jms/multiple-failover-failback/src/main/resources/activemq/server0/broker.xml deleted file mode 100644 index 4cf5582e6b..0000000000 --- a/examples/jms/multiple-failover-failback/src/main/resources/activemq/server0/broker.xml +++ /dev/null @@ -1,93 +0,0 @@ - - - - - - - - - - - - - ../../server0/data/messaging/bindings - - ../../server0/data/messaging/journal - - ../../server0/data/messaging/largemessages - - ../../server0/data/messaging/paging - - - - - - - - - - tcp://localhost:61616 - - - - - tcp://localhost:61616 - - - - - ${udp-address:231.7.7.7} - 9876 - 1000 - netty-connector - - - - - - ${udp-address:231.7.7.7} - 9876 - 60000 - - - - - -
    jms
    - netty-connector - -
    -
    - - - - - - - - - - - - -
    -
    diff --git a/examples/jms/multiple-failover-failback/src/main/resources/activemq/server1/artemis-roles.properties b/examples/jms/multiple-failover-failback/src/main/resources/activemq/server1/artemis-roles.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/multiple-failover-failback/src/main/resources/activemq/server1/artemis-roles.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/multiple-failover-failback/src/main/resources/activemq/server1/artemis-users.properties b/examples/jms/multiple-failover-failback/src/main/resources/activemq/server1/artemis-users.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/multiple-failover-failback/src/main/resources/activemq/server1/artemis-users.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/multiple-failover-failback/src/main/resources/activemq/server1/broker.xml b/examples/jms/multiple-failover-failback/src/main/resources/activemq/server1/broker.xml deleted file mode 100644 index f910045c84..0000000000 --- a/examples/jms/multiple-failover-failback/src/main/resources/activemq/server1/broker.xml +++ /dev/null @@ -1,93 +0,0 @@ - - - - - - - - - - - - - ../../server0/data/messaging/bindings - - ../../server0/data/messaging/journal - - ../../server0/data/messaging/largemessages - - ../../server0/data/messaging/paging - - - - - - - - - - tcp://localhost:61617 - - - - - tcp://localhost:61617 - - - - - ${udp-address:231.7.7.7} - 9876 - 1000 - netty-connector - - - - - - ${udp-address:231.7.7.7} - 9876 - 60000 - - - - - -
    jms
    - netty-connector - -
    -
    - - - - - - - - - - - - -
    -
    diff --git a/examples/jms/multiple-failover-failback/src/main/resources/activemq/server2/artemis-roles.properties b/examples/jms/multiple-failover-failback/src/main/resources/activemq/server2/artemis-roles.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/multiple-failover-failback/src/main/resources/activemq/server2/artemis-roles.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/multiple-failover-failback/src/main/resources/activemq/server2/artemis-users.properties b/examples/jms/multiple-failover-failback/src/main/resources/activemq/server2/artemis-users.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/multiple-failover-failback/src/main/resources/activemq/server2/artemis-users.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/multiple-failover-failback/src/main/resources/activemq/server2/broker.xml b/examples/jms/multiple-failover-failback/src/main/resources/activemq/server2/broker.xml deleted file mode 100644 index 76a521a074..0000000000 --- a/examples/jms/multiple-failover-failback/src/main/resources/activemq/server2/broker.xml +++ /dev/null @@ -1,94 +0,0 @@ - - - - - - - - - - - - - ../../server0/data/messaging/bindings - - ../../server0/data/messaging/journal - - ../../server0/data/messaging/largemessages - - ../../server0/data/messaging/paging - - - - - - - - - tcp://localhost:61618 - - - - - tcp://localhost:61618 - - - - - ${udp-address:231.7.7.7} - 9876 - 1000 - netty-connector - - - - - - ${udp-address:231.7.7.7} - 9876 - 60000 - - - - - -
    jms
    - netty-connector - -
    -
    - - - - - - - - - - - - - - -
    -
    diff --git a/examples/jms/multiple-failover/pom.xml b/examples/jms/multiple-failover/pom.xml index a68679d947..cb00084618 100644 --- a/examples/jms/multiple-failover/pom.xml +++ b/examples/jms/multiple-failover/pom.xml @@ -37,8 +37,8 @@ under the License. - org.apache.activemq.examples.jms - common + org.apache.activemq + artemis-cli ${project.version} @@ -57,13 +57,16 @@ under the License. artemis-maven-plugin - create + create0 create ${basedir}/target/server0 - ${basedir}/target/classes/activemq/server0 + true + false + ../data + true @@ -73,7 +76,10 @@ under the License. ${basedir}/target/server1 - ${basedir}/target/classes/activemq/server1 + true + true + ../data + true @@ -83,7 +89,9 @@ under the License. ${basedir}/target/server2 - ${basedir}/target/classes/activemq/server2 + true + true + ../data diff --git a/examples/jms/multiple-failover/src/main/java/org/apache/activemq/artemis/jms/example/MultipleFailoverExample.java b/examples/jms/multiple-failover/src/main/java/org/apache/activemq/artemis/jms/example/MultipleFailoverExample.java index a2b55e4e7b..928e6fbf91 100644 --- a/examples/jms/multiple-failover/src/main/java/org/apache/activemq/artemis/jms/example/MultipleFailoverExample.java +++ b/examples/jms/multiple-failover/src/main/java/org/apache/activemq/artemis/jms/example/MultipleFailoverExample.java @@ -16,6 +16,8 @@ */ package org.apache.activemq.artemis.jms.example; +import org.apache.activemq.artemis.util.ServerUtil; + import javax.jms.Connection; import javax.jms.ConnectionFactory; import javax.jms.JMSException; @@ -26,28 +28,9 @@ import javax.jms.Session; import javax.jms.TextMessage; import javax.naming.InitialContext; -import org.apache.activemq.artemis.common.example.ActiveMQExample; - -public class MultipleFailoverExample extends ActiveMQExample +public class MultipleFailoverExample { public static void main(final String[] args) throws Exception - { - new MultipleFailoverExample().run(args); - } - - protected void startServers(String[] serversArgs) throws Exception - { - for (int i = 0; i < serversArgs.length; i++) - { - startServer(i, i == 0 ? 5000 : 0); - } - - Thread.sleep(5000); - } - - - @Override - public boolean runExample() throws Exception { final int numMessages = 30; @@ -55,8 +38,15 @@ public class MultipleFailoverExample extends ActiveMQExample InitialContext initialContext = null; + Process[] servers = new Process[3]; + try { + for (int i = 0; i < args.length; i++) + { + servers[i] = ServerUtil.startServer(args[i], MultipleFailoverExample.class.getSimpleName() + i, i, 5000); + } + // Step 1. Get an initial context for looking up JNDI from the server #1 initialContext = new InitialContext(); @@ -103,9 +93,7 @@ public class MultipleFailoverExample extends ActiveMQExample // Step 10. Crash server #1, the live server, and wait a little while to make sure // it has really crashed - Thread.sleep(1000); - killServer(0); - Thread.sleep(5000); + ServerUtil.killServer(servers[0]); // Step 11. Acknowledging the 2nd half of the sent messages will fail as failover to the // backup server has occurred @@ -126,9 +114,7 @@ public class MultipleFailoverExample extends ActiveMQExample } message0.acknowledge(); - Thread.sleep(1000); - killServer(getServer(connection)); - Thread.sleep(5000); + ServerUtil.killServer(servers[ServerUtil.getServer(connection)]); // Step 11. Acknowledging the 2nd half of the sent messages will fail as failover to the // backup server has occurred @@ -138,7 +124,7 @@ public class MultipleFailoverExample extends ActiveMQExample } catch (JMSException e) { - System.err.println("Got exception while acknowledging message: " + e.getMessage()); + throw new IllegalStateException("Got exception while acknowledging message: " + e.getMessage()); } // Step 12. Consume again the 2nd third of the messages again. Note that they are not considered as redelivered. @@ -148,8 +134,6 @@ public class MultipleFailoverExample extends ActiveMQExample System.out.printf("Got message: %s (redelivered?: %s)%n", message0.getText(), message0.getJMSRedelivered()); } message0.acknowledge(); - - return true; } finally { @@ -164,6 +148,11 @@ public class MultipleFailoverExample extends ActiveMQExample { initialContext.close(); } + + for (int i = 0; i < args.length; i++) + { + ServerUtil.killServer(servers[i]); + } } } } diff --git a/examples/jms/multiple-failover/src/main/resources/activemq/server0/artemis-roles.properties b/examples/jms/multiple-failover/src/main/resources/activemq/server0/artemis-roles.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/multiple-failover/src/main/resources/activemq/server0/artemis-roles.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/multiple-failover/src/main/resources/activemq/server0/artemis-users.properties b/examples/jms/multiple-failover/src/main/resources/activemq/server0/artemis-users.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/multiple-failover/src/main/resources/activemq/server0/artemis-users.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/multiple-failover/src/main/resources/activemq/server0/broker.xml b/examples/jms/multiple-failover/src/main/resources/activemq/server0/broker.xml deleted file mode 100644 index 323bfefa3a..0000000000 --- a/examples/jms/multiple-failover/src/main/resources/activemq/server0/broker.xml +++ /dev/null @@ -1,95 +0,0 @@ - - - - - - - - - - - - - ../../server0/data/messaging/bindings - - ../../server0/data/messaging/journal - - ../../server0/data/messaging/largemessages - - ../../server0/data/messaging/paging - - - - - - - - - - tcp://localhost:61616 - - - - - tcp://localhost:61616 - - - - - ${udp-address:231.7.7.7} - 9876 - 1000 - netty-connector - - - - - - ${udp-address:231.7.7.7} - 9876 - 60000 - - - - - -
    jms
    - netty-connector - -
    -
    - - - - - - - - - - - - - - -
    -
    diff --git a/examples/jms/multiple-failover/src/main/resources/activemq/server1/artemis-roles.properties b/examples/jms/multiple-failover/src/main/resources/activemq/server1/artemis-roles.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/multiple-failover/src/main/resources/activemq/server1/artemis-roles.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/multiple-failover/src/main/resources/activemq/server1/artemis-users.properties b/examples/jms/multiple-failover/src/main/resources/activemq/server1/artemis-users.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/multiple-failover/src/main/resources/activemq/server1/artemis-users.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/multiple-failover/src/main/resources/activemq/server1/broker.xml b/examples/jms/multiple-failover/src/main/resources/activemq/server1/broker.xml deleted file mode 100644 index f910045c84..0000000000 --- a/examples/jms/multiple-failover/src/main/resources/activemq/server1/broker.xml +++ /dev/null @@ -1,93 +0,0 @@ - - - - - - - - - - - - - ../../server0/data/messaging/bindings - - ../../server0/data/messaging/journal - - ../../server0/data/messaging/largemessages - - ../../server0/data/messaging/paging - - - - - - - - - - tcp://localhost:61617 - - - - - tcp://localhost:61617 - - - - - ${udp-address:231.7.7.7} - 9876 - 1000 - netty-connector - - - - - - ${udp-address:231.7.7.7} - 9876 - 60000 - - - - - -
    jms
    - netty-connector - -
    -
    - - - - - - - - - - - - -
    -
    diff --git a/examples/jms/multiple-failover/src/main/resources/activemq/server2/artemis-roles.properties b/examples/jms/multiple-failover/src/main/resources/activemq/server2/artemis-roles.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/multiple-failover/src/main/resources/activemq/server2/artemis-roles.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/multiple-failover/src/main/resources/activemq/server2/artemis-users.properties b/examples/jms/multiple-failover/src/main/resources/activemq/server2/artemis-users.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/multiple-failover/src/main/resources/activemq/server2/artemis-users.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/multiple-failover/src/main/resources/activemq/server2/broker.xml b/examples/jms/multiple-failover/src/main/resources/activemq/server2/broker.xml deleted file mode 100644 index c114ed20c2..0000000000 --- a/examples/jms/multiple-failover/src/main/resources/activemq/server2/broker.xml +++ /dev/null @@ -1,93 +0,0 @@ - - - - - - - - - - - - - ../../server0/data/messaging/bindings - - ../../server0/data/messaging/journal - - ../../server0/data/messaging/largemessages - - ../../server0/data/messaging/paging - - - - - - - - - - tcp://localhost:61618 - - - - - tcp://localhost:61618 - - - - - ${udp-address:231.7.7.7} - 9876 - 1000 - netty-connector - - - - - - ${udp-address:231.7.7.7} - 9876 - 60000 - - - - - -
    jms
    - netty-connector - -
    -
    - - - - - - - - - - - - -
    -
    diff --git a/examples/jms/no-consumer-buffering/pom.xml b/examples/jms/no-consumer-buffering/pom.xml index 6e4818f46d..19d91783d8 100644 --- a/examples/jms/no-consumer-buffering/pom.xml +++ b/examples/jms/no-consumer-buffering/pom.xml @@ -36,11 +36,6 @@ under the License. - - org.apache.activemq.examples.jms - common - ${project.version} - org.apache.geronimo.specs geronimo-jms_2.0_spec @@ -61,9 +56,18 @@ under the License. create +
    + + start + + cli + - ${basedir}/target/server0 - ${basedir}/target/classes/activemq/server0 + true + tcp://localhost:61616 + + run + @@ -73,8 +77,16 @@ under the License. org.apache.activemq.artemis.jms.example.NoConsumerBufferingExample + + + + stop + + cli + + - ${basedir}/target/server0 + stop @@ -91,5 +103,4 @@ under the License.
    - diff --git a/examples/jms/no-consumer-buffering/src/main/java/org/apache/activemq/artemis/jms/example/NoConsumerBufferingExample.java b/examples/jms/no-consumer-buffering/src/main/java/org/apache/activemq/artemis/jms/example/NoConsumerBufferingExample.java index b4bc2037fd..525a9c422c 100644 --- a/examples/jms/no-consumer-buffering/src/main/java/org/apache/activemq/artemis/jms/example/NoConsumerBufferingExample.java +++ b/examples/jms/no-consumer-buffering/src/main/java/org/apache/activemq/artemis/jms/example/NoConsumerBufferingExample.java @@ -25,21 +25,13 @@ import javax.jms.Session; import javax.jms.TextMessage; import javax.naming.InitialContext; -import org.apache.activemq.artemis.common.example.ActiveMQExample; - /** * This example demonstrates how ActiveMQ Artemis consumers can be configured to not buffer any messages from * the server. */ -public class NoConsumerBufferingExample extends ActiveMQExample +public class NoConsumerBufferingExample { - public static void main(final String[] args) - { - new NoConsumerBufferingExample().run(args); - } - - @Override - public boolean runExample() throws Exception + public static void main(final String[] args) throws Exception { Connection connection = null; InitialContext initialContext = null; @@ -114,8 +106,6 @@ public class NoConsumerBufferingExample extends ActiveMQExample System.out.println("Consumed message from consumer1: " + message.getText()); } - - return true; } finally { @@ -131,5 +121,4 @@ public class NoConsumerBufferingExample extends ActiveMQExample } } } - } diff --git a/examples/jms/no-consumer-buffering/src/main/resources/activemq/server0/artemis-roles.properties b/examples/jms/no-consumer-buffering/src/main/resources/activemq/server0/artemis-roles.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/no-consumer-buffering/src/main/resources/activemq/server0/artemis-roles.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/no-consumer-buffering/src/main/resources/activemq/server0/artemis-users.properties b/examples/jms/no-consumer-buffering/src/main/resources/activemq/server0/artemis-users.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/no-consumer-buffering/src/main/resources/activemq/server0/artemis-users.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/no-consumer-buffering/src/main/resources/activemq/server0/broker.xml b/examples/jms/no-consumer-buffering/src/main/resources/activemq/server0/broker.xml deleted file mode 100644 index 7690094861..0000000000 --- a/examples/jms/no-consumer-buffering/src/main/resources/activemq/server0/broker.xml +++ /dev/null @@ -1,60 +0,0 @@ - - - - - - - - - - - - - ${data.dir}/server0/data/messaging/bindings - - ${data.dir}/server0/data/messaging/journal - - ${data.dir}/server0/data/messaging/largemessages - - ${data.dir}/server0/data/messaging/paging - - - - tcp://localhost:61616 - - - - - - - - - - - - - - - - - - diff --git a/examples/jms/non-transaction-failover/pom.xml b/examples/jms/non-transaction-failover/pom.xml index 675dc23c5a..72d463619b 100644 --- a/examples/jms/non-transaction-failover/pom.xml +++ b/examples/jms/non-transaction-failover/pom.xml @@ -27,7 +27,7 @@ under the License. 1.0.1-SNAPSHOT - non-transaction-failover + artemis-jms-non-transaction-failover-example jar ActiveMQ Artemis JMS Non Transaction Failover Example @@ -37,8 +37,8 @@ under the License. - org.apache.activemq.examples.jms - common + org.apache.activemq + artemis-cli ${project.version} @@ -57,13 +57,16 @@ under the License. artemis-maven-plugin - create + create0 create ${basedir}/target/server0 - ${basedir}/target/classes/activemq/server0 + true + false + ../data + true @@ -73,7 +76,10 @@ under the License. ${basedir}/target/server1 - ${basedir}/target/classes/activemq/server1 + true + true + ../data + true @@ -93,7 +99,7 @@ under the License. org.apache.activemq.examples.jms - non-transaction-failover + artemis-jms-non-transaction-failover-example ${project.version} diff --git a/examples/jms/non-transaction-failover/src/main/java/org/apache/activemq/artemis/jms/example/NonTransactionFailoverExample.java b/examples/jms/non-transaction-failover/src/main/java/org/apache/activemq/artemis/jms/example/NonTransactionFailoverExample.java index e690fd607e..c5560722d7 100644 --- a/examples/jms/non-transaction-failover/src/main/java/org/apache/activemq/artemis/jms/example/NonTransactionFailoverExample.java +++ b/examples/jms/non-transaction-failover/src/main/java/org/apache/activemq/artemis/jms/example/NonTransactionFailoverExample.java @@ -16,6 +16,8 @@ */ package org.apache.activemq.artemis.jms.example; +import org.apache.activemq.artemis.util.ServerUtil; + import javax.jms.Connection; import javax.jms.ConnectionFactory; import javax.jms.JMSException; @@ -26,31 +28,13 @@ import javax.jms.Session; import javax.jms.TextMessage; import javax.naming.InitialContext; -import org.apache.activemq.artemis.common.example.ActiveMQExample; - /** * A simple example that demonstrates failover of the JMS connection from one node to another * when the live server crashes using a JMS non-transacted session. */ -public class NonTransactionFailoverExample extends ActiveMQExample +public class NonTransactionFailoverExample { public static void main(final String[] args) throws Exception - { - new NonTransactionFailoverExample().run(args); - } - - protected void startServers(String[] serversArgs) throws Exception - { - for (int i = 0; i < serversArgs.length; i++) - { - startServer(i, i == 0 ? 5000 : 0); - } - - Thread.sleep(5000); - } - - @Override - public boolean runExample() throws Exception { final int numMessages = 10; @@ -58,8 +42,15 @@ public class NonTransactionFailoverExample extends ActiveMQExample InitialContext initialContext = null; + Process[] servers = new Process[2]; + try { + for (int i = 0; i < args.length; i++) + { + servers[i] = ServerUtil.startServer(args[i], NonTransactionFailoverExample.class.getSimpleName() + i, i, 5000); + } + // Step 1. Get an initial context for looking up JNDI from the server #1 initialContext = new InitialContext(); @@ -106,9 +97,7 @@ public class NonTransactionFailoverExample extends ActiveMQExample // Step 10. Crash server #1, the live server, and wait a little while to make sure // pending Acks are on the server's side - Thread.sleep(2000); - killServer(0); - Thread.sleep(5000); + ServerUtil.killServer(servers[0]); // Step 11. Acknowledging the 2nd half of the sent messages will fail as failover to the // backup server has occurred @@ -128,8 +117,6 @@ public class NonTransactionFailoverExample extends ActiveMQExample System.out.printf("Got message: %s (redelivered?: %s)%n", message0.getText(), message0.getJMSRedelivered()); } message0.acknowledge(); - - return true; } finally { @@ -144,7 +131,11 @@ public class NonTransactionFailoverExample extends ActiveMQExample { initialContext.close(); } + + for (int i = 0; i < args.length; i++) + { + ServerUtil.killServer(servers[i]); + } } } - } diff --git a/examples/jms/non-transaction-failover/src/main/resources/activemq/server0/artemis-roles.properties b/examples/jms/non-transaction-failover/src/main/resources/activemq/server0/artemis-roles.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/non-transaction-failover/src/main/resources/activemq/server0/artemis-roles.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/non-transaction-failover/src/main/resources/activemq/server0/artemis-users.properties b/examples/jms/non-transaction-failover/src/main/resources/activemq/server0/artemis-users.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/non-transaction-failover/src/main/resources/activemq/server0/artemis-users.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/non-transaction-failover/src/main/resources/activemq/server0/broker.xml b/examples/jms/non-transaction-failover/src/main/resources/activemq/server0/broker.xml deleted file mode 100644 index 00e724b433..0000000000 --- a/examples/jms/non-transaction-failover/src/main/resources/activemq/server0/broker.xml +++ /dev/null @@ -1,93 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - tcp://localhost:61616 - - - - - tcp://localhost:61616 - - - - - ${udp-address:231.7.7.7} - 9876 - 1000 - netty-connector - - - - - - ${udp-address:231.7.7.7} - 9876 - 60000 - - - - - -
    jms
    - netty-connector - -
    -
    - - ../../server0/data/large-messages - ../../server0/data/bindings - ../../server0/data/journal - ../../server0/data/paging - - - - - - - - - - - - - - -
    -
    diff --git a/examples/jms/non-transaction-failover/src/main/resources/activemq/server1/artemis-roles.properties b/examples/jms/non-transaction-failover/src/main/resources/activemq/server1/artemis-roles.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/non-transaction-failover/src/main/resources/activemq/server1/artemis-roles.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/non-transaction-failover/src/main/resources/activemq/server1/artemis-users.properties b/examples/jms/non-transaction-failover/src/main/resources/activemq/server1/artemis-users.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/non-transaction-failover/src/main/resources/activemq/server1/artemis-users.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/non-transaction-failover/src/main/resources/activemq/server1/broker.xml b/examples/jms/non-transaction-failover/src/main/resources/activemq/server1/broker.xml deleted file mode 100644 index 0406b8fad9..0000000000 --- a/examples/jms/non-transaction-failover/src/main/resources/activemq/server1/broker.xml +++ /dev/null @@ -1,94 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - tcp://localhost:61617 - - - - - tcp://localhost:61617 - - - - - ${udp-address:231.7.7.7} - 9876 - 1000 - netty-connector - - - - - - ${udp-address:231.7.7.7} - 9876 - 60000 - - - - - -
    jms
    - netty-connector - -
    -
    - - ../../server0/data/large-messages - ../../server0/data/bindings - ../../server0/data/journal - ../../server0/data/paging - - - - - - - - - - - - - - - -
    -
    diff --git a/examples/jms/openwire/pom.xml b/examples/jms/openwire/pom.xml index 1ee5cfc6e2..3888f12e5f 100644 --- a/examples/jms/openwire/pom.xml +++ b/examples/jms/openwire/pom.xml @@ -35,6 +35,17 @@ under the License. ${project.basedir}/../../.. + + + org.apache.geronimo.specs + geronimo-jms_2.0_spec + + + org.apache.activemq + activemq-client + + + example @@ -49,9 +60,18 @@ under the License. create +
    + + start + + cli + - ${basedir}/target/server0 - ${basedir}/target/classes/activemq/server0 + true + tcp://localhost:61616 + + run + @@ -61,8 +81,16 @@ under the License. org.apache.activemq.artemis.jms.example.OpenWireExample + + + + stop + + cli + + - ${basedir}/target/server0 + stop @@ -79,21 +107,4 @@ under the License. - - - org.apache.activemq.examples.jms - common - ${project.version} - - - org.apache.geronimo.specs - geronimo-jms_2.0_spec - - - org.apache.activemq - activemq-client - - - - diff --git a/examples/jms/openwire/src/main/java/org/apache/activemq/artemis/jms/example/OpenWireExample.java b/examples/jms/openwire/src/main/java/org/apache/activemq/artemis/jms/example/OpenWireExample.java index bd3b22399e..202e1b0e8a 100644 --- a/examples/jms/openwire/src/main/java/org/apache/activemq/artemis/jms/example/OpenWireExample.java +++ b/examples/jms/openwire/src/main/java/org/apache/activemq/artemis/jms/example/OpenWireExample.java @@ -26,24 +26,19 @@ import javax.jms.TextMessage; import org.apache.activemq.ActiveMQConnectionFactory; import org.apache.activemq.command.ActiveMQQueue; -import org.apache.activemq.artemis.common.example.ActiveMQExample; + +import java.lang.Exception; /** * A simple JMS Queue example that creates a producer and consumer on a queue * and sends then receives a message. */ -public class OpenWireExample extends ActiveMQExample +public class OpenWireExample { public static final String OWHOST = "localhost"; public static final int OWPORT = 61616; - public static void main(final String[] args) - { - new OpenWireExample().run(args); - } - - @Override - public boolean runExample() throws Exception + public static void main(final String[] args) throws Exception { Connection connection = null; @@ -84,8 +79,6 @@ public class OpenWireExample extends ActiveMQExample TextMessage messageReceived = (TextMessage) messageConsumer.receive(5000); System.out.println("Received message: " + messageReceived.getText()); - - return true; } finally { diff --git a/examples/jms/paging/pom.xml b/examples/jms/paging/pom.xml index 83103edf98..954aad947c 100644 --- a/examples/jms/paging/pom.xml +++ b/examples/jms/paging/pom.xml @@ -36,11 +36,6 @@ under the License. - - org.apache.activemq.examples.jms - common - ${project.version} - org.apache.geronimo.specs geronimo-jms_2.0_spec @@ -61,9 +56,18 @@ under the License. create + + + start + + cli + - ${basedir}/target/server0 - ${basedir}/target/classes/activemq/server0 + true + tcp://localhost:61616 + + run + @@ -73,8 +77,16 @@ under the License. org.apache.activemq.artemis.jms.example.PagingExample + + + + stop + + cli + + - ${basedir}/target/server0 + stop diff --git a/examples/jms/paging/src/main/java/org/apache/activemq/artemis/jms/example/PagingExample.java b/examples/jms/paging/src/main/java/org/apache/activemq/artemis/jms/example/PagingExample.java index d627c5a5d3..77f8eb6595 100644 --- a/examples/jms/paging/src/main/java/org/apache/activemq/artemis/jms/example/PagingExample.java +++ b/examples/jms/paging/src/main/java/org/apache/activemq/artemis/jms/example/PagingExample.java @@ -26,20 +26,12 @@ import javax.jms.Queue; import javax.jms.Session; import javax.naming.InitialContext; -import org.apache.activemq.artemis.common.example.ActiveMQExample; - /** * A simple JMS Queue example that creates a producer and consumer on a queue and sends then receives a message. */ -public class PagingExample extends ActiveMQExample +public class PagingExample { - public static void main(final String[] args) - { - new PagingExample().run(args); - } - - @Override - public boolean runExample() throws Exception + public static void main(final String[] args) throws Exception { Connection connection = null; @@ -133,9 +125,6 @@ public class PagingExample extends ActiveMQExample message.acknowledge(); } - - return true; - } finally { @@ -153,5 +142,4 @@ public class PagingExample extends ActiveMQExample } } } - } diff --git a/examples/jms/perf/pom.xml b/examples/jms/perf/pom.xml index 2db189aa17..b348a704ed 100644 --- a/examples/jms/perf/pom.xml +++ b/examples/jms/perf/pom.xml @@ -36,6 +36,16 @@ under the License. + + org.apache.activemq + artemis-server + ${project.version} + + + org.apache.activemq + artemis-jms-server + ${project.version} + org.apache.activemq artemis-core-client @@ -55,11 +65,6 @@ under the License. org.apache.geronimo.specs geronimo-jms_2.0_spec - - org.apache.activemq.examples.jms - common - ${project.version} - @@ -76,10 +81,6 @@ under the License. create - - ${basedir}/target/server0 - ${basedir}/target/classes/activemq/server0 - runClient @@ -88,9 +89,6 @@ under the License. org.apache.activemq.artemis.jms.example.Server - - ${basedir}/target/server0 -
    @@ -100,6 +98,11 @@ under the License. artemis-jms-perf-example ${project.version}
    + + org.apache.activemq + artemis-core-client + ${project.version} +
    diff --git a/examples/jms/pom.xml b/examples/jms/pom.xml index 4103a8ff04..4c8db041f7 100644 --- a/examples/jms/pom.xml +++ b/examples/jms/pom.xml @@ -41,10 +41,9 @@ under the License. release - common aerogear - artemis-ra-rar application-layer-failover + artemis-ra-rar bridge browser client-kickoff @@ -141,7 +140,6 @@ under the License. true - common application-layer-failover bridge browser @@ -150,11 +148,14 @@ under the License. client-side-failoverlistener clustered-durable-subscription clustered-grouping + clustered-jgroups clustered-queue clustered-standalone clustered-static-oneway clustered-static-discovery clustered-topic + colocated-failover + colocated-failover-scale-down consumer-rate-limit dead-letter delayed-redelivery @@ -163,10 +164,15 @@ under the License. embedded embedded-simple expiry + ha-policy-autobackup http-transport interceptor + jms-auto-closeable instantiate-connection-factory jms-bridge + jms-completion-listener + jms-context + jms-shared-consumer jmx large-message last-value-queue @@ -180,27 +186,39 @@ under the License. multiple-failover-failback no-consumer-buffering non-transaction-failover + openwire paging + pre-acknowledge producer-rate-limit + proton-cpp + proton-j + proton-ruby queue queue-message-redistribution queue-requestor queue-selector reattach-node + replicated-failback + replicated-failback-static replicated-multiple-failover replicated-transaction-failover request-reply + rest + scale-down scheduled-message security send-acknowledgements spring-integration ssl-enabled + static-selector + static-selector-jms stomp stomp1.1 + stomp1.2 symmetric-cluster diff --git a/examples/jms/pre-acknowledge/pom.xml b/examples/jms/pre-acknowledge/pom.xml index 030d77fc86..b181706838 100644 --- a/examples/jms/pre-acknowledge/pom.xml +++ b/examples/jms/pre-acknowledge/pom.xml @@ -37,8 +37,8 @@ under the License. - org.apache.activemq.examples.jms - common + org.apache.activemq + artemis-jms-client ${project.version} @@ -61,9 +61,18 @@ under the License. create + + + start + + cli + - ${basedir}/target/server0 - ${basedir}/target/classes/activemq/server0 + true + tcp://localhost:61616 + + run + @@ -73,8 +82,16 @@ under the License. org.apache.activemq.artemis.jms.example.PreacknowledgeExample + + + + stop + + cli + + - ${basedir}/target/server0 + stop diff --git a/examples/jms/pre-acknowledge/src/main/java/org/apache/activemq/artemis/jms/example/PreacknowledgeExample.java b/examples/jms/pre-acknowledge/src/main/java/org/apache/activemq/artemis/jms/example/PreacknowledgeExample.java index 076c98979b..446cec0468 100644 --- a/examples/jms/pre-acknowledge/src/main/java/org/apache/activemq/artemis/jms/example/PreacknowledgeExample.java +++ b/examples/jms/pre-acknowledge/src/main/java/org/apache/activemq/artemis/jms/example/PreacknowledgeExample.java @@ -32,7 +32,6 @@ import javax.naming.InitialContext; import org.apache.activemq.artemis.api.jms.ActiveMQJMSClient; import org.apache.activemq.artemis.api.jms.ActiveMQJMSConstants; import org.apache.activemq.artemis.api.jms.management.JMSManagementHelper; -import org.apache.activemq.artemis.common.example.ActiveMQExample; /** * This example demonstrates the use of ActiveMQ Artemis "pre-acknowledge" functionality where @@ -40,15 +39,9 @@ import org.apache.activemq.artemis.common.example.ActiveMQExample; * * Please see the readme.html for more details. */ -public class PreacknowledgeExample extends ActiveMQExample +public class PreacknowledgeExample { - public static void main(final String[] args) - { - new PreacknowledgeExample().run(args); - } - - @Override - public boolean runExample() throws Exception + public static void main(final String[] args) throws Exception { Connection connection = null; @@ -98,15 +91,13 @@ public class PreacknowledgeExample extends ActiveMQExample if (count != 0) { - return false; + throw new IllegalStateException("Queue message count is not 0."); } // Step 8. Finally, receive the message TextMessage messageReceived = (TextMessage)messageConsumer.receive(5000); System.out.println("Received message: " + messageReceived.getText()); - - return true; } finally { @@ -124,7 +115,7 @@ public class PreacknowledgeExample extends ActiveMQExample // To do this we send a management message to get the message count. // In real life you wouldn't create a new session every time you send a management message - private int getMessageCount(final Connection connection) throws Exception + private static int getMessageCount(final Connection connection) throws Exception { QueueSession session = ((QueueConnection)connection).createQueueSession(false, Session.AUTO_ACKNOWLEDGE); diff --git a/examples/jms/producer-rate-limit/pom.xml b/examples/jms/producer-rate-limit/pom.xml index 535a7d562d..d407ea3a1b 100644 --- a/examples/jms/producer-rate-limit/pom.xml +++ b/examples/jms/producer-rate-limit/pom.xml @@ -36,11 +36,6 @@ under the License. - - org.apache.activemq.examples.jms - common - ${project.version} - org.apache.geronimo.specs geronimo-jms_2.0_spec @@ -61,9 +56,18 @@ under the License. create + + + start + + cli + - ${basedir}/target/server0 - ${basedir}/target/classes/activemq/server0 + true + tcp://localhost:61616 + + run + @@ -73,8 +77,16 @@ under the License. org.apache.activemq.artemis.jms.example.ProducerRateLimitExample + + + + stop + + cli + + - ${basedir}/target/server0 + stop diff --git a/examples/jms/producer-rate-limit/src/main/java/org/apache/activemq/artemis/jms/example/ProducerRateLimitExample.java b/examples/jms/producer-rate-limit/src/main/java/org/apache/activemq/artemis/jms/example/ProducerRateLimitExample.java index 3640cdc9f4..c949122161 100644 --- a/examples/jms/producer-rate-limit/src/main/java/org/apache/activemq/artemis/jms/example/ProducerRateLimitExample.java +++ b/examples/jms/producer-rate-limit/src/main/java/org/apache/activemq/artemis/jms/example/ProducerRateLimitExample.java @@ -25,21 +25,13 @@ import javax.jms.Session; import javax.jms.TextMessage; import javax.naming.InitialContext; -import org.apache.activemq.artemis.common.example.ActiveMQExample; - /** * This example demonstrates how a message producer can be limited to produce messages at a maximum rate * specified in messages per sec. */ -public class ProducerRateLimitExample extends ActiveMQExample +public class ProducerRateLimitExample { - public static void main(final String[] args) - { - new ProducerRateLimitExample().run(args); - } - - @Override - public boolean runExample() throws Exception + public static void main(final String[] args) throws Exception { Connection connection = null; InitialContext initialContext = null; @@ -110,8 +102,6 @@ public class ProducerRateLimitExample extends ActiveMQExample } System.out.println("Received " + i + " messages"); - - return true; } finally { @@ -126,5 +116,4 @@ public class ProducerRateLimitExample extends ActiveMQExample } } } - } diff --git a/examples/jms/producer-rate-limit/src/main/resources/activemq/server0/artemis-roles.properties b/examples/jms/producer-rate-limit/src/main/resources/activemq/server0/artemis-roles.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/producer-rate-limit/src/main/resources/activemq/server0/artemis-roles.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/producer-rate-limit/src/main/resources/activemq/server0/artemis-users.properties b/examples/jms/producer-rate-limit/src/main/resources/activemq/server0/artemis-users.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/producer-rate-limit/src/main/resources/activemq/server0/artemis-users.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/producer-rate-limit/src/main/resources/activemq/server0/broker.xml b/examples/jms/producer-rate-limit/src/main/resources/activemq/server0/broker.xml deleted file mode 100644 index 7690094861..0000000000 --- a/examples/jms/producer-rate-limit/src/main/resources/activemq/server0/broker.xml +++ /dev/null @@ -1,60 +0,0 @@ - - - - - - - - - - - - - ${data.dir}/server0/data/messaging/bindings - - ${data.dir}/server0/data/messaging/journal - - ${data.dir}/server0/data/messaging/largemessages - - ${data.dir}/server0/data/messaging/paging - - - - tcp://localhost:61616 - - - - - - - - - - - - - - - - - - diff --git a/examples/jms/proton-cpp/pom.xml b/examples/jms/proton-cpp/pom.xml index c5e41a4d66..240667d032 100644 --- a/examples/jms/proton-cpp/pom.xml +++ b/examples/jms/proton-cpp/pom.xml @@ -37,8 +37,8 @@ under the License. - org.apache.activemq.examples.jms - common + org.apache.activemq + artemis-jms-client ${project.version} @@ -61,9 +61,18 @@ under the License. create + + + start + + cli + - ${basedir}/target/server0 - ${basedir}/target/classes/activemq/server0 + true + tcp://localhost:61616 + + run + @@ -73,8 +82,16 @@ under the License. org.apache.activemq.artemis.jms.example.ProtonCPPExample + + + + stop + + cli + + - ${basedir}/target/server0 + stop diff --git a/examples/jms/proton-cpp/src/main/java/org/apache/activemq/artemis/jms/example/ProtonCPPExample.java b/examples/jms/proton-cpp/src/main/java/org/apache/activemq/artemis/jms/example/ProtonCPPExample.java index b23dc55127..79c6bbc78f 100644 --- a/examples/jms/proton-cpp/src/main/java/org/apache/activemq/artemis/jms/example/ProtonCPPExample.java +++ b/examples/jms/proton-cpp/src/main/java/org/apache/activemq/artemis/jms/example/ProtonCPPExample.java @@ -30,7 +30,6 @@ import javax.naming.InitialContext; import org.apache.activemq.artemis.api.jms.ActiveMQJMSClient; import org.apache.activemq.artemis.api.jms.management.JMSManagementHelper; -import org.apache.activemq.artemis.common.example.ActiveMQExample; /** * This example demonstrates the use of ActiveMQ Artemis "pre-acknowledge" functionality where @@ -38,15 +37,9 @@ import org.apache.activemq.artemis.common.example.ActiveMQExample; * * Please see the readme.html for more details. */ -public class ProtonCPPExample extends ActiveMQExample +public class ProtonCPPExample { - public static void main(final String[] args) - { - new ProtonCPPExample().run(args); - } - - @Override - public boolean runExample() throws Exception + public static void main(final String[] args) throws Exception { Connection connection = null; @@ -95,8 +88,6 @@ public class ProtonCPPExample extends ActiveMQExample // Sending message back to client producerAnswer.send(session.createTextMessage("HELLO from Apache ActiveMQ Artemis")); } - - return true; } finally { diff --git a/examples/jms/proton-cpp/src/main/resources/activemq/server0/artemis-roles.properties b/examples/jms/proton-cpp/src/main/resources/activemq/server0/artemis-roles.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/proton-cpp/src/main/resources/activemq/server0/artemis-roles.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/proton-cpp/src/main/resources/activemq/server0/artemis-users.properties b/examples/jms/proton-cpp/src/main/resources/activemq/server0/artemis-users.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/proton-cpp/src/main/resources/activemq/server0/artemis-users.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/proton-cpp/src/main/resources/activemq/server0/broker.xml b/examples/jms/proton-cpp/src/main/resources/activemq/server0/broker.xml deleted file mode 100644 index eafc6c8f1d..0000000000 --- a/examples/jms/proton-cpp/src/main/resources/activemq/server0/broker.xml +++ /dev/null @@ -1,61 +0,0 @@ - - - - - - - - - - - - - ${data.dir}/server0/data/messaging/bindings - - ${data.dir}/server0/data/messaging/journal - - ${data.dir}/server0/data/messaging/largemessages - - ${data.dir}/server0/data/messaging/paging - - - - - tcp://localhost:61616 - - - - - - - - - - - - - - - - - - diff --git a/examples/jms/proton-j/pom.xml b/examples/jms/proton-j/pom.xml index 3001867f21..2cdf0c823b 100644 --- a/examples/jms/proton-j/pom.xml +++ b/examples/jms/proton-j/pom.xml @@ -36,11 +36,6 @@ under the License. - - org.apache.activemq.examples.jms - common - ${project.version} - org.apache.qpid qpid-amqp-1-0-client @@ -62,9 +57,18 @@ under the License. create + + + start + + cli + - ${basedir}/target/server0 - ${basedir}/target/classes/activemq/server0 + true + tcp://localhost:61616 + + run + @@ -74,8 +78,16 @@ under the License. org.apache.activemq.artemis.jms.example.ProtonJExample + + + + stop + + cli + + - ${basedir}/target/server0 + stop diff --git a/examples/jms/proton-j/src/main/java/org/apache/activemq/artemis/jms/example/ProtonJExample.java b/examples/jms/proton-j/src/main/java/org/apache/activemq/artemis/jms/example/ProtonJExample.java index adb3303a7a..482151d239 100644 --- a/examples/jms/proton-j/src/main/java/org/apache/activemq/artemis/jms/example/ProtonJExample.java +++ b/examples/jms/proton-j/src/main/java/org/apache/activemq/artemis/jms/example/ProtonJExample.java @@ -23,16 +23,10 @@ import org.apache.qpid.amqp_1_0.client.Receiver; import org.apache.qpid.amqp_1_0.client.Sender; import org.apache.qpid.amqp_1_0.client.Session; import org.apache.qpid.amqp_1_0.type.UnsignedInteger; -import org.apache.activemq.artemis.common.example.ActiveMQExample; -public class ProtonJExample extends ActiveMQExample +public class ProtonJExample { - public static void main(String[] args) - { - new ProtonJExample().run(args); - } - @Override - public boolean runExample() throws Exception + public static void main(String[] args) throws Exception { Connection connection = null; @@ -71,7 +65,5 @@ public class ProtonJExample extends ActiveMQExample connection.close(); } } - - return true; } } diff --git a/examples/jms/proton-ruby/pom.xml b/examples/jms/proton-ruby/pom.xml index b00e3086d7..54f2269e2c 100644 --- a/examples/jms/proton-ruby/pom.xml +++ b/examples/jms/proton-ruby/pom.xml @@ -35,14 +35,6 @@ under the License. ${project.basedir}/../../.. - - - org.apache.activemq.examples.jms - common - ${project.version} - - - example diff --git a/examples/jms/queue-message-redistribution/pom.xml b/examples/jms/queue-message-redistribution/pom.xml index c54657c387..8100fcc6cd 100644 --- a/examples/jms/queue-message-redistribution/pom.xml +++ b/examples/jms/queue-message-redistribution/pom.xml @@ -36,11 +36,6 @@ under the License. - - org.apache.activemq.examples.jms - common - ${project.version} - org.apache.geronimo.specs geronimo-jms_2.0_spec @@ -57,7 +52,7 @@ under the License. artemis-maven-plugin - create + create0 create @@ -67,7 +62,7 @@ under the License. - create2 + create1 create @@ -76,6 +71,36 @@ under the License. ${basedir}/target/classes/activemq/server1 + + start0 + + cli + + + true + ${basedir}/target/server0 + tcp://localhost:61616 + + run + + server0 + + + + start1 + + cli + + + true + ${basedir}/target/server1 + tcp://localhost:61617 + + run + + server1 + + runClient @@ -83,9 +108,29 @@ under the License. org.apache.activemq.artemis.jms.example.QueueMessageRedistributionExample + + + + stop0 + + cli + + + ${basedir}/target/server0 - ${basedir}/target/server0 - ${basedir}/target/server1 + stop + + + + + stop1 + + cli + + + ${basedir}/target/server1 + + stop diff --git a/examples/jms/queue-message-redistribution/src/main/java/org/apache/activemq/artemis/jms/example/QueueMessageRedistributionExample.java b/examples/jms/queue-message-redistribution/src/main/java/org/apache/activemq/artemis/jms/example/QueueMessageRedistributionExample.java index a1d0a8f143..aec56b1a10 100644 --- a/examples/jms/queue-message-redistribution/src/main/java/org/apache/activemq/artemis/jms/example/QueueMessageRedistributionExample.java +++ b/examples/jms/queue-message-redistribution/src/main/java/org/apache/activemq/artemis/jms/example/QueueMessageRedistributionExample.java @@ -26,23 +26,15 @@ import javax.jms.TextMessage; import javax.naming.InitialContext; import java.util.Hashtable; -import org.apache.activemq.artemis.common.example.ActiveMQExample; - /** * This example demonstrates a queue with the same name deployed on two nodes of a cluster. * Messages are initially round robin'd between both nodes of the cluster. * The consumer on one of the nodes is then closed, and we demonstrate that the "stranded" messages * are redistributed to the other node which has a consumer so they can be consumed. */ -public class QueueMessageRedistributionExample extends ActiveMQExample +public class QueueMessageRedistributionExample { - public static void main(final String[] args) - { - new QueueMessageRedistributionExample().run(args); - } - - @Override - public boolean runExample() throws Exception + public static void main(final String[] args) throws Exception { Connection connection0 = null; @@ -57,7 +49,7 @@ public class QueueMessageRedistributionExample extends ActiveMQExample // Step 1. Get an initial context for looking up JNDI from server 0 Hashtable properties = new Hashtable(); properties.put("java.naming.factory.initial", "org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory"); - properties.put("connectionFactory.ConnectionFactory", DEFAULT_TCP1); + properties.put("connectionFactory.ConnectionFactory", "tcp://localhost:61616"); properties.put("queue.queue/exampleQueue", "exampleQueue"); ic0 = new InitialContext(properties); @@ -70,7 +62,7 @@ public class QueueMessageRedistributionExample extends ActiveMQExample // Step 4. Get an initial context for looking up JNDI from server 1 properties = new Hashtable(); properties.put("java.naming.factory.initial", "org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory"); - properties.put("connectionFactory.ConnectionFactory", DEFAULT_TCP2); + properties.put("connectionFactory.ConnectionFactory", "tcp://localhost:61617"); ic1 = new InitialContext(properties); // Step 5. Look-up a JMS Connection Factory object from JNDI on server 1 @@ -158,8 +150,6 @@ public class QueueMessageRedistributionExample extends ActiveMQExample // Step 18. We ack the messages. message0.acknowledge(); - - return true; } finally { @@ -186,5 +176,4 @@ public class QueueMessageRedistributionExample extends ActiveMQExample } } } - } diff --git a/examples/jms/queue-message-redistribution/src/main/resources/activemq/server0/broker.xml b/examples/jms/queue-message-redistribution/src/main/resources/activemq/server0/broker.xml index 2d771b0b5c..70ff4d4584 100644 --- a/examples/jms/queue-message-redistribution/src/main/resources/activemq/server0/broker.xml +++ b/examples/jms/queue-message-redistribution/src/main/resources/activemq/server0/broker.xml @@ -29,14 +29,13 @@ under the License. + ./data/bindings - ${data.dir}/server0/data/messaging/bindings + ./data/journal - ${data.dir}/server0/data/messaging/journal + ./data/largemessages - ${data.dir}/server0/data/messaging/largemessages - - ${data.dir}/server0/data/messaging/paging + ./data/paging diff --git a/examples/jms/queue-message-redistribution/src/main/resources/activemq/server1/broker.xml b/examples/jms/queue-message-redistribution/src/main/resources/activemq/server1/broker.xml index 870be491db..6fc6f32d7d 100644 --- a/examples/jms/queue-message-redistribution/src/main/resources/activemq/server1/broker.xml +++ b/examples/jms/queue-message-redistribution/src/main/resources/activemq/server1/broker.xml @@ -29,14 +29,13 @@ under the License. + ./data/bindings - ${data.dir}/server1/data/messaging/bindings + ./data/journal - ${data.dir}/server1/data/messaging/journal + ./data/largemessages - ${data.dir}/server1/data/messaging/largemessages - - ${data.dir}/server1/data/messaging/paging + ./data/paging diff --git a/examples/jms/queue-requestor/pom.xml b/examples/jms/queue-requestor/pom.xml index 893aef7ce9..2b8e16fca2 100644 --- a/examples/jms/queue-requestor/pom.xml +++ b/examples/jms/queue-requestor/pom.xml @@ -36,11 +36,6 @@ under the License. - - org.apache.activemq.examples.jms - common - ${project.version} - org.apache.geronimo.specs geronimo-jms_2.0_spec @@ -61,9 +56,18 @@ under the License. create + + + start + + cli + - ${basedir}/target/server0 - ${basedir}/target/classes/activemq/server0 + true + tcp://localhost:61616 + + run + @@ -73,8 +77,16 @@ under the License. org.apache.activemq.artemis.jms.example.QueueRequestorExample + + + + stop + + cli + + - ${basedir}/target/server0 + stop diff --git a/examples/jms/queue-requestor/src/main/java/org/apache/activemq/artemis/jms/example/QueueRequestorExample.java b/examples/jms/queue-requestor/src/main/java/org/apache/activemq/artemis/jms/example/QueueRequestorExample.java index b9ee4c7eed..b86ad9c8d7 100644 --- a/examples/jms/queue-requestor/src/main/java/org/apache/activemq/artemis/jms/example/QueueRequestorExample.java +++ b/examples/jms/queue-requestor/src/main/java/org/apache/activemq/artemis/jms/example/QueueRequestorExample.java @@ -26,20 +26,12 @@ import javax.jms.Session; import javax.jms.TextMessage; import javax.naming.InitialContext; -import org.apache.activemq.artemis.common.example.ActiveMQExample; - /** * A simple JMS example that shows how to use queues requestors. */ -public class QueueRequestorExample extends ActiveMQExample +public class QueueRequestorExample { - public static void main(final String[] args) - { - new QueueRequestorExample().run(args); - } - - @Override - public boolean runExample() throws Exception + public static void main(final String[] args) throws Exception { QueueConnection connection = null; InitialContext initialContext = null; @@ -85,8 +77,6 @@ public class QueueRequestorExample extends ActiveMQExample // Step 13. close the text reverser service reverserService.close(); - - return true; } finally { diff --git a/examples/jms/queue-selector/pom.xml b/examples/jms/queue-selector/pom.xml index 8ccd41ced9..7f179f60a0 100644 --- a/examples/jms/queue-selector/pom.xml +++ b/examples/jms/queue-selector/pom.xml @@ -36,11 +36,6 @@ under the License. - - org.apache.activemq.examples.jms - common - ${project.version} - org.apache.geronimo.specs geronimo-jms_2.0_spec @@ -61,9 +56,18 @@ under the License. create + + + start + + cli + - ${basedir}/target/server0 - ${basedir}/target/classes/activemq/server0 + true + tcp://localhost:61616 + + run + @@ -73,8 +77,16 @@ under the License. org.apache.activemq.artemis.jms.example.QueueSelectorExample + + + + stop + + cli + + - ${basedir}/target/server0 + stop diff --git a/examples/jms/queue-selector/src/main/java/org/apache/activemq/artemis/jms/example/QueueSelectorExample.java b/examples/jms/queue-selector/src/main/java/org/apache/activemq/artemis/jms/example/QueueSelectorExample.java index 059fe89526..4811257eb2 100644 --- a/examples/jms/queue-selector/src/main/java/org/apache/activemq/artemis/jms/example/QueueSelectorExample.java +++ b/examples/jms/queue-selector/src/main/java/org/apache/activemq/artemis/jms/example/QueueSelectorExample.java @@ -27,24 +27,16 @@ import javax.jms.Queue; import javax.jms.Session; import javax.jms.TextMessage; import javax.naming.InitialContext; - -import org.apache.activemq.artemis.common.example.ActiveMQExample; +import java.util.concurrent.atomic.AtomicBoolean; /** * A simple JMS example that uses selectors with queue consumers. */ -public class QueueSelectorExample extends ActiveMQExample +public class QueueSelectorExample { - private volatile boolean result = true; - - public static void main(final String[] args) - { - new QueueSelectorExample().run(args); - } - - @Override - public boolean runExample() throws Exception + public static void main(final String[] args) throws Exception { + AtomicBoolean result = new AtomicBoolean(true); Connection connection = null; InitialContext initialContext = null; try @@ -65,33 +57,36 @@ public class QueueSelectorExample extends ActiveMQExample connection.start(); // Step 5. Create a JMS Session - Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); + Session senderSession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); // Step 6. Create a JMS Message Producer - MessageProducer producer = session.createProducer(queue); + MessageProducer producer = senderSession.createProducer(queue); // Step 8. Prepare two selectors String redSelector = "color='red'"; String greenSelector = "color='green'"; // Step 9. Create a JMS Message Consumer that receives 'red' messages - MessageConsumer redConsumer = session.createConsumer(queue, redSelector); - redConsumer.setMessageListener(new SimpleMessageListener("red")); + Session redSession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); + MessageConsumer redConsumer = redSession.createConsumer(queue, redSelector); + redConsumer.setMessageListener(new SimpleMessageListener("red", result)); // Step 10. Create a second JMS message consumer that receives 'green' messages - MessageConsumer greenConsumer = session.createConsumer(queue, greenSelector); - greenConsumer.setMessageListener(new SimpleMessageListener("green")); + Session greenSession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); + MessageConsumer greenConsumer = greenSession.createConsumer(queue, greenSelector); + greenConsumer.setMessageListener(new SimpleMessageListener("green", result)); // Step 11. Create another JMS message consumer that receives any messages. - MessageConsumer anyConsumer = session.createConsumer(queue); - anyConsumer.setMessageListener(new SimpleMessageListener("any")); + Session blankSession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); + MessageConsumer anyConsumer = blankSession.createConsumer(queue); + anyConsumer.setMessageListener(new SimpleMessageListener("any", result)); // Step 12. Create three messages, each has a color property - TextMessage redMessage = session.createTextMessage("Red"); + TextMessage redMessage = senderSession.createTextMessage("Red"); redMessage.setStringProperty("color", "red"); - TextMessage greenMessage = session.createTextMessage("Green"); + TextMessage greenMessage = senderSession.createTextMessage("Green"); greenMessage.setStringProperty("color", "green"); - TextMessage blueMessage = session.createTextMessage("Blue"); + TextMessage blueMessage = senderSession.createTextMessage("Blue"); blueMessage.setStringProperty("color", "blue"); // Step 13. Send the Messages @@ -104,7 +99,8 @@ public class QueueSelectorExample extends ActiveMQExample Thread.sleep(5000); - return result; + if (!result.get()) + throw new IllegalStateException(); } finally { @@ -119,40 +115,39 @@ public class QueueSelectorExample extends ActiveMQExample } } } +} - public class SimpleMessageListener implements MessageListener +class SimpleMessageListener implements MessageListener +{ + private final String name; + private AtomicBoolean result; + + public SimpleMessageListener(final String listener, AtomicBoolean result) { - - private final String name; - - public SimpleMessageListener(final String listener) - { - name = listener; - } - - public void onMessage(final Message msg) - { - TextMessage textMessage = (TextMessage)msg; - try - { - String colorProp = msg.getStringProperty("color"); - System.out.println("Receiver " + name + - " receives message [" + - textMessage.getText() + - "] with color property: " + - colorProp); - if (!colorProp.equals(name) && !name.equals("any")) - { - result = false; - } - } - catch (JMSException e) - { - e.printStackTrace(); - result = false; - } - } - + name = listener; + this.result = result; } + public void onMessage(final Message msg) + { + TextMessage textMessage = (TextMessage)msg; + try + { + String colorProp = msg.getStringProperty("color"); + System.out.println("Receiver " + name + + " receives message [" + + textMessage.getText() + + "] with color property: " + + colorProp); + if (!colorProp.equals(name) && !name.equals("any")) + { + result.set(false); + } + } + catch (JMSException e) + { + e.printStackTrace(); + result.set(false); + } + } } diff --git a/examples/jms/queue-selector/src/main/resources/activemq/server0/artemis-roles.properties b/examples/jms/queue-selector/src/main/resources/activemq/server0/artemis-roles.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/queue-selector/src/main/resources/activemq/server0/artemis-roles.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/queue-selector/src/main/resources/activemq/server0/artemis-users.properties b/examples/jms/queue-selector/src/main/resources/activemq/server0/artemis-users.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/queue-selector/src/main/resources/activemq/server0/artemis-users.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/queue-selector/src/main/resources/activemq/server0/broker.xml b/examples/jms/queue-selector/src/main/resources/activemq/server0/broker.xml deleted file mode 100644 index 78f96f3899..0000000000 --- a/examples/jms/queue-selector/src/main/resources/activemq/server0/broker.xml +++ /dev/null @@ -1,59 +0,0 @@ - - - - - - - - - - - - - ${data.dir}/server0/data/messaging/bindings - - ${data.dir}/server0/data/messaging/journal - - ${data.dir}/server0/data/messaging/largemessages - - ${data.dir}/server0/data/messaging/paging - - - - tcp://localhost:61616 - - - - - - - - - - - - - - - - - - diff --git a/examples/jms/queue/pom.xml b/examples/jms/queue/pom.xml index 9619a7f044..fecaaf78ba 100644 --- a/examples/jms/queue/pom.xml +++ b/examples/jms/queue/pom.xml @@ -36,11 +36,6 @@ under the License. - - org.apache.activemq.examples.jms - common - ${project.version} - org.apache.geronimo.specs geronimo-jms_2.0_spec @@ -61,9 +56,18 @@ under the License. create + + + start + + cli + - ${basedir}/target/server0 - + true + tcp://localhost:61616 + + run + @@ -73,8 +77,16 @@ under the License. org.apache.activemq.artemis.jms.example.QueueExample + + + + stop + + cli + + - ${basedir}/target/server0 + stop diff --git a/examples/jms/queue/src/main/java/org/apache/activemq/artemis/jms/example/QueueExample.java b/examples/jms/queue/src/main/java/org/apache/activemq/artemis/jms/example/QueueExample.java index af9b728673..5cbf0cd8ac 100644 --- a/examples/jms/queue/src/main/java/org/apache/activemq/artemis/jms/example/QueueExample.java +++ b/examples/jms/queue/src/main/java/org/apache/activemq/artemis/jms/example/QueueExample.java @@ -25,20 +25,12 @@ import javax.jms.Session; import javax.jms.TextMessage; import javax.naming.InitialContext; -import org.apache.activemq.artemis.common.example.ActiveMQExample; - /** * A simple JMS Queue example that creates a producer and consumer on a queue and sends then receives a message. */ -public class QueueExample extends ActiveMQExample +public class QueueExample { - public static void main(final String[] args) - { - new QueueExample().run(args); - } - - @Override - public boolean runExample() throws Exception + public static void main(final String[] args) throws Exception { Connection connection = null; InitialContext initialContext = null; @@ -80,8 +72,6 @@ public class QueueExample extends ActiveMQExample TextMessage messageReceived = (TextMessage)messageConsumer.receive(5000); System.out.println("Received message: " + messageReceived.getText()); - - return true; } finally { diff --git a/examples/jms/reattach-node/pom.xml b/examples/jms/reattach-node/pom.xml index 76ae5d7eb3..885adcf528 100644 --- a/examples/jms/reattach-node/pom.xml +++ b/examples/jms/reattach-node/pom.xml @@ -37,8 +37,8 @@ under the License. - org.apache.activemq.examples.jms - common + org.apache.activemq + artemis-jms-client ${project.version} @@ -66,6 +66,19 @@ under the License. ${basedir}/target/classes/activemq/server0 + + start + + cli + + + true + tcp://localhost:61616 + + run + + + runClient @@ -73,8 +86,16 @@ under the License. org.apache.activemq.artemis.jms.example.ReattachExample + + + + stop + + cli + + - ${basedir}/target/server0 + stop diff --git a/examples/jms/reattach-node/src/main/java/org/apache/activemq/artemis/jms/example/ReattachExample.java b/examples/jms/reattach-node/src/main/java/org/apache/activemq/artemis/jms/example/ReattachExample.java index 34393d0a40..2b05090b36 100644 --- a/examples/jms/reattach-node/src/main/java/org/apache/activemq/artemis/jms/example/ReattachExample.java +++ b/examples/jms/reattach-node/src/main/java/org/apache/activemq/artemis/jms/example/ReattachExample.java @@ -30,22 +30,15 @@ import javax.naming.InitialContext; import org.apache.activemq.artemis.api.jms.ActiveMQJMSClient; import org.apache.activemq.artemis.api.jms.management.JMSManagementHelper; -import org.apache.activemq.artemis.common.example.ActiveMQExample; /** * This examples demonstrates a connection created to a server. Failure of the network connection is then simulated * * The network is brought back up and the client reconnects and resumes transparently. */ -public class ReattachExample extends ActiveMQExample +public class ReattachExample { - public static void main(final String[] args) - { - new ReattachExample().run(args); - } - - @Override - public boolean runExample() throws Exception + public static void main(final String[] args) throws Exception { Connection connection = null; InitialContext initialContext = null; @@ -103,8 +96,6 @@ public class ReattachExample extends ActiveMQExample TextMessage messageReceived = (TextMessage)messageConsumer.receive(5000); System.out.println("Received message: " + messageReceived.getText()); - - return true; } finally { @@ -121,12 +112,12 @@ public class ReattachExample extends ActiveMQExample } } - private void stopAcceptor() throws Exception + private static void stopAcceptor() throws Exception { stopStartAcceptor(true); } - private void startAcceptor() throws Exception + private static void startAcceptor() throws Exception { stopStartAcceptor(false); } @@ -134,7 +125,7 @@ public class ReattachExample extends ActiveMQExample // To do this we send a management message to close the acceptor, we do this on a different // connection factory which uses a different remoting connection so we can still send messages // when the main connection has been stopped - private void stopStartAcceptor(final boolean stop) throws Exception + private static void stopStartAcceptor(final boolean stop) throws Exception { Hashtable properties = new Hashtable(); properties.put("java.naming.factory.initial", "org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory"); diff --git a/examples/jms/reattach-node/src/main/resources/activemq/server0/broker.xml b/examples/jms/reattach-node/src/main/resources/activemq/server0/broker.xml index 0edc66a327..20321a2ba7 100644 --- a/examples/jms/reattach-node/src/main/resources/activemq/server0/broker.xml +++ b/examples/jms/reattach-node/src/main/resources/activemq/server0/broker.xml @@ -29,13 +29,13 @@ under the License. - ${data.dir}/server0/data/messaging/bindings + ${data.dir:./data}/bindings - ${data.dir}/server0/data/messaging/journal + ${data.dir:./data}/journal - ${data.dir}/server0/data/messaging/largemessages + ${data.dir:./data}/largemessages - ${data.dir}/server0/data/messaging/paging + ${data.dir:./data}/paging diff --git a/examples/jms/replicated-failback-static/pom.xml b/examples/jms/replicated-failback-static/pom.xml index 9a9a2f73f5..2cd507255d 100644 --- a/examples/jms/replicated-failback-static/pom.xml +++ b/examples/jms/replicated-failback-static/pom.xml @@ -37,8 +37,8 @@ under the License. - org.apache.activemq.examples.jms - common + org.apache.activemq + artemis-cli ${project.version} @@ -57,7 +57,7 @@ under the License. artemis-maven-plugin - create + create0 create @@ -68,7 +68,7 @@ under the License. - create2 + create1 create @@ -104,5 +104,4 @@ under the License. - diff --git a/examples/jms/replicated-failback-static/src/main/java/org/apache/activemq/artemis/jms/example/ReplicatedFailbackStaticExample.java b/examples/jms/replicated-failback-static/src/main/java/org/apache/activemq/artemis/jms/example/ReplicatedFailbackStaticExample.java index 7618c402ed..2f22cb9fcd 100644 --- a/examples/jms/replicated-failback-static/src/main/java/org/apache/activemq/artemis/jms/example/ReplicatedFailbackStaticExample.java +++ b/examples/jms/replicated-failback-static/src/main/java/org/apache/activemq/artemis/jms/example/ReplicatedFailbackStaticExample.java @@ -16,6 +16,8 @@ */ package org.apache.activemq.artemis.jms.example; +import org.apache.activemq.artemis.util.ServerUtil; + import javax.jms.Connection; import javax.jms.ConnectionFactory; import javax.jms.JMSException; @@ -26,8 +28,6 @@ import javax.jms.Session; import javax.jms.TextMessage; import javax.naming.InitialContext; -import org.apache.activemq.artemis.common.example.ActiveMQExample; - /** * Example of live and replicating backup pair. *

    @@ -35,15 +35,13 @@ import org.apache.activemq.artemis.common.example.ActiveMQExample; *

    * Later the live server is restarted and takes back its position by asking the backup to stop ("fail-back"). */ -public class ReplicatedFailbackStaticExample extends ActiveMQExample +public class ReplicatedFailbackStaticExample { - public static void main(final String[] args) - { - new ReplicatedFailbackStaticExample().run(args); - } + private static Process server0; - @Override - public boolean runExample() throws Exception + private static Process server1; + + public static void main(final String[] args) throws Exception { final int numMessages = 30; @@ -53,6 +51,9 @@ public class ReplicatedFailbackStaticExample extends ActiveMQExample try { + server0 = ServerUtil.startServer(args[0], ReplicatedFailbackStaticExample.class.getSimpleName() + "0", 0, 30000); + server1 = ServerUtil.startServer(args[1], ReplicatedFailbackStaticExample.class.getSimpleName() + "1", 1, 10000); + // Step 1. Get an initial context for looking up JNDI from the server #1 initialContext = new InitialContext(); @@ -97,10 +98,9 @@ public class ReplicatedFailbackStaticExample extends ActiveMQExample System.out.println("Got message: " + message0.getText()); } - // Step 10. Crash server #1, the live server, and wait a little while to make sure + // Step 10. Crash server #0, the live server, and wait a little while to make sure // it has really crashed - Thread.sleep(5000); - killServer(0); + ServerUtil.killServer(server0); // Step 11. Acknowledging the 2nd half of the sent messages will fail as failover to the // backup server has occurred @@ -121,9 +121,7 @@ public class ReplicatedFailbackStaticExample extends ActiveMQExample } message0.acknowledge(); - reStartServer(0, 10000); - - Thread.sleep(10000); + server0 = ServerUtil.startServer(args[0], ReplicatedFailbackStaticExample.class.getSimpleName() + "0", 0, 10000); // Step 11. Acknowledging the 2nd half of the sent messages will fail as failover to the // backup server has occurred @@ -143,8 +141,6 @@ public class ReplicatedFailbackStaticExample extends ActiveMQExample System.out.printf("Got message: %s (redelivered?: %s)\n", message0.getText(), message0.getJMSRedelivered()); } message0.acknowledge(); - - return true; } finally { @@ -159,7 +155,9 @@ public class ReplicatedFailbackStaticExample extends ActiveMQExample { initialContext.close(); } + + ServerUtil.killServer(server0); + ServerUtil.killServer(server1); } } - } diff --git a/examples/jms/replicated-failback-static/src/main/resources/activemq/server0/artemis-roles.properties b/examples/jms/replicated-failback-static/src/main/resources/activemq/server0/artemis-roles.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/replicated-failback-static/src/main/resources/activemq/server0/artemis-roles.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/replicated-failback-static/src/main/resources/activemq/server0/artemis-users.properties b/examples/jms/replicated-failback-static/src/main/resources/activemq/server0/artemis-users.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/replicated-failback-static/src/main/resources/activemq/server0/artemis-users.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/replicated-failback-static/src/main/resources/activemq/server0/broker.xml b/examples/jms/replicated-failback-static/src/main/resources/activemq/server0/broker.xml index 2bb35527e2..f59bdbcd82 100644 --- a/examples/jms/replicated-failback-static/src/main/resources/activemq/server0/broker.xml +++ b/examples/jms/replicated-failback-static/src/main/resources/activemq/server0/broker.xml @@ -29,13 +29,13 @@ under the License. - ${data.dir}/server0/data/messaging/bindings + ${data.dir:./data}/bindings - ${data.dir}/server0/data/messaging/journal + ${data.dir:./data}/journal - ${data.dir}/server0/data/messaging/largemessages + ${data.dir:./data}/largemessages - ${data.dir}/server0/data/messaging/paging + ${data.dir:./data}/paging exampleUser diff --git a/examples/jms/replicated-failback-static/src/main/resources/activemq/server1/artemis-roles.properties b/examples/jms/replicated-failback-static/src/main/resources/activemq/server1/artemis-roles.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/replicated-failback-static/src/main/resources/activemq/server1/artemis-roles.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/replicated-failback-static/src/main/resources/activemq/server1/artemis-users.properties b/examples/jms/replicated-failback-static/src/main/resources/activemq/server1/artemis-users.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/replicated-failback-static/src/main/resources/activemq/server1/artemis-users.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/replicated-failback-static/src/main/resources/activemq/server1/broker.xml b/examples/jms/replicated-failback-static/src/main/resources/activemq/server1/broker.xml index 71e2e4e774..9173c64a41 100644 --- a/examples/jms/replicated-failback-static/src/main/resources/activemq/server1/broker.xml +++ b/examples/jms/replicated-failback-static/src/main/resources/activemq/server1/broker.xml @@ -29,13 +29,13 @@ under the License. - ${data.dir}/server1/data/messaging/bindings + ${data.dir:./data}/bindings - ${data.dir}/server1/data/messaging/journal + ${data.dir:./data}/journal - ${data.dir}/server1/data/messaging/largemessages + ${data.dir:./data}/largemessages - ${data.dir}/server1/data/messaging/paging + ${data.dir:./data}/paging exampleUser diff --git a/examples/jms/replicated-failback/pom.xml b/examples/jms/replicated-failback/pom.xml index 7a27d383bb..d9c5150a8b 100644 --- a/examples/jms/replicated-failback/pom.xml +++ b/examples/jms/replicated-failback/pom.xml @@ -37,8 +37,8 @@ under the License. - org.apache.activemq.examples.jms - common + org.apache.activemq + artemis-cli ${project.version} @@ -57,7 +57,7 @@ under the License. artemis-maven-plugin - create + create0 create @@ -68,7 +68,7 @@ under the License. - create2 + create1 create @@ -104,5 +104,4 @@ under the License. - diff --git a/examples/jms/replicated-failback/src/main/java/org/apache/activemq/artemis/jms/example/ReplicatedFailbackExample.java b/examples/jms/replicated-failback/src/main/java/org/apache/activemq/artemis/jms/example/ReplicatedFailbackExample.java index 02fcbaf288..1cd933addc 100644 --- a/examples/jms/replicated-failback/src/main/java/org/apache/activemq/artemis/jms/example/ReplicatedFailbackExample.java +++ b/examples/jms/replicated-failback/src/main/java/org/apache/activemq/artemis/jms/example/ReplicatedFailbackExample.java @@ -16,6 +16,8 @@ */ package org.apache.activemq.artemis.jms.example; +import org.apache.activemq.artemis.util.ServerUtil; + import javax.jms.Connection; import javax.jms.ConnectionFactory; import javax.jms.JMSException; @@ -26,8 +28,6 @@ import javax.jms.Session; import javax.jms.TextMessage; import javax.naming.InitialContext; -import org.apache.activemq.artemis.common.example.ActiveMQExample; - /** * Example of live and replicating backup pair. *

    @@ -35,21 +35,13 @@ import org.apache.activemq.artemis.common.example.ActiveMQExample; *

    * Later the live server is restarted and takes back its position by asking the backup to stop ("fail-back"). */ -public class ReplicatedFailbackExample extends ActiveMQExample +public class ReplicatedFailbackExample { - public static void main(final String[] args) - { - new ReplicatedFailbackExample().run(args); - } + private static Process server0; - protected void startServers(String[] serversArgs) throws Exception - { - startServer(0, 60000); - startServer(1, 10000); - } + private static Process server1; - @Override - public boolean runExample() throws Exception + public static void main(final String[] args) throws Exception { final int numMessages = 30; @@ -59,6 +51,9 @@ public class ReplicatedFailbackExample extends ActiveMQExample try { + server0 = ServerUtil.startServer(args[0], ReplicatedFailbackExample.class.getSimpleName() + "0", 0, 30000); + server1 = ServerUtil.startServer(args[1], ReplicatedFailbackExample.class.getSimpleName() + "1", 1, 10000); + // Step 1. Get an initial context for looking up JNDI from the server #1 initialContext = new InitialContext(); @@ -103,10 +98,9 @@ public class ReplicatedFailbackExample extends ActiveMQExample System.out.println("Got message: " + message0.getText()); } - // Step 10. Crash server #1, the live server, and wait a little while to make sure + // Step 10. Crash server #0, the live server, and wait a little while to make sure // it has really crashed - Thread.sleep(5000); - killServer(0); + ServerUtil.killServer(server0); // Step 11. Acknowledging the 2nd half of the sent messages will fail as failover to the // backup server has occurred @@ -127,9 +121,7 @@ public class ReplicatedFailbackExample extends ActiveMQExample } message0.acknowledge(); - reStartServer(0, 10000); - - Thread.sleep(10000); + server0 = ServerUtil.startServer(args[0], ReplicatedFailbackExample.class.getSimpleName() + "0", 0, 10000); // Step 11. Acknowledging the 2nd half of the sent messages will fail as failover to the // backup server has occurred @@ -149,8 +141,6 @@ public class ReplicatedFailbackExample extends ActiveMQExample System.out.printf("Got message: %s (redelivered?: %s)\n", message0.getText(), message0.getJMSRedelivered()); } message0.acknowledge(); - - return true; } finally { @@ -165,7 +155,9 @@ public class ReplicatedFailbackExample extends ActiveMQExample { initialContext.close(); } + + ServerUtil.killServer(server0); + ServerUtil.killServer(server1); } } - } diff --git a/examples/jms/replicated-failback/src/main/resources/activemq/server0/artemis-roles.properties b/examples/jms/replicated-failback/src/main/resources/activemq/server0/artemis-roles.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/replicated-failback/src/main/resources/activemq/server0/artemis-roles.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/replicated-failback/src/main/resources/activemq/server0/artemis-users.properties b/examples/jms/replicated-failback/src/main/resources/activemq/server0/artemis-users.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/replicated-failback/src/main/resources/activemq/server0/artemis-users.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/replicated-failback/src/main/resources/activemq/server0/broker.xml b/examples/jms/replicated-failback/src/main/resources/activemq/server0/broker.xml index e762e2c92c..ab85a389cd 100644 --- a/examples/jms/replicated-failback/src/main/resources/activemq/server0/broker.xml +++ b/examples/jms/replicated-failback/src/main/resources/activemq/server0/broker.xml @@ -29,13 +29,13 @@ under the License. - ${data.dir}/live/bindings + ${data.dir:./data}/bindings - ${data.dir}/live/journal + ${data.dir:./data}/journal - ${data.dir}/live/largemessages + ${data.dir:./data}/largemessages - ${data.dir}/live/paging + ${data.dir:./data}/paging exampleUser diff --git a/examples/jms/replicated-failback/src/main/resources/activemq/server1/artemis-roles.properties b/examples/jms/replicated-failback/src/main/resources/activemq/server1/artemis-roles.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/replicated-failback/src/main/resources/activemq/server1/artemis-roles.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/replicated-failback/src/main/resources/activemq/server1/artemis-users.properties b/examples/jms/replicated-failback/src/main/resources/activemq/server1/artemis-users.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/replicated-failback/src/main/resources/activemq/server1/artemis-users.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/replicated-failback/src/main/resources/activemq/server1/broker.xml b/examples/jms/replicated-failback/src/main/resources/activemq/server1/broker.xml index af242b9d12..cfb7e3322f 100644 --- a/examples/jms/replicated-failback/src/main/resources/activemq/server1/broker.xml +++ b/examples/jms/replicated-failback/src/main/resources/activemq/server1/broker.xml @@ -29,13 +29,13 @@ under the License. - ${data.dir}/bkp/bindings + ${data.dir:./data}/bindings - ${data.dir}/bkp/journal + ${data.dir:./data}/journal - ${data.dir}/bkp/largemessages + ${data.dir:./data}/largemessages - ${data.dir}/bkp/paging + ${data.dir:./data}/paging exampleUser diff --git a/examples/jms/replicated-multiple-failover/pom.xml b/examples/jms/replicated-multiple-failover/pom.xml index 60ba4a6532..d1af812756 100644 --- a/examples/jms/replicated-multiple-failover/pom.xml +++ b/examples/jms/replicated-multiple-failover/pom.xml @@ -37,8 +37,8 @@ under the License. - org.apache.activemq.examples.jms - common + org.apache.activemq + artemis-cli ${project.version} @@ -57,7 +57,7 @@ under the License. artemis-maven-plugin - create + create0 create @@ -68,7 +68,7 @@ under the License. - create2 + create1 create @@ -78,6 +78,17 @@ under the License. -Dudp-address=${udp-address} + + create2 + + create + + + ${basedir}/target/server2 + ${basedir}/target/classes/activemq/server2 + -Dudp-address=${udp-address} + + runClient @@ -88,6 +99,7 @@ under the License. ${basedir}/target/server0 ${basedir}/target/server1 + ${basedir}/target/server2 diff --git a/examples/jms/replicated-multiple-failover/src/main/java/org/apache/activemq/artemis/jms/example/ReplicatedMultipleFailoverExample.java b/examples/jms/replicated-multiple-failover/src/main/java/org/apache/activemq/artemis/jms/example/ReplicatedMultipleFailoverExample.java index 388506545a..31dc492eb8 100644 --- a/examples/jms/replicated-multiple-failover/src/main/java/org/apache/activemq/artemis/jms/example/ReplicatedMultipleFailoverExample.java +++ b/examples/jms/replicated-multiple-failover/src/main/java/org/apache/activemq/artemis/jms/example/ReplicatedMultipleFailoverExample.java @@ -16,6 +16,8 @@ */ package org.apache.activemq.artemis.jms.example; +import org.apache.activemq.artemis.util.ServerUtil; + import javax.jms.Connection; import javax.jms.ConnectionFactory; import javax.jms.JMSException; @@ -26,17 +28,15 @@ import javax.jms.Session; import javax.jms.TextMessage; import javax.naming.InitialContext; -import org.apache.activemq.artemis.common.example.ActiveMQExample; - -public class ReplicatedMultipleFailoverExample extends ActiveMQExample +public class ReplicatedMultipleFailoverExample { - public static void main(final String[] args) - { - new ReplicatedMultipleFailoverExample().run(args); - } + private static Process server0; - @Override - public boolean runExample() throws Exception + private static Process server1; + + private static Process server2; + + public static void main(final String[] args) throws Exception { final int numMessages = 30; @@ -46,6 +46,12 @@ public class ReplicatedMultipleFailoverExample extends ActiveMQExample try { + server0 = ServerUtil.startServer(args[0], ReplicatedMultipleFailoverExample.class.getSimpleName() + "0", 0, 5000); + server1 = ServerUtil.startServer(args[1], ReplicatedMultipleFailoverExample.class.getSimpleName() + "1", 1, 5000); + server2 = ServerUtil.startServer(args[2], ReplicatedMultipleFailoverExample.class.getSimpleName() + "2", 2, 5000); + + Process[] processes = new Process[] {server0, server1, server2}; + // Step 1. Get an initial context for looking up JNDI from the server #1 initialContext = new InitialContext(); @@ -90,10 +96,10 @@ public class ReplicatedMultipleFailoverExample extends ActiveMQExample System.out.println("Got message: " + message0.getText()); } - // Step 10. Crash server #1, the live server, and wait a little while to make sure + // Step 10. Crash server #0, the live server, and wait a little while to make sure // it has really crashed + ServerUtil.killServer(server0); Thread.sleep(5000); - killServer(0); // Step 11. Acknowledging the 2nd half of the sent messages will fail as failover to the // backup server has occurred @@ -114,8 +120,7 @@ public class ReplicatedMultipleFailoverExample extends ActiveMQExample } message0.acknowledge(); - Thread.sleep(5000); - killServer(getServer(connection)); + ServerUtil.killServer(processes[ServerUtil.getServer(connection)]); // Step 11. Acknowledging the 2nd half of the sent messages will fail as failover to the // backup server has occurred @@ -135,8 +140,6 @@ public class ReplicatedMultipleFailoverExample extends ActiveMQExample System.out.printf("Got message: %s (redelivered?: %s)%n", message0.getText(), message0.getJMSRedelivered()); } message0.acknowledge(); - - return true; } finally { @@ -151,7 +154,10 @@ public class ReplicatedMultipleFailoverExample extends ActiveMQExample { initialContext.close(); } + + ServerUtil.killServer(server0); + ServerUtil.killServer(server1); + ServerUtil.killServer(server2); } } - } diff --git a/examples/jms/replicated-multiple-failover/src/main/resources/activemq/server0/artemis-roles.properties b/examples/jms/replicated-multiple-failover/src/main/resources/activemq/server0/artemis-roles.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/replicated-multiple-failover/src/main/resources/activemq/server0/artemis-roles.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/replicated-multiple-failover/src/main/resources/activemq/server0/artemis-users.properties b/examples/jms/replicated-multiple-failover/src/main/resources/activemq/server0/artemis-users.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/replicated-multiple-failover/src/main/resources/activemq/server0/artemis-users.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/replicated-multiple-failover/src/main/resources/activemq/server0/broker.xml b/examples/jms/replicated-multiple-failover/src/main/resources/activemq/server0/broker.xml index eb47eb2b34..fb321c22fc 100644 --- a/examples/jms/replicated-multiple-failover/src/main/resources/activemq/server0/broker.xml +++ b/examples/jms/replicated-multiple-failover/src/main/resources/activemq/server0/broker.xml @@ -29,13 +29,13 @@ under the License. - ${data.dir}/server0/data/messaging/bindings + ${data.dir:./data}/bindings - ${data.dir}/server0/data/messaging/journal + ${data.dir:./data}/journal - ${data.dir}/server0/data/messaging/largemessages + ${data.dir:./data}/largemessages - ${data.dir}/server0/data/messaging/paging + ${data.dir:./data}/paging diff --git a/examples/jms/replicated-multiple-failover/src/main/resources/activemq/server1/artemis-roles.properties b/examples/jms/replicated-multiple-failover/src/main/resources/activemq/server1/artemis-roles.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/replicated-multiple-failover/src/main/resources/activemq/server1/artemis-roles.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/replicated-multiple-failover/src/main/resources/activemq/server1/artemis-users.properties b/examples/jms/replicated-multiple-failover/src/main/resources/activemq/server1/artemis-users.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/replicated-multiple-failover/src/main/resources/activemq/server1/artemis-users.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/replicated-multiple-failover/src/main/resources/activemq/server1/broker.xml b/examples/jms/replicated-multiple-failover/src/main/resources/activemq/server1/broker.xml index 344bfbfd07..1cb959ce8f 100644 --- a/examples/jms/replicated-multiple-failover/src/main/resources/activemq/server1/broker.xml +++ b/examples/jms/replicated-multiple-failover/src/main/resources/activemq/server1/broker.xml @@ -29,13 +29,13 @@ under the License. - ${data.dir}/server1/data/messaging/bindings + ${data.dir:./data}/bindings - ${data.dir}/server1/data/messaging/journal + ${data.dir:./data}/journal - ${data.dir}/server1/data/messaging/largemessages + ${data.dir:./data}/largemessages - ${data.dir}/server1/data/messaging/paging + ${data.dir:./data}/paging diff --git a/examples/jms/replicated-multiple-failover/src/main/resources/activemq/server2/artemis-roles.properties b/examples/jms/replicated-multiple-failover/src/main/resources/activemq/server2/artemis-roles.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/replicated-multiple-failover/src/main/resources/activemq/server2/artemis-roles.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/replicated-multiple-failover/src/main/resources/activemq/server2/artemis-users.properties b/examples/jms/replicated-multiple-failover/src/main/resources/activemq/server2/artemis-users.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/replicated-multiple-failover/src/main/resources/activemq/server2/artemis-users.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/replicated-multiple-failover/src/main/resources/activemq/server2/broker.xml b/examples/jms/replicated-multiple-failover/src/main/resources/activemq/server2/broker.xml index 804f63f641..fbbd45f9dd 100644 --- a/examples/jms/replicated-multiple-failover/src/main/resources/activemq/server2/broker.xml +++ b/examples/jms/replicated-multiple-failover/src/main/resources/activemq/server2/broker.xml @@ -29,13 +29,13 @@ under the License. - ${data.dir}/server2/data/messaging/bindings + ${data.dir:./data}/bindings - ${data.dir}/server2/data/messaging/journal + ${data.dir:./data}/journal - ${data.dir}/server2/data/messaging/largemessages + ${data.dir:./data}/largemessages - ${data.dir}/server2/data/messaging/paging + ${data.dir:./data}/paging @@ -43,6 +43,7 @@ under the License. + tcp://localhost:61618 diff --git a/examples/jms/replicated-transaction-failover/pom.xml b/examples/jms/replicated-transaction-failover/pom.xml index b6def6610e..2c10c66ce0 100644 --- a/examples/jms/replicated-transaction-failover/pom.xml +++ b/examples/jms/replicated-transaction-failover/pom.xml @@ -37,8 +37,8 @@ under the License. - org.apache.activemq.examples.jms - common + org.apache.activemq + artemis-cli ${project.version} @@ -57,7 +57,7 @@ under the License. artemis-maven-plugin - create + create0 create @@ -68,7 +68,7 @@ under the License. - create2 + create1 create @@ -104,5 +104,4 @@ under the License. - diff --git a/examples/jms/replicated-transaction-failover/src/main/java/org/apache/activemq/artemis/jms/example/ReplicatedTransactionFailoverExample.java b/examples/jms/replicated-transaction-failover/src/main/java/org/apache/activemq/artemis/jms/example/ReplicatedTransactionFailoverExample.java index f202e2ea1c..dcc89d2e57 100644 --- a/examples/jms/replicated-transaction-failover/src/main/java/org/apache/activemq/artemis/jms/example/ReplicatedTransactionFailoverExample.java +++ b/examples/jms/replicated-transaction-failover/src/main/java/org/apache/activemq/artemis/jms/example/ReplicatedTransactionFailoverExample.java @@ -16,6 +16,9 @@ */ package org.apache.activemq.artemis.jms.example; +import org.apache.activemq.artemis.api.core.Message; +import org.apache.activemq.artemis.util.ServerUtil; + import javax.jms.Connection; import javax.jms.ConnectionFactory; import javax.jms.MessageConsumer; @@ -26,29 +29,23 @@ import javax.jms.TextMessage; import javax.jms.TransactionRolledBackException; import javax.naming.InitialContext; -import org.apache.activemq.artemis.api.core.Message; -import org.apache.activemq.artemis.common.example.ActiveMQExample; - /** * A simple example that demonstrates failover of the JMS connection from one node to another * when the live server crashes using a JMS transacted session and replication. */ -public class ReplicatedTransactionFailoverExample extends ActiveMQExample +public class ReplicatedTransactionFailoverExample { + private static Process server0; + + private static Process server1; // You need to guarantee uniqueIDs when using duplicate detection // It needs to be unique even after a restart // as these IDs are stored on the journal for control // We recommend some sort of UUID, but for this example the Current Time as string would be enough - String uniqueID = Long.toString(System.currentTimeMillis()); + private static String uniqueID = Long.toString(System.currentTimeMillis()); - public static void main(final String[] args) - { - new ReplicatedTransactionFailoverExample().run(args); - } - - @Override - public boolean runExample() throws Exception + public static void main(final String[] args) throws Exception { final int numMessages = 10; @@ -58,6 +55,9 @@ public class ReplicatedTransactionFailoverExample extends ActiveMQExample try { + server0 = ServerUtil.startServer(args[0], ReplicatedTransactionFailoverExample.class.getSimpleName() + "0", 0, 5000); + server1 = ServerUtil.startServer(args[1], ReplicatedTransactionFailoverExample.class.getSimpleName() + "1", 1, 5000); + // Step 1. Get an initial context for looking up JNDI from the server #1 initialContext = new InitialContext(); @@ -108,9 +108,7 @@ public class ReplicatedTransactionFailoverExample extends ActiveMQExample if (message0 == null) { - System.err.println("Example failed - message wasn't received"); - - return false; + throw new IllegalStateException("Example failed - message wasn't received"); } System.out.println("Got message: " + message0.getText()); @@ -119,8 +117,6 @@ public class ReplicatedTransactionFailoverExample extends ActiveMQExample session.commit(); System.out.println("Other message on the server? " + consumer.receive(5000)); - - return true; } finally { @@ -135,10 +131,13 @@ public class ReplicatedTransactionFailoverExample extends ActiveMQExample { initialContext.close(); } + + ServerUtil.killServer(server0); + ServerUtil.killServer(server1); } } - private void sendMessages(final Session session, + private static void sendMessages(final Session session, final MessageProducer producer, final int numMessages, final boolean killServer) throws Exception @@ -160,10 +159,7 @@ public class ReplicatedTransactionFailoverExample extends ActiveMQExample if (killServer) { - Thread.sleep(5000); - - killServer(0); - + ServerUtil.killServer(server0); } // We send the remaining half of messages diff --git a/examples/jms/replicated-transaction-failover/src/main/resources/activemq/server0/artemis-roles.properties b/examples/jms/replicated-transaction-failover/src/main/resources/activemq/server0/artemis-roles.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/replicated-transaction-failover/src/main/resources/activemq/server0/artemis-roles.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/replicated-transaction-failover/src/main/resources/activemq/server0/artemis-users.properties b/examples/jms/replicated-transaction-failover/src/main/resources/activemq/server0/artemis-users.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/replicated-transaction-failover/src/main/resources/activemq/server0/artemis-users.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/replicated-transaction-failover/src/main/resources/activemq/server0/broker.xml b/examples/jms/replicated-transaction-failover/src/main/resources/activemq/server0/broker.xml index 597f828773..9233f17aa5 100644 --- a/examples/jms/replicated-transaction-failover/src/main/resources/activemq/server0/broker.xml +++ b/examples/jms/replicated-transaction-failover/src/main/resources/activemq/server0/broker.xml @@ -29,13 +29,13 @@ under the License. - ${data.dir}/server0/data/messaging/bindings + ${data.dir:./data}/bindings - ${data.dir}/server0/data/messaging/journal + ${data.dir:./data}/journal - ${data.dir}/server0/data/messaging/largemessages + ${data.dir:./data}/largemessages - ${data.dir}/server0/data/messaging/paging + ${data.dir:./data}/paging diff --git a/examples/jms/replicated-transaction-failover/src/main/resources/activemq/server1/artemis-roles.properties b/examples/jms/replicated-transaction-failover/src/main/resources/activemq/server1/artemis-roles.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/replicated-transaction-failover/src/main/resources/activemq/server1/artemis-roles.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/replicated-transaction-failover/src/main/resources/activemq/server1/artemis-users.properties b/examples/jms/replicated-transaction-failover/src/main/resources/activemq/server1/artemis-users.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/replicated-transaction-failover/src/main/resources/activemq/server1/artemis-users.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/replicated-transaction-failover/src/main/resources/activemq/server1/broker.xml b/examples/jms/replicated-transaction-failover/src/main/resources/activemq/server1/broker.xml index cdefc88f11..848525ee20 100644 --- a/examples/jms/replicated-transaction-failover/src/main/resources/activemq/server1/broker.xml +++ b/examples/jms/replicated-transaction-failover/src/main/resources/activemq/server1/broker.xml @@ -29,13 +29,13 @@ under the License. - ${data.dir}/server1/data/messaging/bindings + ${data.dir:./data}/bindings - ${data.dir}/server1/data/messaging/journal + ${data.dir:./data}/journal - ${data.dir}/server1/data/messaging/largemessages + ${data.dir:./data}/largemessages - ${data.dir}/server1/data/messaging/paging + ${data.dir:./data}/paging diff --git a/examples/jms/request-reply/pom.xml b/examples/jms/request-reply/pom.xml index 5880d9d8fc..e8849d81fd 100644 --- a/examples/jms/request-reply/pom.xml +++ b/examples/jms/request-reply/pom.xml @@ -36,11 +36,6 @@ under the License. - - org.apache.activemq.examples.jms - common - ${project.version} - org.apache.geronimo.specs geronimo-jms_2.0_spec @@ -61,9 +56,18 @@ under the License. create + + + start + + cli + - ${basedir}/target/server0 - ${basedir}/target/classes/activemq/server0 + true + tcp://localhost:61616 + + run + @@ -73,8 +77,16 @@ under the License. org.apache.activemq.artemis.jms.example.RequestReplyExample + + + + stop + + cli + + - ${basedir}/target/server0 + stop @@ -91,5 +103,4 @@ under the License. - diff --git a/examples/jms/request-reply/src/main/java/org/apache/activemq/artemis/jms/example/RequestReplyExample.java b/examples/jms/request-reply/src/main/java/org/apache/activemq/artemis/jms/example/RequestReplyExample.java index 751f2da972..7e9093fa09 100644 --- a/examples/jms/request-reply/src/main/java/org/apache/activemq/artemis/jms/example/RequestReplyExample.java +++ b/examples/jms/request-reply/src/main/java/org/apache/activemq/artemis/jms/example/RequestReplyExample.java @@ -33,8 +33,6 @@ import javax.jms.TemporaryQueue; import javax.jms.TextMessage; import javax.naming.InitialContext; -import org.apache.activemq.artemis.common.example.ActiveMQExample; - /** * A simple JMS example that shows how to use Request/Replay style messaging. * @@ -43,18 +41,11 @@ import org.apache.activemq.artemis.common.example.ActiveMQExample; * * Or better still use the correlation id, and just store the requests in a map, then you don't need a temporary queue at all */ -public class RequestReplyExample extends ActiveMQExample +public class RequestReplyExample { - private final Map requestMap = new HashMap(); - - public static void main(final String[] args) - { - new RequestReplyExample().run(args); - } - - @Override - public boolean runExample() throws Exception + public static void main(final String[] args) throws Exception { + final Map requestMap = new HashMap(); Connection connection = null; InitialContext initialContext = null; @@ -129,8 +120,6 @@ public class RequestReplyExample extends ActiveMQExample // Step 19. Shutdown the request server server.shutdown(); - - return true; } finally { @@ -146,79 +135,78 @@ public class RequestReplyExample extends ActiveMQExample } } } +} - private class SimpleRequestServer implements MessageListener +class SimpleRequestServer implements MessageListener +{ + private Connection connection; + + private Session session; + + MessageProducer replyProducer; + + MessageConsumer requestConsumer; + + public void start() throws Exception { - private Connection connection; + // Get an initial context to perform the JNDI lookup. + InitialContext initialContext = new InitialContext(); - private Session session; + // Lookup the queue to receive the request message + Queue requestQueue = (Queue)initialContext.lookup("queue/exampleQueue"); - MessageProducer replyProducer; + // Lookup for the Connection Factory + ConnectionFactory cfact = (ConnectionFactory)initialContext.lookup("ConnectionFactory"); - MessageConsumer requestConsumer; + // Create a connection + connection = cfact.createConnection(); - public void start() throws Exception + // Start the connection; + connection.start(); + + // Create a session + session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); + + // Create a producer to send the reply message + replyProducer = session.createProducer(null); + + // Create the request comsumer + requestConsumer = session.createConsumer(requestQueue); + + // register the listener + requestConsumer.setMessageListener(this); + } + + public void onMessage(final Message request) + { + try { - // Get an initial context to perform the JNDI lookup. - InitialContext initialContext = new InitialContext(); + System.out.println("Received request message: " + ((TextMessage)request).getText()); - // Lookup the queue to receive the request message - Queue requestQueue = (Queue)initialContext.lookup("queue/exampleQueue"); + // Extract the ReplyTo destination + Destination replyDestination = request.getJMSReplyTo(); - // Lookup for the Connection Factory - ConnectionFactory cfact = (ConnectionFactory)initialContext.lookup("ConnectionFactory"); + System.out.println("Reply to queue: " + replyDestination); - // Create a connection - connection = cfact.createConnection(); + // Create the reply message + TextMessage replyMessage = session.createTextMessage("A reply message"); - // Start the connection; - connection.start(); + // Set the CorrelationID, using message id. + replyMessage.setJMSCorrelationID(request.getJMSMessageID()); - // Create a session - session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); + // Send out the reply message + replyProducer.send(replyDestination, replyMessage); - // Create a producer to send the reply message - replyProducer = session.createProducer(null); - - // Create the request comsumer - requestConsumer = session.createConsumer(requestQueue); - - // register the listener - requestConsumer.setMessageListener(this); + System.out.println("Reply sent"); } - - public void onMessage(final Message request) + catch (JMSException e) { - try - { - System.out.println("Received request message: " + ((TextMessage)request).getText()); - - // Extract the ReplyTo destination - Destination replyDestination = request.getJMSReplyTo(); - - System.out.println("Reply to queue: " + replyDestination); - - // Create the reply message - TextMessage replyMessage = session.createTextMessage("A reply message"); - - // Set the CorrelationID, using message id. - replyMessage.setJMSCorrelationID(request.getJMSMessageID()); - - // Send out the reply message - replyProducer.send(replyDestination, replyMessage); - - System.out.println("Reply sent"); - } - catch (JMSException e) - { - e.printStackTrace(); - } - } - - public void shutdown() throws JMSException - { - connection.close(); + e.printStackTrace(); } } + public void shutdown() throws JMSException + { + connection.close(); + } } diff --git a/examples/jms/scale-down/pom.xml b/examples/jms/scale-down/pom.xml index 5a1cd36585..596273b970 100644 --- a/examples/jms/scale-down/pom.xml +++ b/examples/jms/scale-down/pom.xml @@ -37,8 +37,8 @@ under the License. - org.apache.activemq.examples.jms - common + org.apache.activemq + artemis-cli ${project.version} @@ -57,7 +57,7 @@ under the License. artemis-maven-plugin - create + create0 create @@ -68,7 +68,7 @@ under the License. - create2 + create1 create diff --git a/examples/jms/scale-down/src/main/java/org/apache/activemq/artemis/jms/example/ScaleDownExample.java b/examples/jms/scale-down/src/main/java/org/apache/activemq/artemis/jms/example/ScaleDownExample.java index f3704911de..73adf3320a 100644 --- a/examples/jms/scale-down/src/main/java/org/apache/activemq/artemis/jms/example/ScaleDownExample.java +++ b/examples/jms/scale-down/src/main/java/org/apache/activemq/artemis/jms/example/ScaleDownExample.java @@ -16,6 +16,8 @@ */ package org.apache.activemq.artemis.jms.example; +import org.apache.activemq.artemis.util.ServerUtil; + import javax.jms.Connection; import javax.jms.ConnectionFactory; import javax.jms.MessageConsumer; @@ -26,21 +28,17 @@ import javax.jms.TextMessage; import javax.naming.InitialContext; import java.util.Hashtable; -import org.apache.activemq.artemis.common.example.ActiveMQExample; - /** * A simple example that demonstrates a colocated server * */ -public class ScaleDownExample extends ActiveMQExample +public class ScaleDownExample { - public static void main(final String[] args) - { - new ScaleDownExample().run(args); - } + private static Process server0; - @Override - public boolean runExample() throws Exception + private static Process server1; + + public static void main(final String[] args) throws Exception { final int numMessages = 30; @@ -52,16 +50,19 @@ public class ScaleDownExample extends ActiveMQExample try { + server0 = ServerUtil.startServer(args[0], ScaleDownExample.class.getSimpleName() + "0", 0, 5000); + server1 = ServerUtil.startServer(args[1], ScaleDownExample.class.getSimpleName() + "1", 1, 5000); + // Step 1. Get an initial context for looking up JNDI for both servers Hashtable properties = new Hashtable(); properties.put("java.naming.factory.initial", "org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory"); - properties.put("connectionFactory.ConnectionFactory", DEFAULT_TCP1 + "?ha=true&retryInterval=1000&retryIntervalMultiplier=1.0&reconnectAttempts=-1"); + properties.put("connectionFactory.ConnectionFactory", "tcp://localhost:61616?ha=true&retryInterval=1000&retryIntervalMultiplier=1.0&reconnectAttempts=-1"); properties.put("queue.queue/exampleQueue", "exampleQueue"); initialContext = new InitialContext(properties); properties = new Hashtable(); properties.put("java.naming.factory.initial", "org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory"); - properties.put("connectionFactory.ConnectionFactory", DEFAULT_TCP2 + "?ha=true&retryInterval=1000&retryIntervalMultiplier=1.0&reconnectAttempts=-1"); + properties.put("connectionFactory.ConnectionFactory", "tcp://localhost:61617?ha=true&retryInterval=1000&retryIntervalMultiplier=1.0&reconnectAttempts=-1"); initialContext1 = new InitialContext(properties); // Step 2. Look up the JMS resources from JNDI @@ -92,12 +93,8 @@ public class ScaleDownExample extends ActiveMQExample System.out.println("Sent message: " + message.getText()); } - // Step 7. Crash server #1, the live server, and wait a little while to make sure - // it has really crashed - Thread.sleep(5000); - killServer(1); - Thread.sleep(5000); - + // Step 7. Crash server #1 + ServerUtil.killServer(server1); // Step 8. start the connection ready to receive messages connection.start(); @@ -114,8 +111,6 @@ public class ScaleDownExample extends ActiveMQExample System.out.println("Got message: " + message0.getText()); } message0.acknowledge(); - - return true; } finally { @@ -139,7 +134,9 @@ public class ScaleDownExample extends ActiveMQExample { initialContext1.close(); } + + ServerUtil.killServer(server0); + ServerUtil.killServer(server1); } } - } diff --git a/examples/jms/scale-down/src/main/resources/activemq/server0/artemis-roles.properties b/examples/jms/scale-down/src/main/resources/activemq/server0/artemis-roles.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/scale-down/src/main/resources/activemq/server0/artemis-roles.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/scale-down/src/main/resources/activemq/server0/artemis-users.properties b/examples/jms/scale-down/src/main/resources/activemq/server0/artemis-users.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/scale-down/src/main/resources/activemq/server0/artemis-users.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/scale-down/src/main/resources/activemq/server0/broker.xml b/examples/jms/scale-down/src/main/resources/activemq/server0/broker.xml index b2e18876fc..1a08c9dd33 100644 --- a/examples/jms/scale-down/src/main/resources/activemq/server0/broker.xml +++ b/examples/jms/scale-down/src/main/resources/activemq/server0/broker.xml @@ -29,14 +29,13 @@ under the License. + ${data.dir:./data}/bindings - ${data.dir:../data}/bindings + ${data.dir:./data}/journal - ${data.dir:../data}/journal + ${data.dir:./data}/largemessages - ${data.dir:../data}/largemessages - - ${data.dir:../data}/paging + ${data.dir:./data}/paging diff --git a/examples/jms/scale-down/src/main/resources/activemq/server1/artemis-roles.properties b/examples/jms/scale-down/src/main/resources/activemq/server1/artemis-roles.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/scale-down/src/main/resources/activemq/server1/artemis-roles.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/scale-down/src/main/resources/activemq/server1/artemis-users.properties b/examples/jms/scale-down/src/main/resources/activemq/server1/artemis-users.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/scale-down/src/main/resources/activemq/server1/artemis-users.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/scale-down/src/main/resources/activemq/server1/broker.xml b/examples/jms/scale-down/src/main/resources/activemq/server1/broker.xml index e198399b0e..87dd4aab0e 100644 --- a/examples/jms/scale-down/src/main/resources/activemq/server1/broker.xml +++ b/examples/jms/scale-down/src/main/resources/activemq/server1/broker.xml @@ -29,14 +29,13 @@ under the License. + ${data.dir:./data}/bindings - ${data.dir:../data}/bindings + ${data.dir:./data}/journal - ${data.dir:../data}/journal + ${data.dir:./data}/largemessages - ${data.dir:../data}/largemessages - - ${data.dir:../data}/paging + ${data.dir:./data}/paging diff --git a/examples/jms/scheduled-message/pom.xml b/examples/jms/scheduled-message/pom.xml index 676e5573f0..cfda2ac233 100644 --- a/examples/jms/scheduled-message/pom.xml +++ b/examples/jms/scheduled-message/pom.xml @@ -37,8 +37,8 @@ under the License. - org.apache.activemq.examples.jms - common + org.apache.activemq + artemis-core-client ${project.version} @@ -61,9 +61,18 @@ under the License. create + + + start + + cli + - ${basedir}/target/server0 - ${basedir}/target/classes/activemq/server0 + true + tcp://localhost:61616 + + run + @@ -73,8 +82,16 @@ under the License. org.apache.activemq.artemis.jms.example.ScheduledMessageExample + + + + stop + + cli + + - ${basedir}/target/server0 + stop diff --git a/examples/jms/scheduled-message/src/main/java/org/apache/activemq/artemis/jms/example/ScheduledMessageExample.java b/examples/jms/scheduled-message/src/main/java/org/apache/activemq/artemis/jms/example/ScheduledMessageExample.java index 2fa38bfd2f..ffc99d84ef 100644 --- a/examples/jms/scheduled-message/src/main/java/org/apache/activemq/artemis/jms/example/ScheduledMessageExample.java +++ b/examples/jms/scheduled-message/src/main/java/org/apache/activemq/artemis/jms/example/ScheduledMessageExample.java @@ -29,17 +29,10 @@ import javax.jms.TextMessage; import javax.naming.InitialContext; import org.apache.activemq.artemis.api.core.Message; -import org.apache.activemq.artemis.common.example.ActiveMQExample; -public class ScheduledMessageExample extends ActiveMQExample +public class ScheduledMessageExample { - public static void main(final String[] args) - { - new ScheduledMessageExample().run(args); - } - - @Override - public boolean runExample() throws Exception + public static void main(final String[] args) throws Exception { Connection connection = null; InitialContext initialContext = null; @@ -89,8 +82,6 @@ public class ScheduledMessageExample extends ActiveMQExample System.out.println("Received message: " + messageReceived.getText()); System.out.println("Time of receive: " + formatter.format(new Date())); - - return true; } finally { @@ -105,5 +96,4 @@ public class ScheduledMessageExample extends ActiveMQExample } } } - } diff --git a/examples/jms/scheduled-message/src/main/resources/activemq/server0/artemis-roles.properties b/examples/jms/scheduled-message/src/main/resources/activemq/server0/artemis-roles.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/scheduled-message/src/main/resources/activemq/server0/artemis-roles.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/scheduled-message/src/main/resources/activemq/server0/artemis-users.properties b/examples/jms/scheduled-message/src/main/resources/activemq/server0/artemis-users.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/scheduled-message/src/main/resources/activemq/server0/artemis-users.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/scheduled-message/src/main/resources/activemq/server0/broker.xml b/examples/jms/scheduled-message/src/main/resources/activemq/server0/broker.xml deleted file mode 100644 index 7690094861..0000000000 --- a/examples/jms/scheduled-message/src/main/resources/activemq/server0/broker.xml +++ /dev/null @@ -1,60 +0,0 @@ - - - - - - - - - - - - - ${data.dir}/server0/data/messaging/bindings - - ${data.dir}/server0/data/messaging/journal - - ${data.dir}/server0/data/messaging/largemessages - - ${data.dir}/server0/data/messaging/paging - - - - tcp://localhost:61616 - - - - - - - - - - - - - - - - - - diff --git a/examples/jms/security/pom.xml b/examples/jms/security/pom.xml index 88330b12a0..a58e17701c 100644 --- a/examples/jms/security/pom.xml +++ b/examples/jms/security/pom.xml @@ -36,11 +36,6 @@ under the License. - - org.apache.activemq.examples.jms - common - ${project.version} - org.apache.geronimo.specs geronimo-jms_2.0_spec @@ -61,9 +56,20 @@ under the License. create + + + start + + cli + - ${basedir}/target/server0 - ${basedir}/target/classes/activemq/server0 + true + tcp://localhost:61616 + bill + activemq + + run + @@ -73,8 +79,16 @@ under the License. org.apache.activemq.artemis.jms.example.SecurityExample + + + + stop + + cli + + - ${basedir}/target/server0 + stop diff --git a/examples/jms/security/src/main/java/org/apache/activemq/artemis/jms/example/SecurityExample.java b/examples/jms/security/src/main/java/org/apache/activemq/artemis/jms/example/SecurityExample.java index eb7ffc0a28..fc83fe7ebd 100644 --- a/examples/jms/security/src/main/java/org/apache/activemq/artemis/jms/example/SecurityExample.java +++ b/examples/jms/security/src/main/java/org/apache/activemq/artemis/jms/example/SecurityExample.java @@ -27,20 +27,13 @@ import javax.jms.TextMessage; import javax.jms.Topic; import javax.naming.InitialContext; -import org.apache.activemq.artemis.common.example.ActiveMQExample; - -public class SecurityExample extends ActiveMQExample +public class SecurityExample { - private boolean result = true; - public static void main(final String[] args) - { - new SecurityExample().run(args); - } - - @Override - public boolean runExample() throws Exception + public static void main(final String[] args) throws Exception { + boolean result = true; + Connection failConnection = null; Connection billConnection = null; Connection andrewConnection = null; Connection frankConnection = null; @@ -63,7 +56,7 @@ public class SecurityExample extends ActiveMQExample // Step 4. Try to create a JMS Connection without user/password. It will fail. try { - cf.createConnection(); + failConnection = cf.createConnection(); result = false; } catch (JMSSecurityException e) @@ -136,12 +129,14 @@ public class SecurityExample extends ActiveMQExample // Step 18. Check permissions on news.us.usTopic for sam: can't send but can receive checkUserReceiveNoSend(usTopic, samConnection, "sam", frankConnection); System.out.println("-------------------------------------------------------------------------------------"); - - return result; } finally { // Step 19. Be sure to close our JMS resources! + if (failConnection != null) + { + failConnection.close(); + } if (billConnection != null) { billConnection.close(); @@ -168,7 +163,7 @@ public class SecurityExample extends ActiveMQExample } // Check the user can receive message but cannot send message. - private void checkUserReceiveNoSend(final Topic topic, + private static void checkUserReceiveNoSend(final Topic topic, final Connection connection, final String user, final Connection sendingConn) throws JMSException @@ -181,12 +176,11 @@ public class SecurityExample extends ActiveMQExample try { producer.send(msg); - System.out.println("Security setting is broken! User " + user + + throw new IllegalStateException("Security setting is broken! User " + user + " can send message [" + msg.getText() + "] to topic " + topic); - result = false; } catch (JMSException e) { @@ -206,8 +200,7 @@ public class SecurityExample extends ActiveMQExample } else { - System.out.println("Security setting is broken! User " + user + " cannot receive message from topic " + topic); - result = false; + throw new IllegalStateException("Security setting is broken! User " + user + " cannot receive message from topic " + topic); } session1.close(); @@ -215,7 +208,7 @@ public class SecurityExample extends ActiveMQExample } // Check the user can send message but cannot receive message - private void checkUserSendNoReceive(final Topic topic, + private static void checkUserSendNoReceive(final Topic topic, final Connection connection, final String user, final Connection receivingConn) throws JMSException @@ -244,12 +237,11 @@ public class SecurityExample extends ActiveMQExample } else { - System.out.println("Security setting is broken! User " + user + + throw new IllegalStateException("Security setting is broken! User " + user + " cannot send message [" + msg.getText() + "] to topic " + topic); - result = false; } session.close(); @@ -257,7 +249,7 @@ public class SecurityExample extends ActiveMQExample } // Check the user has neither send nor receive permission on topic - private void checkUserNoSendNoReceive(final Topic topic, final Connection connection, final String user) throws JMSException + private static void checkUserNoSendNoReceive(final Topic topic, final Connection connection, final String user) throws JMSException { Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); MessageProducer producer = session.createProducer(topic); @@ -275,12 +267,11 @@ public class SecurityExample extends ActiveMQExample try { producer.send(msg); - System.out.println("Security setting is broken! User " + user + + throw new IllegalStateException("Security setting is broken! User " + user + " can send message [" + msg.getText() + "] to topic " + topic); - result = false; } catch (JMSException e) { @@ -291,7 +282,7 @@ public class SecurityExample extends ActiveMQExample } // Check the user connection has both send and receive permissions on the topic - private void checkUserSendAndReceive(final Topic topic, final Connection connection, final String user) throws JMSException + private static void checkUserSendAndReceive(final Topic topic, final Connection connection, final String user) throws JMSException { Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); TextMessage msg = session.createTextMessage("hello-world-4"); @@ -306,13 +297,12 @@ public class SecurityExample extends ActiveMQExample } else { - System.out.println("Error! User " + user + " cannot receive the message! "); - result = false; + throw new IllegalStateException("Error! User " + user + " cannot receive the message! "); } session.close(); } - private Connection createConnection(final String username, final String password, final ConnectionFactory cf) throws JMSException + private static Connection createConnection(final String username, final String password, final ConnectionFactory cf) throws JMSException { return cf.createConnection(username, password); } diff --git a/examples/jms/send-acknowledgements/pom.xml b/examples/jms/send-acknowledgements/pom.xml index 7aa59cf24a..6d22b092ce 100644 --- a/examples/jms/send-acknowledgements/pom.xml +++ b/examples/jms/send-acknowledgements/pom.xml @@ -37,8 +37,8 @@ under the License. - org.apache.activemq.examples.jms - common + org.apache.activemq + artemis-jms-client ${project.version} @@ -61,9 +61,18 @@ under the License. create + + + start + + cli + - ${basedir}/target/server0 - ${basedir}/target/classes/activemq/server0 + true + tcp://localhost:61616 + + run + @@ -73,8 +82,16 @@ under the License. org.apache.activemq.artemis.jms.example.SendAcknowledgementsExample + + + + stop + + cli + + - ${basedir}/target/server0 + stop diff --git a/examples/jms/send-acknowledgements/src/main/java/org/apache/activemq/artemis/jms/example/SendAcknowledgementsExample.java b/examples/jms/send-acknowledgements/src/main/java/org/apache/activemq/artemis/jms/example/SendAcknowledgementsExample.java index 03fb866a1b..99fb0bae21 100644 --- a/examples/jms/send-acknowledgements/src/main/java/org/apache/activemq/artemis/jms/example/SendAcknowledgementsExample.java +++ b/examples/jms/send-acknowledgements/src/main/java/org/apache/activemq/artemis/jms/example/SendAcknowledgementsExample.java @@ -27,7 +27,6 @@ import javax.naming.InitialContext; import org.apache.activemq.artemis.api.core.Message; import org.apache.activemq.artemis.api.core.client.ClientSession; import org.apache.activemq.artemis.api.core.client.SendAcknowledgementHandler; -import org.apache.activemq.artemis.common.example.ActiveMQExample; import org.apache.activemq.artemis.jms.client.ActiveMQSession; /** @@ -37,15 +36,9 @@ import org.apache.activemq.artemis.jms.client.ActiveMQSession; * to the stream of messages being sent to the server. * For more information please see the readme.html file */ -public class SendAcknowledgementsExample extends ActiveMQExample +public class SendAcknowledgementsExample { - public static void main(final String[] args) - { - new SendAcknowledgementsExample().run(args); - } - - @Override - public boolean runExample() throws Exception + public static void main(final String[] args) throws Exception { Connection connection = null; InitialContext initialContext = null; @@ -101,8 +94,6 @@ public class SendAcknowledgementsExample extends ActiveMQExample System.out.println("Sent message " + i); } - - return true; } finally { @@ -118,5 +109,4 @@ public class SendAcknowledgementsExample extends ActiveMQExample } } } - } diff --git a/examples/jms/send-acknowledgements/src/main/resources/activemq/server0/artemis-roles.properties b/examples/jms/send-acknowledgements/src/main/resources/activemq/server0/artemis-roles.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/send-acknowledgements/src/main/resources/activemq/server0/artemis-roles.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/send-acknowledgements/src/main/resources/activemq/server0/artemis-users.properties b/examples/jms/send-acknowledgements/src/main/resources/activemq/server0/artemis-users.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/send-acknowledgements/src/main/resources/activemq/server0/artemis-users.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/send-acknowledgements/src/main/resources/activemq/server0/broker.xml b/examples/jms/send-acknowledgements/src/main/resources/activemq/server0/broker.xml deleted file mode 100644 index 7690094861..0000000000 --- a/examples/jms/send-acknowledgements/src/main/resources/activemq/server0/broker.xml +++ /dev/null @@ -1,60 +0,0 @@ - - - - - - - - - - - - - ${data.dir}/server0/data/messaging/bindings - - ${data.dir}/server0/data/messaging/journal - - ${data.dir}/server0/data/messaging/largemessages - - ${data.dir}/server0/data/messaging/paging - - - - tcp://localhost:61616 - - - - - - - - - - - - - - - - - - diff --git a/examples/jms/spring-integration/pom.xml b/examples/jms/spring-integration/pom.xml index 25ae488804..fcc6d9f6f3 100644 --- a/examples/jms/spring-integration/pom.xml +++ b/examples/jms/spring-integration/pom.xml @@ -36,11 +36,6 @@ under the License. - - org.apache.activemq.examples.jms - common - ${project.version} - org.apache.activemq artemis-spring-integration @@ -72,9 +67,6 @@ under the License. org.apache.activemq.artemis.jms.example.SpringExample - - ${basedir}/target/server0 - diff --git a/examples/jms/ssl-enabled/pom.xml b/examples/jms/ssl-enabled/pom.xml index 47989bf0f5..7c6e4f82b2 100644 --- a/examples/jms/ssl-enabled/pom.xml +++ b/examples/jms/ssl-enabled/pom.xml @@ -36,11 +36,6 @@ under the License. - - org.apache.activemq.examples.jms - common - ${project.version} - org.apache.geronimo.specs geronimo-jms_2.0_spec @@ -61,9 +56,18 @@ under the License. create + + + start + + cli + - ${basedir}/target/server0 - ${basedir}/target/classes/activemq/server0 + true + tcp://localhost:5500?sslEnabled=true&trustStorePath=activemq/server0/activemq.example.truststore&trustStorePassword=activemqexample + + run + @@ -73,8 +77,16 @@ under the License. org.apache.activemq.artemis.jms.example.SSLExample + + + + stop + + cli + + - ${basedir}/target/server0 + stop diff --git a/examples/jms/ssl-enabled/src/main/java/org/apache/activemq/artemis/jms/example/SSLExample.java b/examples/jms/ssl-enabled/src/main/java/org/apache/activemq/artemis/jms/example/SSLExample.java index 11f5a91464..a43e4c00c6 100644 --- a/examples/jms/ssl-enabled/src/main/java/org/apache/activemq/artemis/jms/example/SSLExample.java +++ b/examples/jms/ssl-enabled/src/main/java/org/apache/activemq/artemis/jms/example/SSLExample.java @@ -25,20 +25,12 @@ import javax.jms.Session; import javax.jms.TextMessage; import javax.naming.InitialContext; -import org.apache.activemq.artemis.common.example.ActiveMQExample; - /** * A simple JMS Queue example that uses SSL secure transport. */ -public class SSLExample extends ActiveMQExample +public class SSLExample { - public static void main(final String[] args) - { - new SSLExample().run(args); - } - - @Override - public boolean runExample() throws Exception + public static void main(final String[] args) throws Exception { Connection connection = null; InitialContext initialContext = null; @@ -82,8 +74,6 @@ public class SSLExample extends ActiveMQExample System.out.println("Received message: " + messageReceived.getText()); initialContext.close(); - - return true; } finally { @@ -98,5 +88,4 @@ public class SSLExample extends ActiveMQExample } } } - } diff --git a/examples/jms/static-selector-jms/pom.xml b/examples/jms/static-selector-jms/pom.xml index 750af0002f..02b8fb7038 100644 --- a/examples/jms/static-selector-jms/pom.xml +++ b/examples/jms/static-selector-jms/pom.xml @@ -36,11 +36,6 @@ under the License. - - org.apache.activemq.examples.jms - common - ${project.version} - org.apache.geronimo.specs geronimo-jms_2.0_spec @@ -61,9 +56,18 @@ under the License. create + + + start + + cli + - ${basedir}/target/server0 - ${basedir}/target/classes/activemq/server0 + true + tcp://localhost:61616 + + run + @@ -73,8 +77,16 @@ under the License. org.apache.activemq.artemis.jms.example.StaticSelectorJMSExample + + + + stop + + cli + + - ${basedir}/target/server0 + stop @@ -91,6 +103,4 @@ under the License. - - diff --git a/examples/jms/static-selector-jms/src/main/java/org/apache/activemq/artemis/jms/example/StaticSelectorJMSExample.java b/examples/jms/static-selector-jms/src/main/java/org/apache/activemq/artemis/jms/example/StaticSelectorJMSExample.java index 16c22e5cbf..0f064175df 100644 --- a/examples/jms/static-selector-jms/src/main/java/org/apache/activemq/artemis/jms/example/StaticSelectorJMSExample.java +++ b/examples/jms/static-selector-jms/src/main/java/org/apache/activemq/artemis/jms/example/StaticSelectorJMSExample.java @@ -27,24 +27,16 @@ import javax.jms.Queue; import javax.jms.Session; import javax.jms.TextMessage; import javax.naming.InitialContext; - -import org.apache.activemq.artemis.common.example.ActiveMQExample; +import java.util.concurrent.atomic.AtomicBoolean; /** * A simple JMS example that shows how static message selectors work when using JMS config. */ -public class StaticSelectorJMSExample extends ActiveMQExample +public class StaticSelectorJMSExample { - private volatile boolean result = true; - - public static void main(final String[] args) - { - new StaticSelectorJMSExample().run(args); - } - - @Override - public boolean runExample() throws Exception + public static void main(final String[] args) throws Exception { + AtomicBoolean result = new AtomicBoolean(true); Connection connection = null; InitialContext initialContext = null; try @@ -73,7 +65,7 @@ public class StaticSelectorJMSExample extends ActiveMQExample // Step 8. Create a JMS Message Consumer that receives 'red' messages MessageConsumer redConsumer = session.createConsumer(queue); - redConsumer.setMessageListener(new SimpleMessageListener("red")); + redConsumer.setMessageListener(new SimpleMessageListener("red", result)); // Step 9. Create five messages with different 'color' properties TextMessage redMessage1 = session.createTextMessage("Red-1"); @@ -101,7 +93,8 @@ public class StaticSelectorJMSExample extends ActiveMQExample // Step 11. Waiting for the message listener to check the received messages. Thread.sleep(5000); - return result; + if (!result.get()) + throw new IllegalStateException(); } finally { @@ -116,38 +109,39 @@ public class StaticSelectorJMSExample extends ActiveMQExample } } } +} - public class SimpleMessageListener implements MessageListener +class SimpleMessageListener implements MessageListener +{ + private final String name; + private AtomicBoolean result; + + public SimpleMessageListener(final String listener, AtomicBoolean result) { - private final String name; - - public SimpleMessageListener(final String listener) - { - name = listener; - } - - public void onMessage(final Message msg) - { - TextMessage textMessage = (TextMessage)msg; - try - { - String colorProp = msg.getStringProperty("color"); - System.out.println("Receiver " + name + - " receives message [" + - textMessage.getText() + - "] with color property: " + - colorProp); - if (colorProp != null && !colorProp.equals(name)) - { - result = false; - } - } - catch (JMSException e) - { - e.printStackTrace(); - result = false; - } - } + name = listener; + this.result = result; } + public void onMessage(final Message msg) + { + TextMessage textMessage = (TextMessage)msg; + try + { + String colorProp = msg.getStringProperty("color"); + System.out.println("Receiver " + name + + " receives message [" + + textMessage.getText() + + "] with color property: " + + colorProp); + if (colorProp != null && !colorProp.equals(name)) + { + result.set(false); + } + } + catch (JMSException e) + { + e.printStackTrace(); + result.set(false); + } + } } \ No newline at end of file diff --git a/examples/jms/static-selector-jms/src/main/resources/activemq/server0/broker.xml b/examples/jms/static-selector-jms/src/main/resources/activemq/server0/broker.xml index 7442fac3fa..cdeb5343e0 100644 --- a/examples/jms/static-selector-jms/src/main/resources/activemq/server0/broker.xml +++ b/examples/jms/static-selector-jms/src/main/resources/activemq/server0/broker.xml @@ -31,13 +31,13 @@ under the License. - ${data.dir}/server0/data/messaging/bindings + ${data.dir:../data}/bindings - ${data.dir}/server0/data/messaging/journal + ${data.dir:../data}/journal - ${data.dir}/server0/data/messaging/largemessages + ${data.dir:../data}/largemessages - ${data.dir}/server0/data/messaging/paging + ${data.dir:../data}/paging diff --git a/examples/jms/static-selector/pom.xml b/examples/jms/static-selector/pom.xml index cf08771d58..54881c9e8d 100644 --- a/examples/jms/static-selector/pom.xml +++ b/examples/jms/static-selector/pom.xml @@ -36,11 +36,6 @@ under the License. - - org.apache.activemq.examples.jms - common - ${project.version} - org.apache.geronimo.specs geronimo-jms_2.0_spec @@ -61,9 +56,18 @@ under the License. create + + + start + + cli + - ${basedir}/target/server0 - ${basedir}/target/classes/activemq/server0 + true + tcp://localhost:61616 + + run + @@ -73,8 +77,16 @@ under the License. org.apache.activemq.artemis.jms.example.StaticSelectorExample + + + + stop + + cli + + - ${basedir}/target/server0 + stop diff --git a/examples/jms/static-selector/src/main/java/org/apache/activemq/artemis/jms/example/StaticSelectorExample.java b/examples/jms/static-selector/src/main/java/org/apache/activemq/artemis/jms/example/StaticSelectorExample.java index b8449940f3..532ca50bc6 100644 --- a/examples/jms/static-selector/src/main/java/org/apache/activemq/artemis/jms/example/StaticSelectorExample.java +++ b/examples/jms/static-selector/src/main/java/org/apache/activemq/artemis/jms/example/StaticSelectorExample.java @@ -27,24 +27,16 @@ import javax.jms.Queue; import javax.jms.Session; import javax.jms.TextMessage; import javax.naming.InitialContext; - -import org.apache.activemq.artemis.common.example.ActiveMQExample; +import java.util.concurrent.atomic.AtomicBoolean; /** * A simple JMS example that shows how static message selectors work. */ -public class StaticSelectorExample extends ActiveMQExample +public class StaticSelectorExample { - private volatile boolean result = true; - - public static void main(final String[] args) - { - new StaticSelectorExample().run(args); - } - - @Override - public boolean runExample() throws Exception + public static void main(final String[] args) throws Exception { + AtomicBoolean result = new AtomicBoolean(true); Connection connection = null; InitialContext initialContext = null; try @@ -73,7 +65,7 @@ public class StaticSelectorExample extends ActiveMQExample // Step 8. Create a JMS Message Consumer that receives 'red' messages MessageConsumer redConsumer = session.createConsumer(queue); - redConsumer.setMessageListener(new SimpleMessageListener("red")); + redConsumer.setMessageListener(new SimpleMessageListener("red", result)); // Step 9. Create five messages with different 'color' properties TextMessage redMessage1 = session.createTextMessage("Red-1"); @@ -101,7 +93,8 @@ public class StaticSelectorExample extends ActiveMQExample // Step 11. Waiting for the message listener to check the received messages. Thread.sleep(5000); - return result; + if (!result.get()) + throw new IllegalStateException(); } finally { @@ -116,38 +109,40 @@ public class StaticSelectorExample extends ActiveMQExample } } } +} - public class SimpleMessageListener implements MessageListener + +class SimpleMessageListener implements MessageListener +{ + private final String name; + private AtomicBoolean result; + + public SimpleMessageListener(final String listener, AtomicBoolean result) { - private final String name; - - public SimpleMessageListener(final String listener) - { - name = listener; - } - - public void onMessage(final Message msg) - { - TextMessage textMessage = (TextMessage)msg; - try - { - String colorProp = msg.getStringProperty("color"); - System.out.println("Receiver " + name + - " receives message [" + - textMessage.getText() + - "] with color property: " + - colorProp); - if (colorProp != null && !colorProp.equals(name)) - { - result = false; - } - } - catch (JMSException e) - { - e.printStackTrace(); - result = false; - } - } + name = listener; + this.result = result; } + public void onMessage(final Message msg) + { + TextMessage textMessage = (TextMessage)msg; + try + { + String colorProp = msg.getStringProperty("color"); + System.out.println("Receiver " + name + + " receives message [" + + textMessage.getText() + + "] with color property: " + + colorProp); + if (colorProp != null && !colorProp.equals(name)) + { + result.set(false); + } + } + catch (JMSException e) + { + e.printStackTrace(); + result.set(false); + } + } } diff --git a/examples/jms/stomp-websockets/pom.xml b/examples/jms/stomp-websockets/pom.xml index d64b66dccb..64c3ced878 100644 --- a/examples/jms/stomp-websockets/pom.xml +++ b/examples/jms/stomp-websockets/pom.xml @@ -36,11 +36,6 @@ under the License. - - org.apache.activemq.examples.jms - common - ${project.version} - org.apache.geronimo.specs geronimo-jms_2.0_spec @@ -61,9 +56,18 @@ under the License. create + + + start + + cli + - ${basedir}/target/server0 - ${basedir}/target/classes/activemq/server0 + true + tcp://localhost:61616 + + run + @@ -73,8 +77,16 @@ under the License. org.apache.activemq.artemis.jms.example.StompWebSocketExample + + + + stop + + cli + + - ${basedir}/target/server0 + stop diff --git a/examples/jms/stomp-websockets/src/main/java/org/apache/activemq/artemis/jms/example/StompWebSocketExample.java b/examples/jms/stomp-websockets/src/main/java/org/apache/activemq/artemis/jms/example/StompWebSocketExample.java index fcaa63a6ff..7260a091d9 100644 --- a/examples/jms/stomp-websockets/src/main/java/org/apache/activemq/artemis/jms/example/StompWebSocketExample.java +++ b/examples/jms/stomp-websockets/src/main/java/org/apache/activemq/artemis/jms/example/StompWebSocketExample.java @@ -27,21 +27,13 @@ import javax.jms.TextMessage; import javax.jms.Topic; import javax.naming.InitialContext; -import org.apache.activemq.artemis.common.example.ActiveMQExample; - /** * An example where a client will send a JMS message to a Topic. * Browser clients connected using Web Sockets will be able to receive the message. */ -public class StompWebSocketExample extends ActiveMQExample +public class StompWebSocketExample { - public static void main(final String[] args) - { - new StompWebSocketExample().run(args); - } - - @Override - public boolean runExample() throws Exception + public static void main(final String[] args) throws Exception { Connection connection = null; InitialContext initialContext = null; @@ -70,8 +62,6 @@ public class StompWebSocketExample extends ActiveMQExample message = (TextMessage)consumer.receive(); System.out.println("Received message: " + message.getText()); - - return true; } finally { diff --git a/examples/jms/stomp-websockets/src/main/resources/activemq/server0/artemis-roles.properties b/examples/jms/stomp-websockets/src/main/resources/activemq/server0/artemis-roles.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/stomp-websockets/src/main/resources/activemq/server0/artemis-roles.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/stomp-websockets/src/main/resources/activemq/server0/artemis-users.properties b/examples/jms/stomp-websockets/src/main/resources/activemq/server0/artemis-users.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/stomp-websockets/src/main/resources/activemq/server0/artemis-users.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/stomp-websockets/src/main/resources/activemq/server0/broker.xml b/examples/jms/stomp-websockets/src/main/resources/activemq/server0/broker.xml index ce256a9f7f..efceecf8e5 100644 --- a/examples/jms/stomp-websockets/src/main/resources/activemq/server0/broker.xml +++ b/examples/jms/stomp-websockets/src/main/resources/activemq/server0/broker.xml @@ -29,13 +29,13 @@ under the License. - ${data.dir}/server0/data/messaging/bindings + ${data.dir:./data}/bindings - ${data.dir}/server0/data/messaging/journal + ${data.dir:./data}/journal - ${data.dir}/server0/data/messaging/largemessages + ${data.dir:./data}/largemessages - ${data.dir}/server0/data/messaging/paging + ${data.dir:./data}/paging diff --git a/examples/jms/stomp/pom.xml b/examples/jms/stomp/pom.xml index 809e433ee5..867827d5cf 100644 --- a/examples/jms/stomp/pom.xml +++ b/examples/jms/stomp/pom.xml @@ -36,11 +36,6 @@ under the License. - - org.apache.activemq.examples.jms - common - ${project.version} - org.apache.geronimo.specs geronimo-jms_2.0_spec @@ -61,9 +56,18 @@ under the License. create + + + start + + cli + - ${basedir}/target/server0 - ${basedir}/target/classes/activemq/server0 + true + tcp://localhost:61616 + + run + @@ -73,8 +77,16 @@ under the License. org.apache.activemq.artemis.jms.example.StompExample + + + + stop + + cli + + - ${basedir}/target/server0 + stop diff --git a/examples/jms/stomp/src/main/java/org/apache/activemq/artemis/jms/example/StompExample.java b/examples/jms/stomp/src/main/java/org/apache/activemq/artemis/jms/example/StompExample.java index bf10f6f981..0d4f28f3e0 100644 --- a/examples/jms/stomp/src/main/java/org/apache/activemq/artemis/jms/example/StompExample.java +++ b/examples/jms/stomp/src/main/java/org/apache/activemq/artemis/jms/example/StompExample.java @@ -29,24 +29,15 @@ import javax.jms.Session; import javax.jms.TextMessage; import javax.naming.InitialContext; - -import org.apache.activemq.artemis.common.example.ActiveMQExample; - /** * An example where a client will send a Stomp message on a TCP socket * and consume it from a JMS MessageConsumer. */ -public class StompExample extends ActiveMQExample +public class StompExample { private static final String END_OF_FRAME = "\u0000"; - public static void main(final String[] args) - { - new StompExample().run(args); - } - - @Override - public boolean runExample() throws Exception + public static void main(final String[] args) throws Exception { Connection connection = null; InitialContext initialContext = null; @@ -58,11 +49,11 @@ public class StompExample extends ActiveMQExample // Step 2. Send a CONNECT frame to connect to the server String connectFrame = "CONNECT\n" + - "login: guest\n" + - "passcode: guest\n" + - "request-id: 1\n" + - "\n" + - END_OF_FRAME; + "login: guest\n" + + "passcode: guest\n" + + "request-id: 1\n" + + "\n" + + END_OF_FRAME; sendFrame(socket, connectFrame); readFrame(socket); @@ -71,17 +62,17 @@ public class StompExample extends ActiveMQExample // jms.queue.exampleQueue address with a text body String text = "Hello, world from Stomp!"; String message = "SEND\n" + - "destination: jms.queue.exampleQueue\n" + - "\n" + - text + - END_OF_FRAME; + "destination: jms.queue.exampleQueue\n" + + "\n" + + text + + END_OF_FRAME; sendFrame(socket, message); System.out.println("Sent Stomp message: " + text); // Step 4. Send a DISCONNECT frame to disconnect from the server String disconnectFrame = "DISCONNECT\n" + - "\n" + - END_OF_FRAME; + "\n" + + END_OF_FRAME; sendFrame(socket, disconnectFrame); // Step 5. Slose the TCP socket @@ -107,8 +98,6 @@ public class StompExample extends ActiveMQExample // Step 10. Receive the message TextMessage messageReceived = (TextMessage)consumer.receive(5000); System.out.println("Received JMS message: " + messageReceived.getText()); - - return true; } finally { diff --git a/examples/jms/stomp/src/main/resources/activemq/server0/broker.xml b/examples/jms/stomp/src/main/resources/activemq/server0/broker.xml index b24f1da6bd..c0ada1eab1 100644 --- a/examples/jms/stomp/src/main/resources/activemq/server0/broker.xml +++ b/examples/jms/stomp/src/main/resources/activemq/server0/broker.xml @@ -29,13 +29,13 @@ under the License. - ${data.dir}/server0/data/messaging/bindings + ${data.dir:../data}/bindings - ${data.dir}/server0/data/messaging/journal + ${data.dir:../data}/journal - ${data.dir}/server0/data/messaging/largemessages + ${data.dir:../data}/largemessages - ${data.dir}/server0/data/messaging/paging + ${data.dir:../data}/paging diff --git a/examples/jms/stomp1.1/pom.xml b/examples/jms/stomp1.1/pom.xml index 14e9a76483..b17e9c09f0 100644 --- a/examples/jms/stomp1.1/pom.xml +++ b/examples/jms/stomp1.1/pom.xml @@ -36,11 +36,6 @@ under the License. - - org.apache.activemq.examples.jms - common - ${project.version} - org.apache.geronimo.specs geronimo-jms_2.0_spec @@ -61,9 +56,18 @@ under the License. create + + + start + + cli + - ${basedir}/target/server0 - ${basedir}/target/classes/activemq/server0 + true + tcp://localhost:61616 + + run + @@ -73,8 +77,16 @@ under the License. org.apache.activemq.artemis.jms.example.StompExample + + + + stop + + cli + + - ${basedir}/target/server0 + stop diff --git a/examples/jms/stomp1.1/src/main/java/org/apache/activemq/artemis/jms/example/StompExample.java b/examples/jms/stomp1.1/src/main/java/org/apache/activemq/artemis/jms/example/StompExample.java index ee03b85fb6..7d3b3cc5bd 100644 --- a/examples/jms/stomp1.1/src/main/java/org/apache/activemq/artemis/jms/example/StompExample.java +++ b/examples/jms/stomp1.1/src/main/java/org/apache/activemq/artemis/jms/example/StompExample.java @@ -29,23 +29,15 @@ import javax.jms.Session; import javax.jms.TextMessage; import javax.naming.InitialContext; -import org.apache.activemq.artemis.common.example.ActiveMQExample; - /** * An example where a Stomp 1.1 client sends a message on a TCP socket * and consumes it from a JMS MessageConsumer. */ -public class StompExample extends ActiveMQExample +public class StompExample { private static final String END_OF_FRAME = "\u0000"; - public static void main(final String[] args) - { - new StompExample().run(args); - } - - @Override - public boolean runExample() throws Exception + public static void main(final String[] args) throws Exception { Connection connection = null; InitialContext initialContext = null; @@ -57,13 +49,13 @@ public class StompExample extends ActiveMQExample // Step 2. Send a CONNECT frame to connect to the server String connectFrame = "CONNECT\n" + - "accept-version:1.1\n" + - "host:localhost\n" + - "login:guest\n" + - "passcode:guest\n" + - "request-id:1\n" + - "\n" + - END_OF_FRAME; + "accept-version:1.1\n" + + "host:localhost\n" + + "login:guest\n" + + "passcode:guest\n" + + "request-id:1\n" + + "\n" + + END_OF_FRAME; sendFrame(socket, connectFrame); String response = receiveFrame(socket); @@ -73,17 +65,17 @@ public class StompExample extends ActiveMQExample // jms.queue.exampleQueue address with a text body String text = "Hello World from Stomp 1.1 !"; String message = "SEND\n" + - "destination:jms.queue.exampleQueue\n" + - "\n" + - text + - END_OF_FRAME; + "destination:jms.queue.exampleQueue\n" + + "\n" + + text + + END_OF_FRAME; sendFrame(socket, message); System.out.println("Sent Stomp message: " + text); // Step 4. Send a DISCONNECT frame to disconnect from the server String disconnectFrame = "DISCONNECT\n" + - "\n" + - END_OF_FRAME; + "\n" + + END_OF_FRAME; sendFrame(socket, disconnectFrame); // Step 5. Slose the TCP socket @@ -109,8 +101,6 @@ public class StompExample extends ActiveMQExample // Step 10. Receive the message TextMessage messageReceived = (TextMessage)consumer.receive(5000); System.out.println("Received JMS message: " + messageReceived.getText()); - - return true; } finally { diff --git a/examples/jms/stomp1.1/src/main/resources/activemq/server0/artemis-roles.properties b/examples/jms/stomp1.1/src/main/resources/activemq/server0/artemis-roles.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/stomp1.1/src/main/resources/activemq/server0/artemis-roles.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/stomp1.1/src/main/resources/activemq/server0/artemis-users.properties b/examples/jms/stomp1.1/src/main/resources/activemq/server0/artemis-users.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/stomp1.1/src/main/resources/activemq/server0/artemis-users.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/stomp1.1/src/main/resources/activemq/server0/broker.xml b/examples/jms/stomp1.1/src/main/resources/activemq/server0/broker.xml index b24f1da6bd..9688ae9824 100644 --- a/examples/jms/stomp1.1/src/main/resources/activemq/server0/broker.xml +++ b/examples/jms/stomp1.1/src/main/resources/activemq/server0/broker.xml @@ -29,13 +29,13 @@ under the License. - ${data.dir}/server0/data/messaging/bindings + ${data.dir:./data}/bindings - ${data.dir}/server0/data/messaging/journal + ${data.dir:./data}/journal - ${data.dir}/server0/data/messaging/largemessages + ${data.dir:./data}/largemessages - ${data.dir}/server0/data/messaging/paging + ${data.dir:./data}/paging diff --git a/examples/jms/stomp1.2/pom.xml b/examples/jms/stomp1.2/pom.xml index c696d8b737..e673181ea9 100644 --- a/examples/jms/stomp1.2/pom.xml +++ b/examples/jms/stomp1.2/pom.xml @@ -36,11 +36,6 @@ under the License. - - org.apache.activemq.examples.jms - common - ${project.version} - org.apache.geronimo.specs geronimo-jms_2.0_spec @@ -61,9 +56,18 @@ under the License. create + + + start + + cli + - ${basedir}/target/server0 - ${basedir}/target/classes/activemq/server0 + true + tcp://localhost:61616 + + run + @@ -73,8 +77,16 @@ under the License. org.apache.activemq.artemis.jms.example.StompExample + + + + stop + + cli + + - ${basedir}/target/server0 + stop diff --git a/examples/jms/stomp1.2/src/main/java/org/apache/activemq/artemis/jms/example/StompExample.java b/examples/jms/stomp1.2/src/main/java/org/apache/activemq/artemis/jms/example/StompExample.java index f3a0ad7bff..fc978f7113 100644 --- a/examples/jms/stomp1.2/src/main/java/org/apache/activemq/artemis/jms/example/StompExample.java +++ b/examples/jms/stomp1.2/src/main/java/org/apache/activemq/artemis/jms/example/StompExample.java @@ -28,23 +28,15 @@ import javax.jms.Session; import javax.jms.TextMessage; import javax.naming.InitialContext; -import org.apache.activemq.artemis.common.example.ActiveMQExample; - /** * An example where a Stomp 1.2 client sends a message on a TCP socket * and consumes it from a JMS MessageConsumer. */ -public class StompExample extends ActiveMQExample +public class StompExample { private static final String END_OF_FRAME = "\u0000"; - public static void main(final String[] args) - { - new StompExample().run(args); - } - - @Override - public boolean runExample() throws Exception + public static void main(final String[] args) throws Exception { Connection connection = null; InitialContext initialContext = null; @@ -56,13 +48,13 @@ public class StompExample extends ActiveMQExample // Step 2. Send a CONNECT frame to connect to the server String connectFrame = "CONNECT\n" + - "accept-version:1.2\n" + - "host:localhost\n" + - "login:guest\n" + - "passcode:guest\n" + - "request-id:1\n" + - "\n" + - END_OF_FRAME; + "accept-version:1.2\n" + + "host:localhost\n" + + "login:guest\n" + + "passcode:guest\n" + + "request-id:1\n" + + "\n" + + END_OF_FRAME; sendFrame(socket, connectFrame); String response = receiveFrame(socket); @@ -72,17 +64,17 @@ public class StompExample extends ActiveMQExample // jms.queue.exampleQueue address with a text body String text = "Hello World from Stomp 1.2 !"; String message = "SEND\n" + - "destination:jms.queue.exampleQueue\n" + - "\n" + - text + - END_OF_FRAME; + "destination:jms.queue.exampleQueue\n" + + "\n" + + text + + END_OF_FRAME; sendFrame(socket, message); System.out.println("Sent Stomp message: " + text); // Step 4. Send a DISCONNECT frame to disconnect from the server String disconnectFrame = "DISCONNECT\n" + - "\n" + - END_OF_FRAME; + "\n" + + END_OF_FRAME; sendFrame(socket, disconnectFrame); // Step 5. Slose the TCP socket @@ -108,8 +100,6 @@ public class StompExample extends ActiveMQExample // Step 10. Receive the message TextMessage messageReceived = (TextMessage)consumer.receive(5000); System.out.println("Received JMS message: " + messageReceived.getText()); - - return true; } finally { @@ -147,7 +137,5 @@ public class StompExample extends ActiveMQExample String frame = new String(data, "UTF-8"); return frame; - } - } diff --git a/examples/jms/stomp1.2/src/main/resources/activemq/server0/artemis-roles.properties b/examples/jms/stomp1.2/src/main/resources/activemq/server0/artemis-roles.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/stomp1.2/src/main/resources/activemq/server0/artemis-roles.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/stomp1.2/src/main/resources/activemq/server0/artemis-users.properties b/examples/jms/stomp1.2/src/main/resources/activemq/server0/artemis-users.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/stomp1.2/src/main/resources/activemq/server0/artemis-users.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/stomp1.2/src/main/resources/activemq/server0/broker.xml b/examples/jms/stomp1.2/src/main/resources/activemq/server0/broker.xml index b24f1da6bd..9688ae9824 100644 --- a/examples/jms/stomp1.2/src/main/resources/activemq/server0/broker.xml +++ b/examples/jms/stomp1.2/src/main/resources/activemq/server0/broker.xml @@ -29,13 +29,13 @@ under the License. - ${data.dir}/server0/data/messaging/bindings + ${data.dir:./data}/bindings - ${data.dir}/server0/data/messaging/journal + ${data.dir:./data}/journal - ${data.dir}/server0/data/messaging/largemessages + ${data.dir:./data}/largemessages - ${data.dir}/server0/data/messaging/paging + ${data.dir:./data}/paging diff --git a/examples/jms/stop-server-failover/pom.xml b/examples/jms/stop-server-failover/pom.xml index e1ebe90313..2ba5e695c6 100644 --- a/examples/jms/stop-server-failover/pom.xml +++ b/examples/jms/stop-server-failover/pom.xml @@ -36,11 +36,6 @@ under the License. - - org.apache.activemq.examples.jms - common - ${project.version} - org.apache.geronimo.specs geronimo-jms_2.0_spec @@ -57,25 +52,59 @@ under the License. artemis-maven-plugin - create + create0 create ${basedir}/target/server0 - ${basedir}/target/classes/activemq/server0 - -Dudp-address=${udp-address} + true + false + ../data + true - create2 + create1 create ${basedir}/target/server1 - ${basedir}/target/classes/activemq/server1 - -Dudp-address=${udp-address} + true + true + ../data + true + + + + start0 + + cli + + + true + ${basedir}/target/server0 + tcp://localhost:61616 + + run + + server0 + + + + start1 + + cli + + + true + ${basedir}/target/server1 + tcp://localhost:61617 + + run + + server1 @@ -85,9 +114,29 @@ under the License. org.apache.activemq.artemis.jms.example.StopServerFailoverExample + + + + stop0 + + cli + + + ${basedir}/target/server0 - ${basedir}/target/server0 - ${basedir}/target/server1 + stop + + + + + stop1 + + cli + + + ${basedir}/target/server1 + + stop diff --git a/examples/jms/stop-server-failover/src/main/java/org/apache/activemq/artemis/jms/example/StopServerFailoverExample.java b/examples/jms/stop-server-failover/src/main/java/org/apache/activemq/artemis/jms/example/StopServerFailoverExample.java index 7f170f6532..01ee51bd66 100644 --- a/examples/jms/stop-server-failover/src/main/java/org/apache/activemq/artemis/jms/example/StopServerFailoverExample.java +++ b/examples/jms/stop-server-failover/src/main/java/org/apache/activemq/artemis/jms/example/StopServerFailoverExample.java @@ -16,8 +16,6 @@ */ package org.apache.activemq.artemis.jms.example; -import org.apache.activemq.artemis.common.example.ActiveMQExample; - import javax.jms.Connection; import javax.jms.ConnectionFactory; import javax.jms.JMSException; @@ -32,15 +30,9 @@ import javax.naming.InitialContext; * A simple example that demonstrates failover of the JMS connection from one node to another * when the live server crashes using a JMS non-transacted session. */ -public class StopServerFailoverExample extends ActiveMQExample +public class StopServerFailoverExample { - public static void main(final String[] args) - { - new StopServerFailoverExample().run(args); - } - - @Override - public boolean runExample() throws Exception + public static void main(final String[] args) throws Exception { final int numMessages = 10; @@ -94,10 +86,9 @@ public class StopServerFailoverExample extends ActiveMQExample System.out.println("Got message: " + message0.getText()); } - // Step 10. Crash server #1, the live server, and wait a little while to make sure + // Step 10. Crash server #0, the live server, and wait a little while to make sure // it has really crashed - Thread.sleep(5000); - System.out.println("stop the server by logging into jconsole"); + System.out.println("Stop the live server by logging into JConsole and then press any key to continue..."); System.in.read(); // Step 11. Acknowledging the 2nd half of the sent messages will fail as failover to the @@ -118,8 +109,6 @@ public class StopServerFailoverExample extends ActiveMQExample System.out.printf("Got message: %s (redelivered?: %s)\n", message0.getText(), message0.getJMSRedelivered()); } message0.acknowledge(); - - return true; } finally { @@ -136,5 +125,4 @@ public class StopServerFailoverExample extends ActiveMQExample } } } - } diff --git a/examples/jms/stop-server-failover/src/main/resources/activemq/server0/artemis-roles.properties b/examples/jms/stop-server-failover/src/main/resources/activemq/server0/artemis-roles.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/stop-server-failover/src/main/resources/activemq/server0/artemis-roles.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/stop-server-failover/src/main/resources/activemq/server0/artemis-users.properties b/examples/jms/stop-server-failover/src/main/resources/activemq/server0/artemis-users.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/stop-server-failover/src/main/resources/activemq/server0/artemis-users.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/stop-server-failover/src/main/resources/activemq/server0/broker.xml b/examples/jms/stop-server-failover/src/main/resources/activemq/server0/broker.xml deleted file mode 100644 index 6ea24c1a8d..0000000000 --- a/examples/jms/stop-server-failover/src/main/resources/activemq/server0/broker.xml +++ /dev/null @@ -1,94 +0,0 @@ - - - - - - - - - - - - - ${data.dir}/server0/data/messaging/bindings - - ${data.dir}/server0/data/messaging/journal - - ${data.dir}/server0/data/messaging/largemessages - - ${data.dir}/server0/data/messaging/paging - - - - - - - - - - tcp://localhost:61616 - - - - - tcp://localhost:61616 - - - - - ${udp-address:231.7.7.7} - 9876 - 1000 - netty-connector - - - - - - ${udp-address:231.7.7.7} - 9876 - 60000 - - - - - -

    jms
    - netty-connector - - - - - - - - - - - - - - - - - - diff --git a/examples/jms/stop-server-failover/src/main/resources/activemq/server1/artemis-roles.properties b/examples/jms/stop-server-failover/src/main/resources/activemq/server1/artemis-roles.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/stop-server-failover/src/main/resources/activemq/server1/artemis-roles.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/stop-server-failover/src/main/resources/activemq/server1/artemis-users.properties b/examples/jms/stop-server-failover/src/main/resources/activemq/server1/artemis-users.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/stop-server-failover/src/main/resources/activemq/server1/artemis-users.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/stop-server-failover/src/main/resources/activemq/server1/broker.xml b/examples/jms/stop-server-failover/src/main/resources/activemq/server1/broker.xml deleted file mode 100644 index da69fce8d3..0000000000 --- a/examples/jms/stop-server-failover/src/main/resources/activemq/server1/broker.xml +++ /dev/null @@ -1,94 +0,0 @@ - - - - - - - - - - - - - ${data.dir}/server0/data/messaging/bindings - - ${data.dir}/server0/data/messaging/journal - - ${data.dir}/server0/data/messaging/largemessages - - ${data.dir}/server0/data/messaging/paging - - - - - - - - - - tcp://localhost:61617 - - - - - tcp://localhost:61617 - - - - - ${udp-address:231.7.7.7} - 9876 - 1000 - netty-connector - - - - - - ${udp-address:231.7.7.7} - 9876 - 60000 - - - - - -
    jms
    - netty-connector - -
    -
    - - - - - - - - - - - - - -
    -
    diff --git a/examples/jms/symmetric-cluster/pom.xml b/examples/jms/symmetric-cluster/pom.xml index a7d35f7a2d..d6ed18946c 100644 --- a/examples/jms/symmetric-cluster/pom.xml +++ b/examples/jms/symmetric-cluster/pom.xml @@ -37,8 +37,8 @@ under the License. - org.apache.activemq.examples.jms - common + org.apache.activemq + artemis-jms-client ${project.version} @@ -57,7 +57,7 @@ under the License. artemis-maven-plugin - create + create0 create @@ -122,7 +122,96 @@ under the License. -Dudp-address=${udp-address} - + + start0 + + cli + + + true + ${basedir}/target/server0 + tcp://localhost:61616 + + run + + server0 + + + + start1 + + cli + + + true + ${basedir}/target/server1 + tcp://localhost:61617 + + run + + server1 + + + + start2 + + cli + + + true + ${basedir}/target/server2 + tcp://localhost:61618 + + run + + server2 + + + + start3 + + cli + + + true + ${basedir}/target/server3 + tcp://localhost:61619 + + run + + server3 + + + + start4 + + cli + + + true + ${basedir}/target/server4 + tcp://localhost:61620 + + run + + server4 + + + + start5 + + cli + + + true + ${basedir}/target/server5 + tcp://localhost:61621 + + run + + server5 + + runClient @@ -130,13 +219,77 @@ under the License. org.apache.activemq.artemis.jms.example.SymmetricClusterExample + + + + stop0 + + cli + + + ${basedir}/target/server0 - ${basedir}/target/server0 - ${basedir}/target/server1 - ${basedir}/target/server2 - ${basedir}/target/server3 - ${basedir}/target/server4 - ${basedir}/target/server5 + stop + + + + + stop1 + + cli + + + ${basedir}/target/server1 + + stop + + + + + stop2 + + cli + + + ${basedir}/target/server2 + + stop + + + + + stop3 + + cli + + + ${basedir}/target/server3 + + stop + + + + + stop4 + + cli + + + ${basedir}/target/server4 + + stop + + + + + stop5 + + cli + + + ${basedir}/target/server5 + + stop diff --git a/examples/jms/symmetric-cluster/src/main/java/org/apache/activemq/artemis/jms/example/SymmetricClusterExample.java b/examples/jms/symmetric-cluster/src/main/java/org/apache/activemq/artemis/jms/example/SymmetricClusterExample.java index 24e75f0534..e332f04607 100644 --- a/examples/jms/symmetric-cluster/src/main/java/org/apache/activemq/artemis/jms/example/SymmetricClusterExample.java +++ b/examples/jms/symmetric-cluster/src/main/java/org/apache/activemq/artemis/jms/example/SymmetricClusterExample.java @@ -29,7 +29,6 @@ import org.apache.activemq.artemis.api.core.DiscoveryGroupConfiguration; import org.apache.activemq.artemis.api.core.UDPBroadcastEndpointFactory; import org.apache.activemq.artemis.api.jms.ActiveMQJMSClient; import org.apache.activemq.artemis.api.jms.JMSFactoryType; -import org.apache.activemq.artemis.common.example.ActiveMQExample; /** * This example demonstrates a cluster of three nodes set up in a symmetric topology - i.e. each @@ -48,15 +47,9 @@ import org.apache.activemq.artemis.common.example.ActiveMQExample; *

    * Please see the readme.html file for more information. */ -public class SymmetricClusterExample extends ActiveMQExample +public class SymmetricClusterExample { - public static void main(final String[] args) - { - new SymmetricClusterExample().run(args); - } - - @Override - public boolean runExample() throws Exception + public static void main(final String[] args) throws Exception { Connection connection0 = null; @@ -180,53 +173,51 @@ public class SymmetricClusterExample extends ActiveMQExample if (received0 == null) { - return false; + throw new IllegalStateException("Message is null!"); } TextMessage received1 = (TextMessage)subscriber1.receive(5000); if (received1 == null) { - return false; + throw new IllegalStateException("Message is null!"); } TextMessage received2 = (TextMessage)subscriber2.receive(5000); if (received2 == null) { - return false; + throw new IllegalStateException("Message is null!"); } TextMessage received3 = (TextMessage)subscriber3.receive(5000); if (received3 == null) { - return false; + throw new IllegalStateException("Message is null!"); } TextMessage received4 = (TextMessage)subscriber4.receive(5000); if (received4 == null) { - return false; + throw new IllegalStateException("Message is null!"); } TextMessage received5 = (TextMessage)subscriber5.receive(5000); if (received5 == null) { - return false; + throw new IllegalStateException("Message is null!"); } TextMessage received6 = (TextMessage)consumer0.receive(5000); if (received6 == null) { - return false; + throw new IllegalStateException("Message is null!"); } } - - return true; } finally { diff --git a/examples/jms/symmetric-cluster/src/main/resources/activemq/server0/artemis-roles.properties b/examples/jms/symmetric-cluster/src/main/resources/activemq/server0/artemis-roles.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/symmetric-cluster/src/main/resources/activemq/server0/artemis-roles.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/symmetric-cluster/src/main/resources/activemq/server0/artemis-users.properties b/examples/jms/symmetric-cluster/src/main/resources/activemq/server0/artemis-users.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/symmetric-cluster/src/main/resources/activemq/server0/artemis-users.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/symmetric-cluster/src/main/resources/activemq/server0/broker.xml b/examples/jms/symmetric-cluster/src/main/resources/activemq/server0/broker.xml index 27b74894a9..9c672d7cb5 100644 --- a/examples/jms/symmetric-cluster/src/main/resources/activemq/server0/broker.xml +++ b/examples/jms/symmetric-cluster/src/main/resources/activemq/server0/broker.xml @@ -30,14 +30,13 @@ under the License. + ${data.dir:./data}/bindings - ${data.dir}/server0/data/messaging/bindings + ${data.dir:./data}/journal - ${data.dir}/server0/data/messaging/journal + ${data.dir:./data}/largemessages - ${data.dir}/server0/data/messaging/largemessages - - ${data.dir}/server0/data/messaging/paging + ${data.dir:./data}/paging diff --git a/examples/jms/symmetric-cluster/src/main/resources/activemq/server1/artemis-roles.properties b/examples/jms/symmetric-cluster/src/main/resources/activemq/server1/artemis-roles.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/symmetric-cluster/src/main/resources/activemq/server1/artemis-roles.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/symmetric-cluster/src/main/resources/activemq/server1/artemis-users.properties b/examples/jms/symmetric-cluster/src/main/resources/activemq/server1/artemis-users.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/symmetric-cluster/src/main/resources/activemq/server1/artemis-users.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/symmetric-cluster/src/main/resources/activemq/server1/broker.xml b/examples/jms/symmetric-cluster/src/main/resources/activemq/server1/broker.xml index 16a7931959..f02759badf 100644 --- a/examples/jms/symmetric-cluster/src/main/resources/activemq/server1/broker.xml +++ b/examples/jms/symmetric-cluster/src/main/resources/activemq/server1/broker.xml @@ -30,14 +30,13 @@ under the License. + ${data.dir:./data}/bindings - ${data.dir}/server1/data/messaging/bindings + ${data.dir:./data}/journal - ${data.dir}/server1/data/messaging/journal + ${data.dir:./data}/largemessages - ${data.dir}/server1/data/messaging/largemessages - - ${data.dir}/server1/data/messaging/paging + ${data.dir:./data}/paging diff --git a/examples/jms/symmetric-cluster/src/main/resources/activemq/server2/artemis-roles.properties b/examples/jms/symmetric-cluster/src/main/resources/activemq/server2/artemis-roles.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/symmetric-cluster/src/main/resources/activemq/server2/artemis-roles.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/symmetric-cluster/src/main/resources/activemq/server2/artemis-users.properties b/examples/jms/symmetric-cluster/src/main/resources/activemq/server2/artemis-users.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/symmetric-cluster/src/main/resources/activemq/server2/artemis-users.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/symmetric-cluster/src/main/resources/activemq/server2/broker.xml b/examples/jms/symmetric-cluster/src/main/resources/activemq/server2/broker.xml index 30f33a0ae5..a188e71827 100644 --- a/examples/jms/symmetric-cluster/src/main/resources/activemq/server2/broker.xml +++ b/examples/jms/symmetric-cluster/src/main/resources/activemq/server2/broker.xml @@ -30,14 +30,13 @@ under the License. + ${data.dir:./data}/bindings - ${data.dir}/server2/data/messaging/bindings + ${data.dir:./data}/journal - ${data.dir}/server2/data/messaging/journal + ${data.dir:./data}/largemessages - ${data.dir}/server2/data/messaging/largemessages - - ${data.dir}/server2/data/messaging/paging + ${data.dir:./data}/paging diff --git a/examples/jms/symmetric-cluster/src/main/resources/activemq/server3/artemis-roles.properties b/examples/jms/symmetric-cluster/src/main/resources/activemq/server3/artemis-roles.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/symmetric-cluster/src/main/resources/activemq/server3/artemis-roles.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/symmetric-cluster/src/main/resources/activemq/server3/artemis-users.properties b/examples/jms/symmetric-cluster/src/main/resources/activemq/server3/artemis-users.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/symmetric-cluster/src/main/resources/activemq/server3/artemis-users.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/symmetric-cluster/src/main/resources/activemq/server3/broker.xml b/examples/jms/symmetric-cluster/src/main/resources/activemq/server3/broker.xml index afda21b6ca..43ab47c64f 100644 --- a/examples/jms/symmetric-cluster/src/main/resources/activemq/server3/broker.xml +++ b/examples/jms/symmetric-cluster/src/main/resources/activemq/server3/broker.xml @@ -30,14 +30,13 @@ under the License. + ${data.dir:./data}/bindings - ${data.dir}/server3/data/messaging/bindings + ${data.dir:./data}/journal - ${data.dir}/server3/data/messaging/journal + ${data.dir:./data}/largemessages - ${data.dir}/server3/data/messaging/largemessages - - ${data.dir}/server3/data/messaging/paging + ${data.dir:./data}/paging diff --git a/examples/jms/symmetric-cluster/src/main/resources/activemq/server4/artemis-roles.properties b/examples/jms/symmetric-cluster/src/main/resources/activemq/server4/artemis-roles.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/symmetric-cluster/src/main/resources/activemq/server4/artemis-roles.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/symmetric-cluster/src/main/resources/activemq/server4/artemis-users.properties b/examples/jms/symmetric-cluster/src/main/resources/activemq/server4/artemis-users.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/symmetric-cluster/src/main/resources/activemq/server4/artemis-users.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/symmetric-cluster/src/main/resources/activemq/server4/broker.xml b/examples/jms/symmetric-cluster/src/main/resources/activemq/server4/broker.xml index 321d57bb6f..ce4afab4ac 100644 --- a/examples/jms/symmetric-cluster/src/main/resources/activemq/server4/broker.xml +++ b/examples/jms/symmetric-cluster/src/main/resources/activemq/server4/broker.xml @@ -30,14 +30,13 @@ under the License. + ${data.dir:./data}/bindings - ${data.dir}/server4/data/messaging/bindings + ${data.dir:./data}/journal - ${data.dir}/server4/data/messaging/journal + ${data.dir:./data}/largemessages - ${data.dir}/server4/data/messaging/largemessages - - ${data.dir}/server4/data/messaging/paging + ${data.dir:./data}/paging diff --git a/examples/jms/symmetric-cluster/src/main/resources/activemq/server5/artemis-roles.properties b/examples/jms/symmetric-cluster/src/main/resources/activemq/server5/artemis-roles.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/symmetric-cluster/src/main/resources/activemq/server5/artemis-roles.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/symmetric-cluster/src/main/resources/activemq/server5/artemis-users.properties b/examples/jms/symmetric-cluster/src/main/resources/activemq/server5/artemis-users.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/symmetric-cluster/src/main/resources/activemq/server5/artemis-users.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/symmetric-cluster/src/main/resources/activemq/server5/broker.xml b/examples/jms/symmetric-cluster/src/main/resources/activemq/server5/broker.xml index abbe9adfdc..d23612a37d 100644 --- a/examples/jms/symmetric-cluster/src/main/resources/activemq/server5/broker.xml +++ b/examples/jms/symmetric-cluster/src/main/resources/activemq/server5/broker.xml @@ -30,23 +30,22 @@ under the License. + ${data.dir:./data}/bindings - ${data.dir}/server5/data/messaging/bindings + ${data.dir:./data}/journal - ${data.dir}/server5/data/messaging/journal + ${data.dir:./data}/largemessages - ${data.dir}/server5/data/messaging/largemessages - - ${data.dir}/server5/data/messaging/paging + ${data.dir:./data}/paging - tcp://localhost:5450 + tcp://localhost:61621 - tcp://localhost:5450 + tcp://localhost:61621 diff --git a/examples/jms/temp-queue/pom.xml b/examples/jms/temp-queue/pom.xml index b21308895f..1599fcc387 100644 --- a/examples/jms/temp-queue/pom.xml +++ b/examples/jms/temp-queue/pom.xml @@ -36,11 +36,6 @@ under the License. - - org.apache.activemq.examples.jms - common - ${project.version} - org.apache.geronimo.specs geronimo-jms_2.0_spec @@ -61,9 +56,18 @@ under the License. create + + + start + + cli + - ${basedir}/target/server0 - ${basedir}/target/classes/activemq/server0 + true + tcp://localhost:61616 + + run + @@ -73,8 +77,16 @@ under the License. org.apache.activemq.artemis.jms.example.TemporaryQueueExample + + + + stop + + cli + + - ${basedir}/target/server0 + stop diff --git a/examples/jms/temp-queue/src/main/java/org/apache/activemq/artemis/jms/example/TemporaryQueueExample.java b/examples/jms/temp-queue/src/main/java/org/apache/activemq/artemis/jms/example/TemporaryQueueExample.java index cd39f7fcda..a2f7d3841d 100644 --- a/examples/jms/temp-queue/src/main/java/org/apache/activemq/artemis/jms/example/TemporaryQueueExample.java +++ b/examples/jms/temp-queue/src/main/java/org/apache/activemq/artemis/jms/example/TemporaryQueueExample.java @@ -26,20 +26,12 @@ import javax.jms.TemporaryQueue; import javax.jms.TextMessage; import javax.naming.InitialContext; -import org.apache.activemq.artemis.common.example.ActiveMQExample; - /** * A simple JMS example that shows how to use temporary queues. */ -public class TemporaryQueueExample extends ActiveMQExample +public class TemporaryQueueExample { - public static void main(final String[] args) - { - new TemporaryQueueExample().run(args); - } - - @Override - public boolean runExample() throws Exception + public static void main(final String[] args) throws Exception { Connection connection = null; InitialContext initialContext = null; @@ -115,8 +107,6 @@ public class TemporaryQueueExample extends ActiveMQExample { System.out.println("Exception got when trying to access a temp queue outside its scope: " + e); } - - return true; } finally { diff --git a/examples/jms/temp-queue/src/main/resources/activemq/server0/artemis-roles.properties b/examples/jms/temp-queue/src/main/resources/activemq/server0/artemis-roles.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/temp-queue/src/main/resources/activemq/server0/artemis-roles.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/temp-queue/src/main/resources/activemq/server0/artemis-users.properties b/examples/jms/temp-queue/src/main/resources/activemq/server0/artemis-users.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/temp-queue/src/main/resources/activemq/server0/artemis-users.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/temp-queue/src/main/resources/activemq/server0/broker.xml b/examples/jms/temp-queue/src/main/resources/activemq/server0/broker.xml index d5950867ff..f1c14b2db6 100644 --- a/examples/jms/temp-queue/src/main/resources/activemq/server0/broker.xml +++ b/examples/jms/temp-queue/src/main/resources/activemq/server0/broker.xml @@ -29,19 +29,13 @@ under the License. - ${data.dir}/server0/data/messaging/bindings + ${data.dir:./data}/bindings - ${data.dir}/server0/data/messaging/journal + ${data.dir:./data}/journal - ${data.dir}/server0/data/messaging/largemessages + ${data.dir:./data}/largemessages - ${data.dir}/server0/data/messaging/paging - - - - - tcp://localhost:61616 - + ${data.dir:./data}/paging @@ -49,8 +43,6 @@ under the License. - - @@ -69,6 +61,5 @@ under the License. - diff --git a/examples/jms/topic-hierarchies/pom.xml b/examples/jms/topic-hierarchies/pom.xml index 087570e730..250abd3aef 100644 --- a/examples/jms/topic-hierarchies/pom.xml +++ b/examples/jms/topic-hierarchies/pom.xml @@ -37,8 +37,8 @@ under the License. - org.apache.activemq.examples.jms - common + org.apache.activemq + artemis-jms-client ${project.version} @@ -61,9 +61,18 @@ under the License. create + + + start + + cli + - ${basedir}/target/server0 - ${basedir}/target/classes/activemq/server0 + true + tcp://localhost:61616 + + run + @@ -73,8 +82,16 @@ under the License. org.apache.activemq.artemis.jms.example.TopicHierarchyExample + + + + stop + + cli + + - ${basedir}/target/server0 + stop diff --git a/examples/jms/topic-hierarchies/src/main/java/org/apache/activemq/artemis/jms/example/TopicHierarchyExample.java b/examples/jms/topic-hierarchies/src/main/java/org/apache/activemq/artemis/jms/example/TopicHierarchyExample.java index 34fe27d81a..f2385baf07 100644 --- a/examples/jms/topic-hierarchies/src/main/java/org/apache/activemq/artemis/jms/example/TopicHierarchyExample.java +++ b/examples/jms/topic-hierarchies/src/main/java/org/apache/activemq/artemis/jms/example/TopicHierarchyExample.java @@ -27,22 +27,15 @@ import javax.jms.Topic; import javax.naming.InitialContext; import org.apache.activemq.artemis.api.jms.ActiveMQJMSClient; -import org.apache.activemq.artemis.common.example.ActiveMQExample; /** * This example demonstrates how a JMS TopicSubscriber can be created to subscribe to a wild-card Topic. * * For more information please see the readme.html */ -public class TopicHierarchyExample extends ActiveMQExample +public class TopicHierarchyExample { - public static void main(final String[] args) - { - new TopicHierarchyExample().run(args); - } - - @Override - public boolean runExample() throws Exception + public static void main(final String[] args) throws Exception { Connection connection = null; InitialContext initialContext = null; @@ -113,12 +106,10 @@ public class TopicHierarchyExample extends ActiveMQExample if (message != null) { - return false; + throw new IllegalStateException("Message was not null."); } System.out.println("Didn't received any more message: " + message); - - return true; } finally { @@ -133,5 +124,4 @@ public class TopicHierarchyExample extends ActiveMQExample } } } - } diff --git a/examples/jms/topic-hierarchies/src/main/resources/activemq/server0/artemis-roles.properties b/examples/jms/topic-hierarchies/src/main/resources/activemq/server0/artemis-roles.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/topic-hierarchies/src/main/resources/activemq/server0/artemis-roles.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/topic-hierarchies/src/main/resources/activemq/server0/artemis-users.properties b/examples/jms/topic-hierarchies/src/main/resources/activemq/server0/artemis-users.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/topic-hierarchies/src/main/resources/activemq/server0/artemis-users.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/topic-hierarchies/src/main/resources/activemq/server0/broker.xml b/examples/jms/topic-hierarchies/src/main/resources/activemq/server0/broker.xml index 1f94195d48..ac065f6af4 100644 --- a/examples/jms/topic-hierarchies/src/main/resources/activemq/server0/broker.xml +++ b/examples/jms/topic-hierarchies/src/main/resources/activemq/server0/broker.xml @@ -40,13 +40,13 @@ under the License. - ${data.dir}/server0/data/messaging/bindings + ${data.dir:./data}/bindings - ${data.dir}/server0/data/messaging/journal + ${data.dir:./data}/journal - ${data.dir}/server0/data/messaging/largemessages + ${data.dir:./data}/largemessages - ${data.dir}/server0/data/messaging/paging + ${data.dir:./data}/paging diff --git a/examples/jms/topic-selector-example1/pom.xml b/examples/jms/topic-selector-example1/pom.xml index 7526dd53d4..bbf95ee9a6 100644 --- a/examples/jms/topic-selector-example1/pom.xml +++ b/examples/jms/topic-selector-example1/pom.xml @@ -36,11 +36,6 @@ under the License. - - org.apache.activemq.examples.jms - common - ${project.version} - org.apache.geronimo.specs geronimo-jms_2.0_spec @@ -61,9 +56,18 @@ under the License. create + + + start + + cli + - ${basedir}/target/server0 - ${basedir}/target/classes/activemq/server0 + true + tcp://localhost:61616 + + run + @@ -73,8 +77,16 @@ under the License. org.apache.activemq.artemis.jms.example.TopicSelectorExample1 + + + + stop + + cli + + - ${basedir}/target/server0 + stop diff --git a/examples/jms/topic-selector-example1/src/main/java/org/apache/activemq/artemis/jms/example/TopicSelectorExample1.java b/examples/jms/topic-selector-example1/src/main/java/org/apache/activemq/artemis/jms/example/TopicSelectorExample1.java index 5116a76cad..28c128ed02 100644 --- a/examples/jms/topic-selector-example1/src/main/java/org/apache/activemq/artemis/jms/example/TopicSelectorExample1.java +++ b/examples/jms/topic-selector-example1/src/main/java/org/apache/activemq/artemis/jms/example/TopicSelectorExample1.java @@ -25,20 +25,12 @@ import javax.jms.TextMessage; import javax.jms.Topic; import javax.naming.InitialContext; -import org.apache.activemq.artemis.common.example.ActiveMQExample; - /** * A simple JMS Topic example that creates a producer and consumer on a queue and sends and receives a message. */ -public class TopicSelectorExample1 extends ActiveMQExample +public class TopicSelectorExample1 { - public static void main(final String[] args) - { - new TopicSelectorExample1().run(args); - } - - @Override - public boolean runExample() throws Exception + public static void main(final String[] args) throws Exception { Connection connection = null; @@ -81,8 +73,8 @@ public class TopicSelectorExample1 extends ActiveMQExample { // Step 10.1 Create a text message TextMessage message1 = session.createTextMessage("This is a text message " + i + - " sent for someID=" + - someID); + " sent for someID=" + + someID); // Step 10.1 Set a property message1.setIntProperty("someID", someID); @@ -110,8 +102,8 @@ public class TopicSelectorExample1 extends ActiveMQExample } System.out.println("messageConsumer1 received " + messageReceivedA.getText() + - " someID = " + - messageReceivedA.getIntProperty("someID")); + " someID = " + + messageReceivedA.getIntProperty("someID")); } // Step 13. Consume the messages from MessageConsumer2, filtering out someID=2 @@ -126,8 +118,8 @@ public class TopicSelectorExample1 extends ActiveMQExample } System.out.println("messageConsumer2 received " + messageReceivedB.getText() + - " someID = " + - messageReceivedB.getIntProperty("someID")); + " someID = " + + messageReceivedB.getIntProperty("someID")); } // Step 14. Consume the messages from MessageConsumer3, receiving the complete set of messages @@ -141,17 +133,14 @@ public class TopicSelectorExample1 extends ActiveMQExample break; } System.out.println("messageConsumer3 received " + messageReceivedC.getText() + - " someID = " + - messageReceivedC.getIntProperty("someID")); + " someID = " + + messageReceivedC.getIntProperty("someID")); } // Step 15. Close the subscribers messageConsumer1.close(); messageConsumer2.close(); messageConsumer3.close(); - - return true; - } finally { diff --git a/examples/jms/topic-selector-example1/src/main/resources/activemq/server0/artemis-roles.properties b/examples/jms/topic-selector-example1/src/main/resources/activemq/server0/artemis-roles.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/topic-selector-example1/src/main/resources/activemq/server0/artemis-roles.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/topic-selector-example1/src/main/resources/activemq/server0/artemis-users.properties b/examples/jms/topic-selector-example1/src/main/resources/activemq/server0/artemis-users.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/topic-selector-example1/src/main/resources/activemq/server0/artemis-users.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/topic-selector-example1/src/main/resources/activemq/server0/broker.xml b/examples/jms/topic-selector-example1/src/main/resources/activemq/server0/broker.xml index e7c1a14cbd..4a4b5056cf 100644 --- a/examples/jms/topic-selector-example1/src/main/resources/activemq/server0/broker.xml +++ b/examples/jms/topic-selector-example1/src/main/resources/activemq/server0/broker.xml @@ -29,13 +29,13 @@ under the License. - ${data.dir}/server0/data/messaging/bindings + ${data.dir:./data}/bindings - ${data.dir}/server0/data/messaging/journal + ${data.dir:./data}/journal - ${data.dir}/server0/data/messaging/largemessages + ${data.dir:./data}/largemessages - ${data.dir}/server0/data/messaging/paging + ${data.dir:./data}/paging diff --git a/examples/jms/topic-selector-example2/pom.xml b/examples/jms/topic-selector-example2/pom.xml index 320d13ce61..b9f5332de0 100644 --- a/examples/jms/topic-selector-example2/pom.xml +++ b/examples/jms/topic-selector-example2/pom.xml @@ -36,11 +36,6 @@ under the License. - - org.apache.activemq.examples.jms - common - ${project.version} - org.apache.geronimo.specs geronimo-jms_2.0_spec @@ -61,9 +56,18 @@ under the License. create + + + start + + cli + - ${basedir}/target/server0 - ${basedir}/target/classes/activemq/server0 + true + tcp://localhost:61616 + + run + @@ -73,8 +77,16 @@ under the License. org.apache.activemq.artemis.jms.example.TopicSelectorExample2 + + + + stop + + cli + + - ${basedir}/target/server0 + stop diff --git a/examples/jms/topic-selector-example2/src/main/java/org/apache/activemq/artemis/jms/example/TopicSelectorExample2.java b/examples/jms/topic-selector-example2/src/main/java/org/apache/activemq/artemis/jms/example/TopicSelectorExample2.java index 301b752cec..e80d22d99b 100644 --- a/examples/jms/topic-selector-example2/src/main/java/org/apache/activemq/artemis/jms/example/TopicSelectorExample2.java +++ b/examples/jms/topic-selector-example2/src/main/java/org/apache/activemq/artemis/jms/example/TopicSelectorExample2.java @@ -27,24 +27,16 @@ import javax.jms.Session; import javax.jms.TextMessage; import javax.jms.Topic; import javax.naming.InitialContext; - -import org.apache.activemq.artemis.common.example.ActiveMQExample; +import java.util.concurrent.atomic.AtomicBoolean; /** * A simple JMS example that consumes messages using selectors. */ -public class TopicSelectorExample2 extends ActiveMQExample +public class TopicSelectorExample2 { - private volatile boolean result = true; - - public static void main(final String[] args) - { - new TopicSelectorExample2().run(args); - } - - @Override - public boolean runExample() throws Exception + public static void main(final String[] args) throws Exception { + AtomicBoolean result = new AtomicBoolean(true); Connection connection = null; InitialContext initialContext = null; try @@ -65,33 +57,36 @@ public class TopicSelectorExample2 extends ActiveMQExample connection.start(); // Step 6. Create a JMS Session - Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); + Session producerSession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); // Step 7. Create a Message Producer - MessageProducer producer = session.createProducer(topic); + MessageProducer producer = producerSession.createProducer(topic); // Step 8. Prepare two selectors String redSelector = "color='red'"; String greenSelector = "color='green'"; // Step 9. Create a JMS Message Consumer that receives 'red' messages - MessageConsumer redConsumer = session.createConsumer(topic, redSelector); - redConsumer.setMessageListener(new SimpleMessageListener("red")); + Session redSession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); + MessageConsumer redConsumer = redSession.createConsumer(topic, redSelector); + redConsumer.setMessageListener(new SimpleMessageListener("red", result)); // Step 10. Create a second JMS message consumer that receives 'green' messages - MessageConsumer greenConsumer = session.createConsumer(topic, greenSelector); - greenConsumer.setMessageListener(new SimpleMessageListener("green")); + Session greenSession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); + MessageConsumer greenConsumer = greenSession.createConsumer(topic, greenSelector); + greenConsumer.setMessageListener(new SimpleMessageListener("green", result)); // Step 11. Create another JMS message consumer that receives all messages. - MessageConsumer allConsumer = session.createConsumer(topic); - allConsumer.setMessageListener(new SimpleMessageListener("all")); + Session allSession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); + MessageConsumer allConsumer = allSession.createConsumer(topic); + allConsumer.setMessageListener(new SimpleMessageListener("all", result)); // Step 12. Create three messages, each has a color property - TextMessage redMessage = session.createTextMessage("Red"); + TextMessage redMessage = producerSession.createTextMessage("Red"); redMessage.setStringProperty("color", "red"); - TextMessage greenMessage = session.createTextMessage("Green"); + TextMessage greenMessage = producerSession.createTextMessage("Green"); greenMessage.setStringProperty("color", "green"); - TextMessage blueMessage = session.createTextMessage("Blue"); + TextMessage blueMessage = producerSession.createTextMessage("Blue"); blueMessage.setStringProperty("color", "blue"); // Step 13. Send the Messages @@ -104,7 +99,8 @@ public class TopicSelectorExample2 extends ActiveMQExample Thread.sleep(5000); - return result; + if (!result.get()) + throw new IllegalStateException(); } finally { @@ -121,39 +117,39 @@ public class TopicSelectorExample2 extends ActiveMQExample } } } - - public class SimpleMessageListener implements MessageListener - { - - private final String name; - - public SimpleMessageListener(final String listener) - { - name = listener; - } - - public void onMessage(final Message msg) - { - TextMessage textMessage = (TextMessage)msg; - try - { - String colorProp = msg.getStringProperty("color"); - System.out.println("Receiver " + name + - " receives message [" + - textMessage.getText() + - "] with color property: " + - colorProp); - if (!colorProp.equals(name) && !name.equals("all")) - { - result = false; - } - } - catch (JMSException e) - { - e.printStackTrace(); - result = false; - } - } - - } } + +class SimpleMessageListener implements MessageListener +{ + private final String name; + AtomicBoolean result; + + public SimpleMessageListener(final String listener, AtomicBoolean result) + { + name = listener; + this.result = result; + } + + public void onMessage(final Message msg) + { + TextMessage textMessage = (TextMessage)msg; + try + { + String colorProp = msg.getStringProperty("color"); + System.out.println("Receiver " + name + + " receives message [" + + textMessage.getText() + + "] with color property: " + + colorProp); + if (!colorProp.equals(name) && !name.equals("all")) + { + result.set(false); + } + } + catch (JMSException e) + { + e.printStackTrace(); + result.set(false); + } + } +} \ No newline at end of file diff --git a/examples/jms/topic-selector-example2/src/main/resources/activemq/server0/artemis-roles.properties b/examples/jms/topic-selector-example2/src/main/resources/activemq/server0/artemis-roles.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/topic-selector-example2/src/main/resources/activemq/server0/artemis-roles.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/topic-selector-example2/src/main/resources/activemq/server0/artemis-users.properties b/examples/jms/topic-selector-example2/src/main/resources/activemq/server0/artemis-users.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/topic-selector-example2/src/main/resources/activemq/server0/artemis-users.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/topic-selector-example2/src/main/resources/activemq/server0/broker.xml b/examples/jms/topic-selector-example2/src/main/resources/activemq/server0/broker.xml index e7c1a14cbd..4a4b5056cf 100644 --- a/examples/jms/topic-selector-example2/src/main/resources/activemq/server0/broker.xml +++ b/examples/jms/topic-selector-example2/src/main/resources/activemq/server0/broker.xml @@ -29,13 +29,13 @@ under the License. - ${data.dir}/server0/data/messaging/bindings + ${data.dir:./data}/bindings - ${data.dir}/server0/data/messaging/journal + ${data.dir:./data}/journal - ${data.dir}/server0/data/messaging/largemessages + ${data.dir:./data}/largemessages - ${data.dir}/server0/data/messaging/paging + ${data.dir:./data}/paging diff --git a/examples/jms/topic/pom.xml b/examples/jms/topic/pom.xml index 0fe39ff25a..2c6a91a091 100644 --- a/examples/jms/topic/pom.xml +++ b/examples/jms/topic/pom.xml @@ -36,11 +36,6 @@ under the License. - - org.apache.activemq.examples.jms - common - ${project.version} - org.apache.geronimo.specs geronimo-jms_2.0_spec @@ -60,9 +55,18 @@ under the License. create + + + start + + cli + - ${basedir}/target/server0 - ${basedir}/target/classes/activemq/server0 + true + tcp://localhost:61616 + + run + @@ -72,8 +76,16 @@ under the License. org.apache.activemq.artemis.jms.example.TopicExample + + + + stop + + cli + + - ${basedir}/target/server0 + stop @@ -90,5 +102,4 @@ under the License. - diff --git a/examples/jms/topic/src/main/java/org/apache/activemq/artemis/jms/example/TopicExample.java b/examples/jms/topic/src/main/java/org/apache/activemq/artemis/jms/example/TopicExample.java index 0564525e44..08ca057b8e 100644 --- a/examples/jms/topic/src/main/java/org/apache/activemq/artemis/jms/example/TopicExample.java +++ b/examples/jms/topic/src/main/java/org/apache/activemq/artemis/jms/example/TopicExample.java @@ -25,20 +25,12 @@ import javax.jms.TextMessage; import javax.jms.Topic; import javax.naming.InitialContext; -import org.apache.activemq.artemis.common.example.ActiveMQExample; - /** * A simple JMS Topic example that creates a producer and consumer on a queue and sends and receives a message. */ -public class TopicExample extends ActiveMQExample +public class TopicExample { - public static void main(final String[] args) - { - new TopicExample().run(args); - } - - @Override - public boolean runExample() throws Exception + public static void main(final String[] args) throws Exception { Connection connection = null; InitialContext initialContext = null; @@ -88,8 +80,6 @@ public class TopicExample extends ActiveMQExample messageReceived = (TextMessage)messageConsumer2.receive(); System.out.println("Consumer 2 Received message: " + messageReceived.getText()); - - return true; } finally { diff --git a/examples/jms/topic/src/main/resources/activemq/server0/artemis-roles.properties b/examples/jms/topic/src/main/resources/activemq/server0/artemis-roles.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/topic/src/main/resources/activemq/server0/artemis-roles.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/topic/src/main/resources/activemq/server0/artemis-users.properties b/examples/jms/topic/src/main/resources/activemq/server0/artemis-users.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/topic/src/main/resources/activemq/server0/artemis-users.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/topic/src/main/resources/activemq/server0/broker.xml b/examples/jms/topic/src/main/resources/activemq/server0/broker.xml index e7c1a14cbd..f379d5533c 100644 --- a/examples/jms/topic/src/main/resources/activemq/server0/broker.xml +++ b/examples/jms/topic/src/main/resources/activemq/server0/broker.xml @@ -29,13 +29,13 @@ under the License. - ${data.dir}/server0/data/messaging/bindings + ${data.dir:./data}/bindings - ${data.dir}/server0/data/messaging/journal + ${data.dir:./data}/journal - ${data.dir}/server0/data/messaging/largemessages + ${data.dir:./data}/largemessages - ${data.dir}/server0/data/messaging/paging + ${data.dir:./data}/paging @@ -43,7 +43,6 @@ under the License. - diff --git a/examples/jms/transaction-failover/pom.xml b/examples/jms/transaction-failover/pom.xml index f9544780f5..0fe0ec87cd 100644 --- a/examples/jms/transaction-failover/pom.xml +++ b/examples/jms/transaction-failover/pom.xml @@ -37,8 +37,8 @@ under the License. - org.apache.activemq.examples.jms - common + org.apache.activemq + artemis-cli ${project.version} @@ -57,7 +57,7 @@ under the License. artemis-maven-plugin - create + create0 create @@ -68,7 +68,7 @@ under the License. - create2 + create1 create diff --git a/examples/jms/transaction-failover/src/main/java/org/apache/activemq/artemis/jms/example/TransactionFailoverExample.java b/examples/jms/transaction-failover/src/main/java/org/apache/activemq/artemis/jms/example/TransactionFailoverExample.java index 49986496cd..119bdf8f98 100644 --- a/examples/jms/transaction-failover/src/main/java/org/apache/activemq/artemis/jms/example/TransactionFailoverExample.java +++ b/examples/jms/transaction-failover/src/main/java/org/apache/activemq/artemis/jms/example/TransactionFailoverExample.java @@ -16,6 +16,9 @@ */ package org.apache.activemq.artemis.jms.example; +import org.apache.activemq.artemis.api.core.Message; +import org.apache.activemq.artemis.util.ServerUtil; + import javax.jms.Connection; import javax.jms.ConnectionFactory; import javax.jms.MessageConsumer; @@ -26,30 +29,23 @@ import javax.jms.TextMessage; import javax.jms.TransactionRolledBackException; import javax.naming.InitialContext; -import org.apache.activemq.artemis.api.core.Message; -import org.apache.activemq.artemis.common.example.ActiveMQExample; - /** * A simple example that demonstrates failover of the JMS connection from one node to another * when the live server crashes using a JMS transacted session. */ -public class TransactionFailoverExample extends ActiveMQExample +public class TransactionFailoverExample { - - public static void main(final String[] args) - { - new TransactionFailoverExample().run(args); - } - // You need to guarantee uniqueIDs when using duplicate detection // It needs to be unique even after a restart // as these IDs are stored on the journal for control // We recommend some sort of UUID, but for this example the Current Time as string would be enough - String uniqueID = Long.toString(System.currentTimeMillis()); + static String uniqueID = Long.toString(System.currentTimeMillis()); + private static Process server0; - @Override - public boolean runExample() throws Exception + private static Process server1; + + public static void main(final String[] args) throws Exception { final int numMessages = 10; @@ -59,6 +55,9 @@ public class TransactionFailoverExample extends ActiveMQExample try { + server0 = ServerUtil.startServer(args[0], TransactionFailoverExample.class.getSimpleName() + "0", 0, 5000); + server1 = ServerUtil.startServer(args[1], TransactionFailoverExample.class.getSimpleName() + "1", 1, 5000); + // Step 1. Get an initial context for looking up JNDI from the server #1 initialContext = new InitialContext(); @@ -109,9 +108,7 @@ public class TransactionFailoverExample extends ActiveMQExample if (message0 == null) { - System.err.println("Example failed - message wasn't received"); - - return false; + throw new IllegalStateException("Example failed - message wasn't received"); } System.out.println("Got message: " + message0.getText()); @@ -120,8 +117,6 @@ public class TransactionFailoverExample extends ActiveMQExample session.commit(); System.out.println("Other message on the server? " + consumer.receive(5000)); - - return true; } finally { @@ -136,10 +131,13 @@ public class TransactionFailoverExample extends ActiveMQExample { initialContext.close(); } + + ServerUtil.killServer(server0); + ServerUtil.killServer(server1); } } - private void sendMessages(final Session session, + private static void sendMessages(final Session session, final MessageProducer producer, final int numMessages, final boolean killServer) throws Exception @@ -161,8 +159,7 @@ public class TransactionFailoverExample extends ActiveMQExample { Thread.sleep(5000); - killServer(0); - + ServerUtil.killServer(server0); } // We send the remaining half of messages @@ -180,5 +177,4 @@ public class TransactionFailoverExample extends ActiveMQExample System.out.println("Sent message: " + message.getText()); } } - } diff --git a/examples/jms/transaction-failover/src/main/resources/activemq/server0/artemis-roles.properties b/examples/jms/transaction-failover/src/main/resources/activemq/server0/artemis-roles.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/transaction-failover/src/main/resources/activemq/server0/artemis-roles.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/transaction-failover/src/main/resources/activemq/server0/artemis-users.properties b/examples/jms/transaction-failover/src/main/resources/activemq/server0/artemis-users.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/transaction-failover/src/main/resources/activemq/server0/artemis-users.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/transaction-failover/src/main/resources/activemq/server0/broker.xml b/examples/jms/transaction-failover/src/main/resources/activemq/server0/broker.xml index 74a66d4cb5..916fdf5903 100644 --- a/examples/jms/transaction-failover/src/main/resources/activemq/server0/broker.xml +++ b/examples/jms/transaction-failover/src/main/resources/activemq/server0/broker.xml @@ -29,17 +29,19 @@ under the License. - ../../data/messaging/bindings + ../data/bindings - ../../data/messaging/journal + ../data/journal - ../../data/messaging/largemessages + ../data/largemessages - ../../data/messaging/paging + ../data/paging - + + true + diff --git a/examples/jms/transaction-failover/src/main/resources/activemq/server1/artemis-roles.properties b/examples/jms/transaction-failover/src/main/resources/activemq/server1/artemis-roles.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/transaction-failover/src/main/resources/activemq/server1/artemis-roles.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/transaction-failover/src/main/resources/activemq/server1/artemis-users.properties b/examples/jms/transaction-failover/src/main/resources/activemq/server1/artemis-users.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/transaction-failover/src/main/resources/activemq/server1/artemis-users.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/transaction-failover/src/main/resources/activemq/server1/broker.xml b/examples/jms/transaction-failover/src/main/resources/activemq/server1/broker.xml index 62e5154432..055f04a71d 100644 --- a/examples/jms/transaction-failover/src/main/resources/activemq/server1/broker.xml +++ b/examples/jms/transaction-failover/src/main/resources/activemq/server1/broker.xml @@ -29,17 +29,19 @@ under the License. - ../../data/messaging/bindings + ../data/bindings - ../../data/messaging/journal + ../data/journal - ../../data/messaging/largemessages + ../data/largemessages - ../../data/messaging/paging + ../data/paging - + + true + diff --git a/examples/jms/transactional/pom.xml b/examples/jms/transactional/pom.xml index 7461ed67d8..902912495f 100644 --- a/examples/jms/transactional/pom.xml +++ b/examples/jms/transactional/pom.xml @@ -36,11 +36,6 @@ under the License. - - org.apache.activemq.examples.jms - common - ${project.version} - org.apache.geronimo.specs geronimo-jms_2.0_spec @@ -61,9 +56,18 @@ under the License. create + + + start + + cli + - ${basedir}/target/server0 - ${basedir}/target/classes/activemq/server0 + true + tcp://localhost:61616 + + run + @@ -73,8 +77,16 @@ under the License. org.apache.activemq.artemis.jms.example.TransactionalExample + + + + stop + + cli + + - ${basedir}/target/server0 + stop diff --git a/examples/jms/transactional/src/main/java/org/apache/activemq/artemis/jms/example/TransactionalExample.java b/examples/jms/transactional/src/main/java/org/apache/activemq/artemis/jms/example/TransactionalExample.java index 56b21f5336..794b76f394 100644 --- a/examples/jms/transactional/src/main/java/org/apache/activemq/artemis/jms/example/TransactionalExample.java +++ b/examples/jms/transactional/src/main/java/org/apache/activemq/artemis/jms/example/TransactionalExample.java @@ -25,20 +25,12 @@ import javax.jms.Session; import javax.jms.TextMessage; import javax.naming.InitialContext; -import org.apache.activemq.artemis.common.example.ActiveMQExample; - /** * A simple JMS example that sends and consume message transactionally. */ -public class TransactionalExample extends ActiveMQExample +public class TransactionalExample { - public static void main(final String[] args) - { - new TransactionalExample().run(args); - } - - @Override - public boolean runExample() throws Exception + public static void main(final String[] args) throws Exception { Connection connection = null; InitialContext initialContext = null; @@ -117,13 +109,11 @@ public class TransactionalExample extends ActiveMQExample if (receivedMessage != null) { // This was not supposed to happen - return false; + throw new IllegalStateException("Message is not null."); } System.out.println("Message received after receive commit: " + receivedMessage); - return true; - } finally { @@ -139,5 +129,4 @@ public class TransactionalExample extends ActiveMQExample } } } - } diff --git a/examples/jms/transactional/src/main/resources/activemq/server0/artemis-roles.properties b/examples/jms/transactional/src/main/resources/activemq/server0/artemis-roles.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/transactional/src/main/resources/activemq/server0/artemis-roles.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/transactional/src/main/resources/activemq/server0/artemis-users.properties b/examples/jms/transactional/src/main/resources/activemq/server0/artemis-users.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/transactional/src/main/resources/activemq/server0/artemis-users.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/transactional/src/main/resources/activemq/server0/broker.xml b/examples/jms/transactional/src/main/resources/activemq/server0/broker.xml deleted file mode 100644 index 7690094861..0000000000 --- a/examples/jms/transactional/src/main/resources/activemq/server0/broker.xml +++ /dev/null @@ -1,60 +0,0 @@ - - - - - - - - - - - - - ${data.dir}/server0/data/messaging/bindings - - ${data.dir}/server0/data/messaging/journal - - ${data.dir}/server0/data/messaging/largemessages - - ${data.dir}/server0/data/messaging/paging - - - - tcp://localhost:61616 - - - - - - - - - - - - - - - - - - diff --git a/examples/jms/xa-heuristic/pom.xml b/examples/jms/xa-heuristic/pom.xml index da401e3ec9..ada7aafe11 100644 --- a/examples/jms/xa-heuristic/pom.xml +++ b/examples/jms/xa-heuristic/pom.xml @@ -37,8 +37,13 @@ under the License. - org.apache.activemq.examples.jms - common + org.apache.activemq + artemis-core-client + ${project.version} + + + org.apache.activemq + artemis-commons ${project.version} @@ -62,11 +67,22 @@ under the License. create - ${basedir}/target/server0 - ${basedir}/target/classes/activemq/server0 -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=3001 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false + + start + + cli + + + true + tcp://localhost:61616 + + run + + + runClient @@ -74,8 +90,16 @@ under the License. org.apache.activemq.artemis.jms.example.XAHeuristicExample + + + + stop + + cli + + - ${basedir}/target/server0 + stop diff --git a/examples/jms/xa-heuristic/src/main/java/org/apache/activemq/artemis/jms/example/DummyXid.java b/examples/jms/xa-heuristic/src/main/java/org/apache/activemq/artemis/jms/example/DummyXid.java new file mode 100644 index 0000000000..2b8a200528 --- /dev/null +++ b/examples/jms/xa-heuristic/src/main/java/org/apache/activemq/artemis/jms/example/DummyXid.java @@ -0,0 +1,208 @@ +/* + * 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.jms.example; + +import javax.transaction.xa.Xid; + +import org.apache.activemq.artemis.utils.Base64; + +public class DummyXid implements Xid +{ + private static final long serialVersionUID = 407053232840068514L; + + private final byte[] branchQualifier; + + private final int formatId; + + private final byte[] globalTransactionId; + + private int hash; + + private boolean hashCalculated; + + // Static -------------------------------------------------------- + + public static String toBase64String(final Xid xid) + { + return Base64.encodeBytes(DummyXid.toByteArray(xid)); + } + + private static byte[] toByteArray(final Xid xid) + { + byte[] branchQualifier = xid.getBranchQualifier(); + byte[] globalTransactionId = xid.getGlobalTransactionId(); + int formatId = xid.getFormatId(); + + byte[] hashBytes = new byte[branchQualifier.length + globalTransactionId.length + 4]; + System.arraycopy(branchQualifier, 0, hashBytes, 0, branchQualifier.length); + System.arraycopy(globalTransactionId, 0, hashBytes, branchQualifier.length, globalTransactionId.length); + byte[] intBytes = new byte[4]; + for (int i = 0; i < 4; i++) + { + intBytes[i] = (byte)((formatId >> i * 8) % 0xFF); + } + System.arraycopy(intBytes, 0, hashBytes, branchQualifier.length + globalTransactionId.length, 4); + return hashBytes; + } + + // Constructors -------------------------------------------------- + + /** + * Standard constructor + * @param branchQualifier + * @param formatId + * @param globalTransactionId + */ + public DummyXid(final byte[] branchQualifier, final int formatId, final byte[] globalTransactionId) + { + this.branchQualifier = branchQualifier; + this.formatId = formatId; + this.globalTransactionId = globalTransactionId; + } + + /** + * Copy constructor + * @param other + */ + public DummyXid(final Xid other) + { + branchQualifier = copyBytes(other.getBranchQualifier()); + formatId = other.getFormatId(); + globalTransactionId = copyBytes(other.getGlobalTransactionId()); + } + + // Xid implementation ------------------------------------------------------------------ + + public byte[] getBranchQualifier() + { + return branchQualifier; + } + + public int getFormatId() + { + return formatId; + } + + public byte[] getGlobalTransactionId() + { + return globalTransactionId; + } + + // Public ------------------------------------------------------------------------------- + + @Override + public int hashCode() + { + if (!hashCalculated) + { + calcHash(); + } + return hash; + } + + @Override + public boolean equals(final Object other) + { + if (this == other) + { + return true; + } + if (!(other instanceof Xid)) + { + return false; + } + Xid xother = (Xid)other; + if (xother.getFormatId() != formatId) + { + return false; + } + if (xother.getBranchQualifier().length != branchQualifier.length) + { + return false; + } + if (xother.getGlobalTransactionId().length != globalTransactionId.length) + { + return false; + } + for (int i = 0; i < branchQualifier.length; i++) + { + byte[] otherBQ = xother.getBranchQualifier(); + if (branchQualifier[i] != otherBQ[i]) + { + return false; + } + } + for (int i = 0; i < globalTransactionId.length; i++) + { + byte[] otherGtx = xother.getGlobalTransactionId(); + if (globalTransactionId[i] != otherGtx[i]) + { + return false; + } + } + return true; + } + + @Override + public String toString() + { + return "XidImpl (" + System.identityHashCode(this) + + " bq:" + + stringRep(branchQualifier) + + " formatID:" + + formatId + + " gtxid:" + + stringRep(globalTransactionId); + } + + // Private ------------------------------------------------------------------------------- + + private String stringRep(final byte[] bytes) + { + StringBuilder buff = new StringBuilder(); + for (int i = 0; i < bytes.length; i++) + { + byte b = bytes[i]; + + buff.append(b); + + if (i != bytes.length - 1) + { + buff.append('.'); + } + } + + return buff.toString(); + } + + private void calcHash() + { + byte[] hashBytes = org.apache.activemq.artemis.jms.example.DummyXid.toByteArray(this); + String s = new String(hashBytes); + hash = s.hashCode(); + hashCalculated = true; + } + + private byte[] copyBytes(final byte[] other) + { + byte[] bytes = new byte[other.length]; + + System.arraycopy(other, 0, bytes, 0, other.length); + + return bytes; + } +} diff --git a/examples/jms/xa-heuristic/src/main/java/org/apache/activemq/artemis/jms/example/XAHeuristicExample.java b/examples/jms/xa-heuristic/src/main/java/org/apache/activemq/artemis/jms/example/XAHeuristicExample.java index 09232e3009..4da5c83329 100644 --- a/examples/jms/xa-heuristic/src/main/java/org/apache/activemq/artemis/jms/example/XAHeuristicExample.java +++ b/examples/jms/xa-heuristic/src/main/java/org/apache/activemq/artemis/jms/example/XAHeuristicExample.java @@ -40,29 +40,19 @@ import java.util.ArrayList; import java.util.HashMap; import org.apache.activemq.artemis.api.core.management.ObjectNameBuilder; -import org.apache.activemq.artemis.common.example.ActiveMQExample; -import org.apache.activemq.artemis.common.example.DummyXid; import org.apache.activemq.artemis.utils.UUIDGenerator; /** * A simple JMS example showing how to administer un-finished transactions. */ -public class XAHeuristicExample extends ActiveMQExample +public class XAHeuristicExample { - private volatile boolean result = true; - - private final ArrayList receiveHolder = new ArrayList(); - private static final String JMX_URL = "service:jmx:rmi:///jndi/rmi://localhost:3001/jmxrmi"; - public static void main(final String[] args) - { - new XAHeuristicExample().run(args); - } - - @Override - public boolean runExample() throws Exception + public static void main(final String[] args) throws Exception { + Boolean result = true; + final ArrayList receiveHolder = new ArrayList(); XAConnection connection = null; InitialContext initialContext = null; try @@ -90,7 +80,7 @@ public class XAHeuristicExample extends ActiveMQExample // Step 8. Create a normal Message Consumer MessageConsumer normalConsumer = normalSession.createConsumer(queue); - normalConsumer.setMessageListener(new SimpleMessageListener()); + normalConsumer.setMessageListener(new SimpleMessageListener(receiveHolder, result)); // Step 9. Get the JMS Session Session session = xaSession.getSession(); @@ -104,8 +94,8 @@ public class XAHeuristicExample extends ActiveMQExample // Step 12. create a transaction Xid xid1 = new DummyXid("xa-example1".getBytes(StandardCharsets.ISO_8859_1), 1, UUIDGenerator.getInstance() - .generateStringUUID() - .getBytes()); + .generateStringUUID() + .getBytes()); // Step 13. Get the JMS XAResource XAResource xaRes = xaSession.getXAResource(); @@ -125,12 +115,12 @@ public class XAHeuristicExample extends ActiveMQExample xaRes.prepare(xid1); // Step 18. Check none should be received - checkNoMessageReceived(); + checkNoMessageReceived(receiveHolder); // Step 19. Create another transaction. Xid xid2 = new DummyXid("xa-example2".getBytes(), 1, UUIDGenerator.getInstance() - .generateStringUUID() - .getBytes()); + .generateStringUUID() + .getBytes()); // Step 20. Begin the transaction work xaRes.start(xid2, XAResource.TMNOFLAGS); @@ -147,7 +137,7 @@ public class XAHeuristicExample extends ActiveMQExample xaRes.prepare(xid2); // Step 24. Again, no messages should be received! - checkNoMessageReceived(); + checkNoMessageReceived(receiveHolder); // Step 25. Create JMX Connector to connect to the server's MBeanServer JMXConnector connector = JMXConnectorFactory.connect(new JMXServiceURL(JMX_URL), new HashMap()); @@ -180,7 +170,7 @@ public class XAHeuristicExample extends ActiveMQExample Thread.sleep(2000); // Step 30. Check the result, only the 'world' message received - checkMessageReceived("world"); + checkMessageReceived("world", receiveHolder); // Step 31. Check the prepared transaction again, should have none. infos = (String[])mbsc.invoke(serverObject, "listPreparedTransactions", null, null); @@ -188,8 +178,6 @@ public class XAHeuristicExample extends ActiveMQExample // Step 32. Close the JMX Connector connector.close(); - - return result; } finally { @@ -205,48 +193,52 @@ public class XAHeuristicExample extends ActiveMQExample } } - private void checkMessageReceived(final String value) + private static void checkMessageReceived(final String value, ArrayList receiveHolder) { if (receiveHolder.size() != 1) { - System.out.println("Number of messages received not correct ! -- " + receiveHolder.size()); - result = false; + throw new IllegalStateException("Number of messages received not correct ! -- " + receiveHolder.size()); } String msg = receiveHolder.get(0); if (!msg.equals(value)) { - System.out.println("Received message [" + msg + "], but we expect [" + value + "]"); - result = false; + throw new IllegalStateException("Received message [" + msg + "], but we expect [" + value + "]"); } receiveHolder.clear(); } - private void checkNoMessageReceived() + private static void checkNoMessageReceived(ArrayList receiveHolder) { if (receiveHolder.size() > 0) { - System.out.println("Message received, wrong!"); - result = false; + throw new IllegalStateException("Message received, wrong!"); } receiveHolder.clear(); } +} - public class SimpleMessageListener implements MessageListener +class SimpleMessageListener implements MessageListener +{ + ArrayList receiveHolder; + Boolean result; + + SimpleMessageListener(ArrayList receiveHolder, Boolean result) { - public void onMessage(final Message message) - { - try - { - System.out.println("Message received: " + ((TextMessage)message).getText()); - receiveHolder.add(((TextMessage)message).getText()); - } - catch (JMSException e) - { - result = false; - e.printStackTrace(); - } - } - + this.receiveHolder = receiveHolder; + this.result = result; } + public void onMessage(final Message message) + { + try + { + System.out.println("Message received: " + ((TextMessage)message).getText()); + receiveHolder.add(((TextMessage)message).getText()); + } + catch (JMSException e) + { + result = false; + e.printStackTrace(); + } + } } diff --git a/examples/jms/xa-heuristic/src/main/resources/activemq/server0/artemis-roles.properties b/examples/jms/xa-heuristic/src/main/resources/activemq/server0/artemis-roles.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/xa-heuristic/src/main/resources/activemq/server0/artemis-roles.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/xa-heuristic/src/main/resources/activemq/server0/artemis-users.properties b/examples/jms/xa-heuristic/src/main/resources/activemq/server0/artemis-users.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/xa-heuristic/src/main/resources/activemq/server0/artemis-users.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/xa-heuristic/src/main/resources/activemq/server0/broker.xml b/examples/jms/xa-heuristic/src/main/resources/activemq/server0/broker.xml deleted file mode 100644 index 7690094861..0000000000 --- a/examples/jms/xa-heuristic/src/main/resources/activemq/server0/broker.xml +++ /dev/null @@ -1,60 +0,0 @@ - - - - - - - - - - - - - ${data.dir}/server0/data/messaging/bindings - - ${data.dir}/server0/data/messaging/journal - - ${data.dir}/server0/data/messaging/largemessages - - ${data.dir}/server0/data/messaging/paging - - - - tcp://localhost:61616 - - - - - - - - - - - - - - - - - - diff --git a/examples/jms/xa-receive/pom.xml b/examples/jms/xa-receive/pom.xml index 5fa068a6fd..8336c5f9e6 100644 --- a/examples/jms/xa-receive/pom.xml +++ b/examples/jms/xa-receive/pom.xml @@ -37,8 +37,8 @@ under the License. - org.apache.activemq.examples.jms - common + org.apache.activemq + artemis-commons ${project.version} @@ -61,9 +61,18 @@ under the License. create + + + start + + cli + - ${basedir}/target/server0 - ${basedir}/target/classes/activemq/server0 + true + tcp://localhost:61616 + + run + @@ -72,9 +81,17 @@ under the License. runClient - org.apache.activemq.artemis.jms.example.TransactionalExample + org.apache.activemq.artemis.jms.example.XAReceiveExample + + + + stop + + cli + + - ${basedir}/target/server0 + stop diff --git a/examples/jms/common/src/main/java/org/apache/activemq/artemis/common/example/DummyXid.java b/examples/jms/xa-receive/src/main/java/org/apache/activemq/artemis/jms/example/DummyXid.java similarity index 99% rename from examples/jms/common/src/main/java/org/apache/activemq/artemis/common/example/DummyXid.java rename to examples/jms/xa-receive/src/main/java/org/apache/activemq/artemis/jms/example/DummyXid.java index 05e320fb9e..c8bf9cc834 100644 --- a/examples/jms/common/src/main/java/org/apache/activemq/artemis/common/example/DummyXid.java +++ b/examples/jms/xa-receive/src/main/java/org/apache/activemq/artemis/jms/example/DummyXid.java @@ -14,12 +14,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.activemq.artemis.common.example; - -import javax.transaction.xa.Xid; +package org.apache.activemq.artemis.jms.example; import org.apache.activemq.artemis.utils.Base64; +import javax.transaction.xa.Xid; + public class DummyXid implements Xid { private static final long serialVersionUID = 407053232840068514L; diff --git a/examples/jms/xa-receive/src/main/java/org/apache/activemq/artemis/jms/example/XAReceiveExample.java b/examples/jms/xa-receive/src/main/java/org/apache/activemq/artemis/jms/example/XAReceiveExample.java index 2671e54682..6562cea5ca 100644 --- a/examples/jms/xa-receive/src/main/java/org/apache/activemq/artemis/jms/example/XAReceiveExample.java +++ b/examples/jms/xa-receive/src/main/java/org/apache/activemq/artemis/jms/example/XAReceiveExample.java @@ -29,26 +29,14 @@ import javax.transaction.xa.XAResource; import javax.transaction.xa.Xid; import java.nio.charset.StandardCharsets; -import org.apache.activemq.artemis.common.example.ActiveMQExample; - -// Defined on xa-heuristic example, the maven dependency will take care of that -import org.apache.activemq.artemis.common.example.DummyXid; import org.apache.activemq.artemis.utils.UUIDGenerator; /** * A simple JMS example showing the usage of XA support in JMS. */ -public class XAReceiveExample extends ActiveMQExample +public class XAReceiveExample { - private volatile boolean result = true; - - public static void main(final String[] args) - { - new XAReceiveExample().run(args); - } - - @Override - public boolean runExample() throws Exception + public static void main(final String[] args) throws Exception { XAConnection connection = null; InitialContext initialContext = null; @@ -90,8 +78,8 @@ public class XAReceiveExample extends ActiveMQExample // Step 12. create a transaction Xid xid1 = new DummyXid("xa-example1".getBytes(StandardCharsets.US_ASCII), 1, UUIDGenerator.getInstance() - .generateStringUUID() - .getBytes()); + .generateStringUUID() + .getBytes()); // Step 13. Get the JMS XAResource XAResource xaRes = xaSession.getXAResource(); @@ -120,8 +108,8 @@ public class XAReceiveExample extends ActiveMQExample // Step 20. Create another transaction Xid xid2 = new DummyXid("xa-example2".getBytes(), 1, UUIDGenerator.getInstance() - .generateStringUUID() - .getBytes()); + .generateStringUUID() + .getBytes()); // Step 21. Start the transaction xaRes.start(xid2, XAResource.TMNOFLAGS); @@ -149,10 +137,8 @@ public class XAReceiveExample extends ActiveMQExample } else { - result = false; + throw new IllegalStateException(); } - - return result; } finally { @@ -167,5 +153,4 @@ public class XAReceiveExample extends ActiveMQExample } } } - } diff --git a/examples/jms/xa-receive/src/main/resources/activemq/server0/artemis-roles.properties b/examples/jms/xa-receive/src/main/resources/activemq/server0/artemis-roles.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/xa-receive/src/main/resources/activemq/server0/artemis-roles.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/xa-receive/src/main/resources/activemq/server0/artemis-users.properties b/examples/jms/xa-receive/src/main/resources/activemq/server0/artemis-users.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/xa-receive/src/main/resources/activemq/server0/artemis-users.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/xa-receive/src/main/resources/activemq/server0/broker.xml b/examples/jms/xa-receive/src/main/resources/activemq/server0/broker.xml deleted file mode 100644 index 7690094861..0000000000 --- a/examples/jms/xa-receive/src/main/resources/activemq/server0/broker.xml +++ /dev/null @@ -1,60 +0,0 @@ - - - - - - - - - - - - - ${data.dir}/server0/data/messaging/bindings - - ${data.dir}/server0/data/messaging/journal - - ${data.dir}/server0/data/messaging/largemessages - - ${data.dir}/server0/data/messaging/paging - - - - tcp://localhost:61616 - - - - - - - - - - - - - - - - - - diff --git a/examples/jms/xa-send/pom.xml b/examples/jms/xa-send/pom.xml index 594bb446af..3038202e98 100644 --- a/examples/jms/xa-send/pom.xml +++ b/examples/jms/xa-send/pom.xml @@ -37,8 +37,8 @@ under the License. - org.apache.activemq.examples.jms - common + org.apache.activemq + artemis-commons ${project.version} @@ -56,18 +56,23 @@ under the License. org.apache.activemq artemis-maven-plugin + + create + + create + + start - start + cli - - - data.dir - ${basedir}/target/ - - + true + tcp://localhost:61616 + + run + @@ -82,8 +87,13 @@ under the License. stop - stop + cli + + + stop + + @@ -92,45 +102,10 @@ under the License. artemis-jms-xa-send-example ${project.version} - - org.apache.activemq - artemis-core-client - ${project.version} - - - org.apache.activemq - artemis-server - ${project.version} - - - org.apache.activemq - artemis-jms-client - ${project.version} - - - org.apache.activemq - artemis-jms-server - ${project.version} - - - io.netty - netty-all - ${netty.version} - - - org.apache.geronimo.specs - geronimo-jms_2.0_spec - ${geronimo.jms.2.spec.version} - - - false - ${basedir}/target/classes/activemq/server0 - - diff --git a/examples/jms/xa-send/src/main/java/org/apache/activemq/artemis/jms/example/DummyXid.java b/examples/jms/xa-send/src/main/java/org/apache/activemq/artemis/jms/example/DummyXid.java new file mode 100644 index 0000000000..c8bf9cc834 --- /dev/null +++ b/examples/jms/xa-send/src/main/java/org/apache/activemq/artemis/jms/example/DummyXid.java @@ -0,0 +1,208 @@ +/* + * 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.jms.example; + +import org.apache.activemq.artemis.utils.Base64; + +import javax.transaction.xa.Xid; + +public class DummyXid implements Xid +{ + private static final long serialVersionUID = 407053232840068514L; + + private final byte[] branchQualifier; + + private final int formatId; + + private final byte[] globalTransactionId; + + private int hash; + + private boolean hashCalculated; + + // Static -------------------------------------------------------- + + public static String toBase64String(final Xid xid) + { + return Base64.encodeBytes(DummyXid.toByteArray(xid)); + } + + private static byte[] toByteArray(final Xid xid) + { + byte[] branchQualifier = xid.getBranchQualifier(); + byte[] globalTransactionId = xid.getGlobalTransactionId(); + int formatId = xid.getFormatId(); + + byte[] hashBytes = new byte[branchQualifier.length + globalTransactionId.length + 4]; + System.arraycopy(branchQualifier, 0, hashBytes, 0, branchQualifier.length); + System.arraycopy(globalTransactionId, 0, hashBytes, branchQualifier.length, globalTransactionId.length); + byte[] intBytes = new byte[4]; + for (int i = 0; i < 4; i++) + { + intBytes[i] = (byte)((formatId >> i * 8) % 0xFF); + } + System.arraycopy(intBytes, 0, hashBytes, branchQualifier.length + globalTransactionId.length, 4); + return hashBytes; + } + + // Constructors -------------------------------------------------- + + /** + * Standard constructor + * @param branchQualifier + * @param formatId + * @param globalTransactionId + */ + public DummyXid(final byte[] branchQualifier, final int formatId, final byte[] globalTransactionId) + { + this.branchQualifier = branchQualifier; + this.formatId = formatId; + this.globalTransactionId = globalTransactionId; + } + + /** + * Copy constructor + * @param other + */ + public DummyXid(final Xid other) + { + branchQualifier = copyBytes(other.getBranchQualifier()); + formatId = other.getFormatId(); + globalTransactionId = copyBytes(other.getGlobalTransactionId()); + } + + // Xid implementation ------------------------------------------------------------------ + + public byte[] getBranchQualifier() + { + return branchQualifier; + } + + public int getFormatId() + { + return formatId; + } + + public byte[] getGlobalTransactionId() + { + return globalTransactionId; + } + + // Public ------------------------------------------------------------------------------- + + @Override + public int hashCode() + { + if (!hashCalculated) + { + calcHash(); + } + return hash; + } + + @Override + public boolean equals(final Object other) + { + if (this == other) + { + return true; + } + if (!(other instanceof Xid)) + { + return false; + } + Xid xother = (Xid)other; + if (xother.getFormatId() != formatId) + { + return false; + } + if (xother.getBranchQualifier().length != branchQualifier.length) + { + return false; + } + if (xother.getGlobalTransactionId().length != globalTransactionId.length) + { + return false; + } + for (int i = 0; i < branchQualifier.length; i++) + { + byte[] otherBQ = xother.getBranchQualifier(); + if (branchQualifier[i] != otherBQ[i]) + { + return false; + } + } + for (int i = 0; i < globalTransactionId.length; i++) + { + byte[] otherGtx = xother.getGlobalTransactionId(); + if (globalTransactionId[i] != otherGtx[i]) + { + return false; + } + } + return true; + } + + @Override + public String toString() + { + return "XidImpl (" + System.identityHashCode(this) + + " bq:" + + stringRep(branchQualifier) + + " formatID:" + + formatId + + " gtxid:" + + stringRep(globalTransactionId); + } + + // Private ------------------------------------------------------------------------------- + + private String stringRep(final byte[] bytes) + { + StringBuilder buff = new StringBuilder(); + for (int i = 0; i < bytes.length; i++) + { + byte b = bytes[i]; + + buff.append(b); + + if (i != bytes.length - 1) + { + buff.append('.'); + } + } + + return buff.toString(); + } + + private void calcHash() + { + byte[] hashBytes = DummyXid.toByteArray(this); + String s = new String(hashBytes); + hash = s.hashCode(); + hashCalculated = true; + } + + private byte[] copyBytes(final byte[] other) + { + byte[] bytes = new byte[other.length]; + + System.arraycopy(other, 0, bytes, 0, other.length); + + return bytes; + } +} diff --git a/examples/jms/xa-send/src/main/java/org/apache/activemq/artemis/jms/example/XASendExample.java b/examples/jms/xa-send/src/main/java/org/apache/activemq/artemis/jms/example/XASendExample.java index 447fbc49f0..43d6c21193 100644 --- a/examples/jms/xa-send/src/main/java/org/apache/activemq/artemis/jms/example/XASendExample.java +++ b/examples/jms/xa-send/src/main/java/org/apache/activemq/artemis/jms/example/XASendExample.java @@ -32,28 +32,19 @@ import javax.transaction.xa.XAResource; import javax.transaction.xa.Xid; import java.nio.charset.StandardCharsets; import java.util.ArrayList; +import java.util.concurrent.atomic.AtomicBoolean; -import org.apache.activemq.artemis.common.example.ActiveMQExample; -import org.apache.activemq.artemis.common.example.DummyXid; import org.apache.activemq.artemis.utils.UUIDGenerator; /** * A simple JMS example showing the usage of XA support in JMS. */ -public class XASendExample extends ActiveMQExample +public class XASendExample { - private volatile boolean result = true; - - private final ArrayList receiveHolder = new ArrayList(); - - public static void main(final String[] args) - { - new XASendExample().run(args); - } - - @Override - public boolean runExample() throws Exception + public static void main(final String[] args) throws Exception { + AtomicBoolean result = new AtomicBoolean(true); + final ArrayList receiveHolder = new ArrayList(); XAConnection connection = null; InitialContext initialContext = null; try @@ -81,7 +72,7 @@ public class XASendExample extends ActiveMQExample // Step 8. Create a normal Message Consumer MessageConsumer normalConsumer = normalSession.createConsumer(queue); - normalConsumer.setMessageListener(new SimpleMessageListener()); + normalConsumer.setMessageListener(new SimpleMessageListener(receiveHolder, result)); // Step 9. Get the JMS Session Session session = xaSession.getSession(); @@ -95,8 +86,8 @@ public class XASendExample extends ActiveMQExample // Step 12. create a transaction Xid xid1 = new DummyXid("xa-example1".getBytes(StandardCharsets.UTF_8), 1, UUIDGenerator.getInstance() - .generateStringUUID() - .getBytes()); + .generateStringUUID() + .getBytes()); // Step 13. Get the JMS XAResource XAResource xaRes = xaSession.getXAResource(); @@ -111,7 +102,7 @@ public class XASendExample extends ActiveMQExample Thread.sleep(2000); // Step 16. Check the result, it should receive none! - checkNoMessageReceived(); + checkNoMessageReceived(receiveHolder); // Step 17. Stop the work xaRes.end(xid1, XAResource.TMSUCCESS); @@ -123,12 +114,12 @@ public class XASendExample extends ActiveMQExample xaRes.rollback(xid1); // Step 20. No messages should be received! - checkNoMessageReceived(); + checkNoMessageReceived(receiveHolder); // Step 21. Create another transaction Xid xid2 = new DummyXid("xa-example2".getBytes(), 1, UUIDGenerator.getInstance() - .generateStringUUID() - .getBytes()); + .generateStringUUID() + .getBytes()); // Step 22. Start the transaction xaRes.start(xid2, XAResource.TMNOFLAGS); @@ -144,7 +135,7 @@ public class XASendExample extends ActiveMQExample xaRes.prepare(xid2); // Step 26. No messages should be received at this moment - checkNoMessageReceived(); + checkNoMessageReceived(receiveHolder); // Step 27. Commit! xaRes.commit(xid2, false); @@ -152,9 +143,10 @@ public class XASendExample extends ActiveMQExample Thread.sleep(2000); // Step 28. Check the result, all message received - checkAllMessageReceived(); + checkAllMessageReceived(receiveHolder); - return result; + if (!result.get()) + throw new IllegalStateException(); } finally { @@ -170,42 +162,47 @@ public class XASendExample extends ActiveMQExample } } - private void checkAllMessageReceived() + private static void checkAllMessageReceived(ArrayList receiveHolder) { if (receiveHolder.size() != 2) { - System.out.println("Number of messages received not correct ! -- " + receiveHolder.size()); - result = false; + throw new IllegalStateException("Number of messages received not correct ! -- " + receiveHolder.size()); } receiveHolder.clear(); } - private void checkNoMessageReceived() + private static void checkNoMessageReceived(ArrayList receiveHolder) { if (receiveHolder.size() > 0) { - System.out.println("Message received, wrong!"); - result = false; + throw new IllegalStateException("Message received, wrong!"); } receiveHolder.clear(); } +} - public class SimpleMessageListener implements MessageListener +class SimpleMessageListener implements MessageListener +{ + ArrayList receiveHolder; + AtomicBoolean result; + + public SimpleMessageListener(ArrayList receiveHolder, AtomicBoolean result) { - public void onMessage(final Message message) - { - try - { - System.out.println("Message received: " + message); - receiveHolder.add(((TextMessage)message).getText()); - } - catch (JMSException e) - { - result = false; - e.printStackTrace(); - } - } - + this.receiveHolder = receiveHolder; + this.result = result; } + public void onMessage(final Message message) + { + try + { + System.out.println("Message received: " + message); + receiveHolder.add(((TextMessage)message).getText()); + } + catch (JMSException e) + { + result.set(false); + e.printStackTrace(); + } + } } diff --git a/examples/jms/xa-send/src/main/resources/activemq/server0/artemis-roles.properties b/examples/jms/xa-send/src/main/resources/activemq/server0/artemis-roles.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/xa-send/src/main/resources/activemq/server0/artemis-roles.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/xa-send/src/main/resources/activemq/server0/artemis-users.properties b/examples/jms/xa-send/src/main/resources/activemq/server0/artemis-users.properties deleted file mode 100644 index 4e2d44cec4..0000000000 --- a/examples/jms/xa-send/src/main/resources/activemq/server0/artemis-users.properties +++ /dev/null @@ -1,17 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file diff --git a/examples/jms/xa-send/src/main/resources/activemq/server0/broker.xml b/examples/jms/xa-send/src/main/resources/activemq/server0/broker.xml deleted file mode 100644 index 7690094861..0000000000 --- a/examples/jms/xa-send/src/main/resources/activemq/server0/broker.xml +++ /dev/null @@ -1,60 +0,0 @@ - - - - - - - - - - - - - ${data.dir}/server0/data/messaging/bindings - - ${data.dir}/server0/data/messaging/journal - - ${data.dir}/server0/data/messaging/largemessages - - ${data.dir}/server0/data/messaging/paging - - - - tcp://localhost:61616 - - - - - - - - - - - - - - - - - -