From 138bfe968259eca3f8be0e98076195a2b4bf2946 Mon Sep 17 00:00:00 2001
From: Clebert Suconic
Date: Thu, 6 Aug 2015 10:24:00 -0400
Subject: [PATCH 1/2] Removing 'created by' comments
---
.../artemis/core/server/impl/SharedStoreLiveActivation.java | 3 ---
.../activemq/artemis/core/transaction/TransactionFactory.java | 3 ---
.../activemq/network/MQTTNetworkOfBrokersFailoverTest.java | 4 ----
3 files changed, 10 deletions(-)
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/SharedStoreLiveActivation.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/SharedStoreLiveActivation.java
index 0e41b7aae5..e9b67b8c81 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/SharedStoreLiveActivation.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/SharedStoreLiveActivation.java
@@ -20,9 +20,6 @@ import org.apache.activemq.artemis.core.server.ActiveMQServerLogger;
import org.apache.activemq.artemis.core.server.NodeManager;
import org.apache.activemq.artemis.core.server.cluster.ha.SharedStoreMasterPolicy;
-/**
-* Created by andy on 04/09/14.
-*/
public final class SharedStoreLiveActivation extends LiveActivation
{
//this is how we act when we initially start as live
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/transaction/TransactionFactory.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/transaction/TransactionFactory.java
index 5252f665c7..976543947e 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/transaction/TransactionFactory.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/transaction/TransactionFactory.java
@@ -20,9 +20,6 @@ import org.apache.activemq.artemis.core.persistence.StorageManager;
import javax.transaction.xa.Xid;
-/**
- * Created by andy on 22/07/14.
- */
public interface TransactionFactory
{
Transaction newTransaction(Xid xid, StorageManager storageManager, int timeoutSeconds);
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/MQTTNetworkOfBrokersFailoverTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/MQTTNetworkOfBrokersFailoverTest.java
index 928a7a6364..d0bd3d79b9 100644
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/MQTTNetworkOfBrokersFailoverTest.java
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/MQTTNetworkOfBrokersFailoverTest.java
@@ -47,10 +47,6 @@ import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-/**
- * Created by ceposta
- * filters)
+ {
+ StringWriter writer = new StringWriter();
+ PrintWriter printWriter = new PrintWriter(writer);
+ printWriter.println();
+
+ for (String str : getQueueList())
+ {
+ printWriter.println(" ");
+ }
+ for (String str : getTopicList())
+ {
+ printWriter.println(" ");
+ }
+ filters.put("${jms-list.settings}", writer.toString());
+ }
+
private void performAutoTune(HashMap filters, boolean aio, File dataFolder)
{
if (noAutoTune)
@@ -793,6 +819,31 @@ public class Create extends InputAbstract
}
}
+
+ private String[] getQueueList()
+ {
+ if (queues == null)
+ {
+ return new String[0];
+ }
+ else
+ {
+ return queues.split(",");
+ }
+ }
+
+ private String[] getTopicList()
+ {
+ if (topics == null)
+ {
+ return new String[0];
+ }
+ else
+ {
+ return topics.split(",");
+ }
+ }
+
String path(String value, boolean unixPaths) throws IOException
{
return path(new File(value), unixPaths);
diff --git a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/InputAbstract.java b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/InputAbstract.java
index c348484dae..f5180ef17e 100644
--- a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/InputAbstract.java
+++ b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/InputAbstract.java
@@ -26,7 +26,7 @@ public class InputAbstract extends ActionAbstract
private Scanner scanner;
- @Option(name = "--silent-input", description = "It will disable all the inputs, and it would make a best guess for any required input")
+ @Option(name = "--silent", description = "It will disable all the inputs, and it would make a best guess for any required input")
private boolean silentInput = false;
public boolean isSilentInput()
diff --git a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/tools/XmlDataExporter.java b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/tools/XmlDataExporter.java
index cf5be129ca..3ea76ce406 100644
--- a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/tools/XmlDataExporter.java
+++ b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/tools/XmlDataExporter.java
@@ -131,7 +131,7 @@ public final class XmlDataExporter extends DataAbstract implements Action
try
{
- process(System.out, getBinding(), getJournal(), getPaging(), getLargeMessages());
+ process(context.out, getBinding(), getJournal(), getPaging(), getLargeMessages());
}
catch (Exception e)
{
diff --git a/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/etc/broker.xml b/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/etc/broker.xml
index 1cd32456e4..75cd6ee17e 100644
--- a/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/etc/broker.xml
+++ b/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/etc/broker.xml
@@ -24,7 +24,7 @@ under the License.
-
+ ${jms-list.settings}
diff --git a/artemis-cli/src/test/java/org/apache/activemq/cli/test/ArtemisTest.java b/artemis-cli/src/test/java/org/apache/activemq/cli/test/ArtemisTest.java
index 3aed71e79e..a42fae92e7 100644
--- a/artemis-cli/src/test/java/org/apache/activemq/cli/test/ArtemisTest.java
+++ b/artemis-cli/src/test/java/org/apache/activemq/cli/test/ArtemisTest.java
@@ -23,9 +23,14 @@ import javax.jms.TextMessage;
import java.io.File;
import java.util.concurrent.TimeUnit;
+import org.apache.activemq.artemis.api.core.SimpleString;
+import org.apache.activemq.artemis.api.core.client.ClientSession;
+import org.apache.activemq.artemis.api.core.client.ClientSessionFactory;
+import org.apache.activemq.artemis.api.core.client.ServerLocator;
import org.apache.activemq.artemis.cli.Artemis;
import org.apache.activemq.artemis.cli.commands.Run;
import org.apache.activemq.artemis.cli.commands.util.SyncCalculation;
+import org.apache.activemq.artemis.core.client.impl.ServerLocatorImpl;
import org.apache.activemq.artemis.jlibaio.LibaioContext;
import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory;
import org.apache.activemq.artemis.jms.client.ActiveMQDestination;
@@ -83,15 +88,35 @@ public class ArtemisTest
Assert.assertEquals(0, LibaioContext.getTotalMaxIO());
}
-
@Test
public void testSimpleRun() throws Exception
{
+ String queues = "q1,t2";
+ String topics = "t1,t2";
Run.setEmbedded(true);
- Artemis.main("create", temporaryFolder.getRoot().getAbsolutePath(), "--force", "--silent-input", "--no-web");
+ Artemis.main("create", temporaryFolder.getRoot().getAbsolutePath(), "--force", "--silent", "--no-web", "--queues", queues, "--topics", topics);
System.setProperty("artemis.instance", temporaryFolder.getRoot().getAbsolutePath());
// Some exceptions may happen on the initialization, but they should be ok on start the basic core protocol
Artemis.execute("run");
+
+
+ try (ServerLocator locator = ServerLocatorImpl.newLocator("tcp://localhost:61616");
+ ClientSessionFactory factory = locator.createSessionFactory();
+ ClientSession coreSession = factory.createSession())
+ {
+ for (String str: queues.split(","))
+ {
+ ClientSession.QueueQuery queryResult = coreSession.queueQuery(SimpleString.toSimpleString("jms.queue." + str));
+ Assert.assertTrue("Couldn't find queue " + str, queryResult.isExists());
+ }
+ for (String str: topics.split(","))
+ {
+ ClientSession.QueueQuery queryResult = coreSession.queueQuery(SimpleString.toSimpleString("jms.topic." + str));
+ Assert.assertTrue("Couldn't find topic " + str, queryResult.isExists());
+ }
+ }
+
+
Assert.assertEquals(Integer.valueOf(1000), Artemis.execute("producer", "--message-count", "1000", "--verbose"));
Assert.assertEquals(Integer.valueOf(1000), Artemis.execute("consumer", "--verbose", "--break-on-null", "--receive-timeout", "100"));
@@ -100,6 +125,7 @@ public class ArtemisTest
Session session = connection.createSession(true, Session.SESSION_TRANSACTED);
MessageProducer producer = session.createProducer(ActiveMQDestination.createDestination("queue://TEST", ActiveMQDestination.QUEUE_TYPE));
+
TextMessage message = session.createTextMessage("Banana");
message.setStringProperty("fruit", "banana");
producer.send(message);
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/ActiveMQClientLogger.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/ActiveMQClientLogger.java
index ba3fad85ff..8b3d0da9f2 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/ActiveMQClientLogger.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/ActiveMQClientLogger.java
@@ -181,7 +181,7 @@ public interface ActiveMQClientLogger extends BasicLogger
@Message(id = 212028, value = "error starting server locator", format = Message.Format.MESSAGE_FORMAT)
void errorStartingLocator(@Cause Exception e);
- @LogMessage(level = Logger.Level.WARN)
+ @LogMessage(level = Logger.Level.DEBUG)
@Message(id = 212029,
value = "Closing a Server Locator left open. Please make sure you close all Server Locators explicitly before letting them go out of scope! {0}",
format = Message.Format.MESSAGE_FORMAT)
diff --git a/artemis-distribution/src/main/resources/README.html b/artemis-distribution/src/main/resources/README.html
index f8327061fa..fe89886b50 100644
--- a/artemis-distribution/src/main/resources/README.html
+++ b/artemis-distribution/src/main/resources/README.html
@@ -71,7 +71,7 @@ SYNOPSIS
[--clustered] [--data ] [--encoding ] [--force]
[--home ] [--host ] [--java-options ]
[--password ] [--port-offset ] [--replicated]
- [--role ] [--shared-store] [--silent-input] [--user ] [--]
+ [--role ] [--shared-store] [--silent] [--user ] [--]
...
diff --git a/artemis-maven-plugin/src/main/java/org/apache/activemq/artemis/maven/ArtemisAbstractPlugin.java b/artemis-maven-plugin/src/main/java/org/apache/activemq/artemis/maven/ArtemisAbstractPlugin.java
new file mode 100644
index 0000000000..43cc075a79
--- /dev/null
+++ b/artemis-maven-plugin/src/main/java/org/apache/activemq/artemis/maven/ArtemisAbstractPlugin.java
@@ -0,0 +1,48 @@
+/**
+ * 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.maven;
+
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.plugins.annotations.Parameter;
+
+public abstract class ArtemisAbstractPlugin extends AbstractMojo
+{
+
+
+ /** It will ignore executioni if ignore has been set to true. This is useful as a property from the build. */
+ @Parameter(defaultValue = "")
+ private boolean ignore;
+
+ public void execute() throws MojoExecutionException, MojoFailureException
+ {
+ if (ignore)
+ {
+ getLog().debug("******************************************************************************************************");
+ getLog().debug("Execution of " + getClass().getSimpleName() + " is being ignored as ignore has been set to true");
+ getLog().debug("******************************************************************************************************");
+ }
+ else
+ {
+ doExecute();
+ }
+ }
+
+ protected abstract void doExecute() throws MojoExecutionException, MojoFailureException;
+}
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 1fd46148db..45aafcb59b 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,10 +16,14 @@
*/
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 org.apache.activemq.artemis.cli.Artemis;
import org.apache.activemq.artemis.cli.commands.Run;
import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory;
-import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugin.descriptor.PluginDescriptor;
@@ -28,13 +32,8 @@ 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
+public class ArtemisCLIPlugin extends ArtemisAbstractPlugin
{
private PluginDescriptor descriptor;
@@ -98,7 +97,8 @@ public class ArtemisCLIPlugin extends AbstractMojo
}
- public void execute() throws MojoExecutionException, MojoFailureException
+ @Override
+ protected void doExecute() throws MojoExecutionException, MojoFailureException
{
// This is to avoid the Run issuing a kill at any point
Run.setEmbedded(true);
diff --git a/artemis-maven-plugin/src/main/java/org/apache/activemq/artemis/maven/ActiveMQClientPlugin.java b/artemis-maven-plugin/src/main/java/org/apache/activemq/artemis/maven/ArtemisClientPlugin.java
similarity index 91%
rename from artemis-maven-plugin/src/main/java/org/apache/activemq/artemis/maven/ActiveMQClientPlugin.java
rename to artemis-maven-plugin/src/main/java/org/apache/activemq/artemis/maven/ArtemisClientPlugin.java
index c269e4f691..1716c033d7 100644
--- a/artemis-maven-plugin/src/main/java/org/apache/activemq/artemis/maven/ActiveMQClientPlugin.java
+++ b/artemis-maven-plugin/src/main/java/org/apache/activemq/artemis/maven/ArtemisClientPlugin.java
@@ -16,21 +16,20 @@
*/
package org.apache.activemq.artemis.maven;
-import org.apache.maven.plugin.AbstractMojo;
+import java.lang.reflect.Method;
+import java.util.Properties;
+
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
-import java.lang.reflect.Method;
-import java.util.Properties;
-
/**
* Allows a Java Client to be run which must hve a static main(String[] args) method
*/
@Mojo(name = "runClient", defaultPhase = LifecyclePhase.VERIFY)
-public class ActiveMQClientPlugin extends AbstractMojo
+public class ArtemisClientPlugin extends ArtemisAbstractPlugin
{
@Parameter
@@ -44,7 +43,8 @@ public class ActiveMQClientPlugin extends AbstractMojo
*/
private Properties systemProperties;
- public void execute() throws MojoExecutionException, MojoFailureException
+ @Override
+ protected void doExecute() throws MojoExecutionException, MojoFailureException
{
try
{
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/ArtemisCreatePlugin.java
similarity index 86%
rename from artemis-maven-plugin/src/main/java/org/apache/activemq/artemis/maven/ActiveMQCreatePlugin.java
rename to artemis-maven-plugin/src/main/java/org/apache/activemq/artemis/maven/ArtemisCreatePlugin.java
index 405b2b1d80..eb3462ecac 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/ArtemisCreatePlugin.java
@@ -28,7 +28,6 @@ import java.util.Map;
import java.util.Set;
import org.apache.activemq.artemis.cli.Artemis;
-import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugin.descriptor.PluginDescriptor;
@@ -47,7 +46,7 @@ import org.eclipse.aether.resolution.ArtifactResolutionException;
import org.eclipse.aether.resolution.ArtifactResult;
@Mojo(name = "create", defaultPhase = LifecyclePhase.VERIFY)
-public class ActiveMQCreatePlugin extends AbstractMojo
+public class ArtemisCreatePlugin extends ArtemisAbstractPlugin
{
@@ -59,6 +58,7 @@ public class ActiveMQCreatePlugin extends AbstractMojo
*/
private PluginDescriptor descriptor;
+ /** Directory to replace the configuration with */
@Parameter(defaultValue = "${basedir}/target/classes/activemq/server0", required = true)
private File configuration;
@@ -98,7 +98,7 @@ public class ActiveMQCreatePlugin extends AbstractMojo
@Parameter(defaultValue = "false")
private boolean sharedStore;
- @Parameter(defaultValue = "true")
+ @Parameter(defaultValue = "false")
private boolean clustered;
@Parameter(defaultValue = "false")
@@ -110,6 +110,10 @@ public class ActiveMQCreatePlugin extends AbstractMojo
@Parameter(defaultValue = "false")
private boolean failoverOnShutdown;
+ /** it will disable auto-tune*/
+ @Parameter(defaultValue = "true")
+ private boolean noAutoTune;
+
@Parameter(defaultValue = "ON_DEMAND")
private String messageLoadBalancing;
@@ -122,6 +126,13 @@ public class ActiveMQCreatePlugin extends AbstractMojo
@Parameter(defaultValue = "${project.remoteProjectRepositories}")
private List remoteRepos;
+ /**
+ * For extra stuff not covered by the properties
+ */
+ @Parameter
+ ArrayList args = new ArrayList<>();
+
+
@Parameter
private String[] libList;
@@ -166,7 +177,8 @@ public class ActiveMQCreatePlugin extends AbstractMojo
}
}
- public void execute() throws MojoExecutionException, MojoFailureException
+ @Override
+ protected void doExecute() throws MojoExecutionException, MojoFailureException
{
if (System.getProperty("bypassAddress") != null)
{
@@ -205,7 +217,8 @@ public class ActiveMQCreatePlugin extends AbstractMojo
}
ArrayList listCommands = new ArrayList<>();
- add(listCommands, "create", "--allow-anonymous", "--silent-input", "--force", "--no-web", "--user", user, "--password", password,
+
+ add(listCommands, "create", "--allow-anonymous", "--silent", "--force", "--no-web", "--user", user, "--password", password,
"--role", role,
"--port-offset", "" + portOffset,
"--data", dataFolder);
@@ -250,38 +263,46 @@ public class ActiveMQCreatePlugin extends AbstractMojo
add(listCommands, "--failover-on-shutdown");
}
- add(listCommands, "--no-autotune");
+ if (noAutoTune)
+ {
+ add(listCommands, "--no-autotune");
+ }
+
add(listCommands, "--verbose");
+ for (String str : args)
+ {
+ add(listCommands, str);
+ }
+
add(listCommands, instance.getAbsolutePath());
- getLog().info("************************************************");
- getLog().info("Calling create server at " + instance + " home= " + home);
+ getLog().debug("***** Server created at " + instance + " with home=" + home + " *****");
try
{
Artemis.execute(home, null, listCommands);
- String[] list = configuration.list();
-
- if (list != null)
+ if (configuration != null)
{
- getLog().debug("************************************************");
- getLog().debug("Replacing configuration files:");
+ String[] list = configuration.list();
- for (String file : configuration.list())
+ if (list != null)
{
- Path target = instance.toPath().resolve("etc").resolve(file);
- getLog().debug("Replacing " + file + " into " + target);
+ getLog().debug("************************************************");
+ getLog().debug("Replacing configuration files:");
+
+ for (String file : configuration.list())
+ {
+ Path target = instance.toPath().resolve("etc").resolve(file);
+ getLog().debug("Replacing " + file + " into " + target);
- Files.copy(configuration.toPath().resolve(file), target, StandardCopyOption.REPLACE_EXISTING);
+ Files.copy(configuration.toPath().resolve(file), target, StandardCopyOption.REPLACE_EXISTING);
+ }
}
}
- File projectLib = project.getArtifact().getFile();
- copyToLib(projectLib);
-
if (libList != null)
{
for (int i = 0; i < libList.length; i++)
diff --git a/artemis-maven-plugin/src/main/java/org/apache/activemq/artemis/maven/LibInstallPlugin.java b/artemis-maven-plugin/src/main/java/org/apache/activemq/artemis/maven/LibInstallPlugin.java
deleted file mode 100644
index e65108d8d9..0000000000
--- a/artemis-maven-plugin/src/main/java/org/apache/activemq/artemis/maven/LibInstallPlugin.java
+++ /dev/null
@@ -1,147 +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.maven;
-
-import java.io.File;
-import java.io.IOException;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.StandardCopyOption;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.maven.plugin.AbstractMojo;
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.MojoFailureException;
-import org.apache.maven.plugin.descriptor.PluginDescriptor;
-import org.apache.maven.plugins.annotations.Component;
-import org.apache.maven.plugins.annotations.LifecyclePhase;
-import org.apache.maven.plugins.annotations.Mojo;
-import org.apache.maven.plugins.annotations.Parameter;
-import org.apache.maven.project.MavenProject;
-import org.eclipse.aether.RepositorySystem;
-import org.eclipse.aether.RepositorySystemSession;
-import org.eclipse.aether.artifact.Artifact;
-import org.eclipse.aether.artifact.DefaultArtifact;
-import org.eclipse.aether.repository.RemoteRepository;
-import org.eclipse.aether.resolution.ArtifactRequest;
-import org.eclipse.aether.resolution.ArtifactResolutionException;
-import org.eclipse.aether.resolution.ArtifactResult;
-
-@Mojo(name = "lib-install", defaultPhase = LifecyclePhase.VERIFY)
-public class LibInstallPlugin extends AbstractMojo
-
-{
-
- @Parameter
- String name;
-
- /**
- * The plugin descriptor
- */
- private PluginDescriptor descriptor;
-
- @Parameter(defaultValue = "${basedir}/target/server0", required = true)
- private File instance;
-
- @Component
- private RepositorySystem repositorySystem;
-
- @Parameter(defaultValue = "${repositorySystemSession}")
- private RepositorySystemSession repoSession;
-
- @Parameter(defaultValue = "${project.remoteProjectRepositories}")
- private List remoteRepos;
-
-
- @Parameter
- private String[] libList;
-
- @Parameter(defaultValue = "${localRepository}")
- private org.apache.maven.artifact.repository.ArtifactRepository localRepository;
-
- public void execute() throws MojoExecutionException, MojoFailureException
- {
- MavenProject project = (MavenProject) getPluginContext().get("project");
-
- Map properties = getPluginContext();
-
- try
- {
-
- File projectLib = project.getArtifact().getFile();
- copyToLib(projectLib);
-
- if (libList != null)
- {
- for (int i = 0; i < libList.length; i++)
- {
- String[] splitString = libList[i].split(":");
-
- getLog().info("********************" + splitString[0] + "/" + splitString[1] + "/" + splitString[2]);
-
- Artifact artifact;
- try
- {
- artifact = new DefaultArtifact(libList[i]);
- }
- catch (IllegalArgumentException e)
- {
- throw new MojoFailureException(e.getMessage(), e);
- }
-
- ArtifactRequest request = new ArtifactRequest();
- request.setArtifact(artifact);
- request.setRepositories(remoteRepos);
-
- getLog().info("Resolving artifact " + artifact + " from " + remoteRepos);
-
- ArtifactResult result;
- try
- {
- result = repositorySystem.resolveArtifact(repoSession, request);
- }
- catch (ArtifactResolutionException e)
- {
- throw new MojoExecutionException(e.getMessage(), e);
- }
-
- File artifactFile = result.getArtifact().getFile();
-
- getLog().info("Artifact:: " + artifact + " file = " + artifactFile);
-
- copyToLib(artifactFile);
-
- }
- }
-
- }
- catch (Exception e)
- {
- getLog().error(e);
- throw new MojoFailureException(e.getMessage());
- }
- }
-
- private void copyToLib(File projectLib) throws IOException
- {
- Path target = instance.toPath().resolve("lib").resolve(projectLib.getName());
- target.toFile().mkdirs();
- getLog().info("Copying " + projectLib.getName() + " as " + target.toFile().getAbsolutePath());
- Files.copy(projectLib.toPath(), target, StandardCopyOption.REPLACE_EXISTING);
- }
-}
diff --git a/docs/user-manual/en/using-server.md b/docs/user-manual/en/using-server.md
index 2fa214d5e3..9a59c29037 100644
--- a/docs/user-manual/en/using-server.md
+++ b/docs/user-manual/en/using-server.md
@@ -93,7 +93,7 @@ For a full list of updated properties always use:
[--clustered] [--data ] [--encoding ] [--force]
[--home ] [--host ] [--java-options ]
[--password ] [--port-offset ] [--replicated]
- [--role ] [--shared-store] [--silent-input] [--user ] [--]
+ [--role ] [--shared-store] [--silent] [--user ] [--]
OPTIONS
@@ -143,7 +143,7 @@ For a full list of updated properties always use:
--shared-store
Enable broker shared store
- --silent-input
+ --silent
It will disable all the inputs, and it would make a best guess for
any required input
diff --git a/examples/core/embedded/pom.xml b/examples/core/embedded/pom.xml
index 8453105cf4..ebe5254308 100644
--- a/examples/core/embedded/pom.xml
+++ b/examples/core/embedded/pom.xml
@@ -61,9 +61,6 @@ under the License.
-
-
- example
@@ -84,6 +81,4 @@ under the License.
-
-
diff --git a/examples/core/embedded/readme.html b/examples/core/embedded/readme.html
index c5c21418ba..d65caa220c 100644
--- a/examples/core/embedded/readme.html
+++ b/examples/core/embedded/readme.html
@@ -38,7 +38,7 @@ under the License.
ActiveMQ Artemis Embedded could be used from very simple use cases with only InVM support to very complex cases with clustering, persistence and fail over.
Example step-by-step
- To run the example, simply type mvn verify -Pexample
from this directory
+ To run the example, simply type mvn verify
from this directory
In this we don't use any configuration files. (Everything is embedded). We simply instantiate ConfigurationImpl, ActiveMQServer, start it and operate on JMS regularly
diff --git a/examples/core/perf/src/main/resources/activemq/server0/broker.xml b/examples/core/perf/src/main/resources/activemq/server0/broker.xml
index 8876d42c49..6e787fb84d 100644
--- a/examples/core/perf/src/main/resources/activemq/server0/broker.xml
+++ b/examples/core/perf/src/main/resources/activemq/server0/broker.xml
@@ -23,13 +23,13 @@ under the License.
xsi:schemaLocation="urn:activemq /schema/artemis-server.xsd">
- ${data.dir:./data}/bindings
+ ./data/bindings
- ${data.dir:./data}/journal
+ ./data/journal
- ${data.dir:./data}/largemessages
+ ./data/largemessages
- ${data.dir:./data}/paging
+ ./data/paging
diff --git a/examples/core/pom.xml b/examples/core/pom.xml
index c88656e855..fd3ba183e8 100644
--- a/examples/core/pom.xml
+++ b/examples/core/pom.xml
@@ -39,7 +39,8 @@ under the License.
- release
+
+ examples
embedded
embedded-remote
diff --git a/examples/jms/README.md b/examples/jms/README.md
index f0cd2af3ef..e9d9e36112 100644
--- a/examples/jms/README.md
+++ b/examples/jms/README.md
@@ -3,22 +3,25 @@ Running the ActiveMQ Artemis Examples
To run an individual example firstly cd into the example directory and run
+```sh
+mvn verify
```
-mvn verify -Pexample
+
+Most examples offer a way to start them without creating and starting the server (say if you want to do it manually)
+
+```sh
+mvn verify -PnoServer
```
If you are running against an un released version, i.e. from master branch, you will have to run `mvn install` on the root
pom.xml and the example/activemq-jms-examples-common/pom.xml first.
-If you want to run all the examples (except those that need to be run standalone) you can run `mvn verify -Pexample` in the examples
+If you want to run all the examples (except those that need to be run standalone) you can run `mvn verify -Pexamples` in the examples
directory but before you do you will need to up the memory used by running:
```
export MAVEN_OPTS="-Xmx1024m -XX:MaxPermSize=256m"
```
-
-To run the javaee examples follow the instructions in examples/javaee/README.md
-
### Recreating the examples
If you are trying to copy the examples somewhere else and modifying them. Consider asking Maven to explicitly list all the dependencies:
diff --git a/examples/jms/aerogear/pom.xml b/examples/jms/aerogear/pom.xml
index a42a6e889c..fc224d623a 100644
--- a/examples/jms/aerogear/pom.xml
+++ b/examples/jms/aerogear/pom.xml
@@ -18,7 +18,8 @@ specific language governing permissions and limitations
under the License.
-->
-
+
4.0.0
@@ -34,7 +35,7 @@ under the License.
${project.basedir}/../../..
- artemis-jms-aerogear-example
+ aerogear
jar
ActiveMQ Artemis JMS AeroGear Example
@@ -48,80 +49,86 @@ under the License.
- example
-
-
-
- org.apache.activemq
- artemis-maven-plugin
-
-
- create
-
- create
-
-
-
-
-
- org.apache.activemq:artemis-aerogear-integration:${project.version}
- org.jboss.aerogear:unifiedpush-java-client:1.0.0
- net.iharder:base64:2.3.8
- com.fasterxml.jackson.core:jackson-annotations:2.3.0
- com.fasterxml.jackson.core:jackson-core:2.3.0
- org.jboss.resteasy:resteasy-jackson-provider:2.3.2.Final
- org.codehaus.jackson:jackson-core-asl:1.8.5
- org.codehaus.jackson:jackson-mapper-asl:1.8.5
- org.codehaus.jackson:jackson-jaxrs:1.8.5
- org.codehaus.jackson:jackson-xc:1.8.5
-
-
-
-
- start
-
- cli
-
-
- true
- tcp://localhost:61616
-
- run
-
-
-
-
- runClient
-
- runClient
-
-
- org.apache.activemq.artemis.jms.example.AerogearExample
-
-
-
- stop
-
- cli
-
-
-
- stop
-
-
-
-
-
-
- org.apache.activemq.examples.jms
- artemis-jms-aerogear-example
- ${project.version}
-
-
-
-
-
+
+ noServer
+
+ true
+
+
+
+
+ org.apache.activemq
+ artemis-maven-plugin
+
+
+ create
+
+ create
+
+
+ ${noServer}
+
+
+ org.apache.activemq:artemis-aerogear-integration:${project.version}
+ org.jboss.aerogear:unifiedpush-java-client:1.0.0
+ net.iharder:base64:2.3.8
+ com.fasterxml.jackson.core:jackson-annotations:2.3.0
+ com.fasterxml.jackson.core:jackson-core:2.3.0
+ org.jboss.resteasy:resteasy-jackson-provider:2.3.2.Final
+ org.codehaus.jackson:jackson-core-asl:1.8.5
+ org.codehaus.jackson:jackson-mapper-asl:1.8.5
+ org.codehaus.jackson:jackson-jaxrs:1.8.5
+ org.codehaus.jackson:jackson-xc:1.8.5
+
+
+
+
+ start
+
+ cli
+
+
+ ${noServer}
+ true
+ tcp://localhost:61616
+
+ run
+
+
+
+
+ runClient
+
+ runClient
+
+
+ org.apache.activemq.artemis.jms.example.AerogearExample
+
+
+
+ stop
+
+ cli
+
+
+ ${noServer}
+
+ stop
+
+
+
+
+
+
+ org.apache.activemq.examples.jms
+ aerogear
+ ${project.version}
+
+
+
+
+
diff --git a/examples/jms/aerogear/readme.html b/examples/jms/aerogear/readme.html
index 661b7d14f5..bdddfa65c3 100644
--- a/examples/jms/aerogear/readme.html
+++ b/examples/jms/aerogear/readme.html
@@ -27,6 +27,9 @@ under the License.
JMS AeroGear Example
+
+ To run the example, simply type mvn verify from this directory,
or mvn -PnoServer verify if you want to start and create the server manually.
+
This example shows how you can send a message to a mobile device by leveraging AeroGears push technology which
provides support for different push notification technologies like Google Cloud Messaging, Apple's APNs or
Mozilla's SimplePush.
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 5c389c8ac5..1095761a10 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/bindings
- ${data.dir:./data}/journal
+ ./data/journal
- ${data.dir:./data}/largemessages
+ ./data/largemessages
- ${data.dir:./data}/paging
+ ./data/paging
diff --git a/examples/jms/application-layer-failover/pom.xml b/examples/jms/application-layer-failover/pom.xml
index 65d217d75a..b670d1858c 100644
--- a/examples/jms/application-layer-failover/pom.xml
+++ b/examples/jms/application-layer-failover/pom.xml
@@ -18,7 +18,8 @@ specific language governing permissions and limitations
under the License.
-->
-
+
4.0.0
@@ -27,7 +28,7 @@ under the License.
1.0.1-SNAPSHOT
- artemis-jms-application-layer-failover-example
+ application-layer-failover
jar
ActiveMQ Artemis JMS Application Layer Failover Example
@@ -42,64 +43,60 @@ under the License.
${project.version}
- org.apache.geronimo.specs
- geronimo-jms_2.0_spec
+ org.apache.activemq
+ artemis-jms-client
+ ${project.version}
-
-
- example
-
-
-
- org.apache.activemq
- artemis-maven-plugin
-
-
- create0
-
- create
-
-
- ${basedir}/target/server0
-
-
-
- create1
-
- create
-
-
- ${basedir}/target/server1
- 1
-
-
-
- runClient
-
- runClient
-
-
- org.apache.activemq.artemis.jms.example.ApplicationLayerFailoverExample
-
- ${basedir}/target/server0
- ${basedir}/target/server1
-
-
-
-
-
-
- org.apache.activemq.examples.jms
- artemis-jms-application-layer-failover-example
- ${project.version}
-
-
-
-
-
-
-
+
+
+
+ org.apache.activemq
+ artemis-maven-plugin
+
+
+ create0
+
+ create
+
+
+ ${basedir}/target/server0
+
+
+
+ create1
+
+ create
+
+
+ ${basedir}/target/server1
+ 1
+
+
+
+ runClient
+
+ runClient
+
+
+ org.apache.activemq.artemis.jms.example.ApplicationLayerFailoverExample
+
+ ${basedir}/target/server0
+ ${basedir}/target/server1
+
+
+
+
+
+
+ org.apache.activemq.examples.jms
+ application-layer-failover
+ ${project.version}
+
+
+
+
+
diff --git a/examples/jms/application-layer-failover/readme.html b/examples/jms/application-layer-failover/readme.html
index b9699bc7dd..3a23b62926 100644
--- a/examples/jms/application-layer-failover/readme.html
+++ b/examples/jms/application-layer-failover/readme.html
@@ -27,6 +27,8 @@ under the License.
Application-Layer Failover Example
+ To run the example, simply type mvn verify from this directory. This example will always spawn and stop multiple servers.
+
ActiveMQ Artemis implements fully transparent automatic failover of connections from a live node to a backup node which requires
no special coding. This is described in a different example and requires server replication.
However, ActiveMQ Artemis also supports Application-Layer failover which is useful in the case where replication is not enabled.
@@ -37,12 +39,11 @@ under the License.
Application-Layer failover is an alternative approach to High Availabilty (HA).
Application-Layer failover differs from automatic failover in that some client side coding is required in order
to implement this. Also, with Application-Layer failover, since the old Session object dies and a new is created, any uncommitted
- work in the old Session will be lost, and any unacknowledged messages might be redelivered.
+ work in the old Session will be lost, and any unacknowledged messages might be redelivered.
For more information on ActiveMQ Artemis failover and HA, and clustering in general, please see the clustering
- section of the user manual.
+ section of the user manual.
Example step-by-step
- To run the example, simply type mvn verify -Pexample
from this directory
In this example, the live server is server 1, which will failover onto server 0.
The connection will initially be created to server1, server 1 will crash, and the client will carry on
on server 0, the new server. With Application-Layer failover the node that is failed over onto, does not need to
@@ -87,13 +88,13 @@ under the License.
}
-
+
We now cause server 1, the live server to crash. After a little while the connection's
ExceptionListener will register the failure and reconnection will occur.
killServer(1);
-
+
The connection's ExceptionListener gets called, and we lookup the JMS objects and
recreate the connection, session, etc on the other node 0.
@@ -121,7 +122,7 @@ under the License.
e.printStackTrace();
}
}
- }
+ }
@@ -138,7 +139,7 @@ under the License.
}
-
+
And consume them.
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 fcd3ccaaaf..86a23390e0 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,14 +16,6 @@
*/
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;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-
import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.jms.ExceptionListener;
@@ -35,6 +27,11 @@ import javax.jms.Session;
import javax.jms.TextMessage;
import javax.naming.InitialContext;
import javax.naming.NamingException;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory;
+import org.apache.activemq.artemis.util.ServerUtil;
/**
* A simple example that demonstrates application-layer failover of the JMS connection from one node to another
@@ -144,32 +141,25 @@ public class ApplicationLayerFailoverExample
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();
- properties.put("java.naming.factory.initial", "org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory");
- properties.put("connectionFactory.ConnectionFactory", "tcp://127.0.0.1:" + (61616 + server));
- properties.put("queue.queue/exampleQueue", "exampleQueue");
- initialContext = new InitialContext(properties);
+ // Step 1. Instantiate a JMS Connection Factory object from JNDI on server 1
+ ConnectionFactory connectionFactory = new ActiveMQConnectionFactory("tcp://127.0.0.1:" + (61616 + server));
- // Step 2. Look-up the JMS Queue object from JNDI
- Queue queue = (Queue)initialContext.lookup("queue/exampleQueue");
-
- // Step 3. Look-up a JMS Connection Factory object from JNDI on server 1
- ConnectionFactory connectionFactory = (ConnectionFactory)initialContext.lookup("ConnectionFactory");
-
- // Step 4. We create a JMS Connection connection
+ // Step 2. We create a JMS Connection connection
connection = connectionFactory.createConnection();
- // Step 6. We start the connection to ensure delivery occurs
+ // Step 3. We start the connection to ensure delivery occurs
connection.start();
- // Step 5. We create a JMS Session
+ // Step 4. We create a JMS Session
session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
- // Step 7. We create a JMS MessageConsumer object
+ // Step 5. Look-up the JMS Queue object from JNDI
+ Queue queue = session.createQueue("exampleQueue");
+
+ // Step 6. We create a JMS MessageConsumer object
consumer = session.createConsumer(queue);
- // Step 8. We create a JMS MessageProducer object
+ // Step 7. We create a JMS MessageProducer object
producer = session.createProducer(queue);
}
diff --git a/examples/jms/bridge/pom.xml b/examples/jms/bridge/pom.xml
index 73cbdc56d9..8c835de0cf 100644
--- a/examples/jms/bridge/pom.xml
+++ b/examples/jms/bridge/pom.xml
@@ -18,7 +18,8 @@ specific language governing permissions and limitations
under the License.
-->
-
+
4.0.0
@@ -27,7 +28,7 @@ under the License.
1.0.1-SNAPSHOT
- artemis-jms-core-bridge-example
+ core-bridge
jar
ActiveMQ Artemis Core Bridge Example
@@ -49,109 +50,127 @@ under the License.
- example
-
-
-
- org.apache.activemq
- artemis-maven-plugin
-
-
- create0
-
- create
-
-
- ${basedir}/target/server0
- ${basedir}/target/classes/activemq/server0
-
-
-
- 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
-
-
-
- runClient
-
- runClient
-
-
- org.apache.activemq.artemis.jms.example.BridgeExample
-
-
-
- stop0
-
- cli
-
-
- ${basedir}/target/server0
-
- stop
-
-
-
-
- stop1
-
- cli
-
-
- ${basedir}/target/server1
-
- stop
-
-
-
-
-
-
- org.apache.activemq.examples.jms
- artemis-jms-core-bridge-example
- ${project.version}
-
-
-
-
-
+
+ noServer
+
+ true
+
+
+
+
+ org.apache.activemq
+ artemis-maven-plugin
+
+
+ create0
+
+ create
+
+
+
+
+ org.apache.activemq.examples.jms:core-bridge:${project.version}
+
+ ${noServer}
+ ${basedir}/target/server0
+ ${basedir}/target/classes/activemq/server0
+
+
+
+ create1
+
+ create
+
+
+
+
+ org.apache.activemq.examples.jms:core-bridge:${project.version}
+
+ ${noServer}
+ ${basedir}/target/server1
+ ${basedir}/target/classes/activemq/server1
+ 1
+
+
+
+ start0
+
+ cli
+
+
+ ${noServer}
+ true
+ ${basedir}/target/server0
+ tcp://localhost:61616
+
+ run
+
+ server0
+
+
+
+ start1
+
+ cli
+
+
+ ${noServer}
+ true
+ ${basedir}/target/server1
+ tcp://localhost:61617
+
+ run
+
+ server1
+
+
+
+ runClient
+
+ runClient
+
+
+ org.apache.activemq.artemis.jms.example.BridgeExample
+
+
+
+ stop0
+
+ cli
+
+
+ ${noServer}
+ ${basedir}/target/server0
+
+ stop
+
+
+
+
+ stop1
+
+ cli
+
+
+ ${noServer}
+ ${basedir}/target/server1
+
+ stop
+
+
+
+
+
+
+ org.apache.activemq.examples.jms
+ core-bridge
+ ${project.version}
+
+
+
+
+
diff --git a/examples/jms/bridge/readme.html b/examples/jms/bridge/readme.html
index 6b5bb01c03..a9440c792f 100644
--- a/examples/jms/bridge/readme.html
+++ b/examples/jms/bridge/readme.html
@@ -26,6 +26,7 @@ under the License.
Core Bridge Example
+ To run the example, simply type mvn verify from this directory,
or mvn -PnoServer verify if you want to start and create the server manually.
This example demonstrates a core bridge deployed on one server, which consumes messages from a
local queue and forwards them to an address on a second server.
@@ -69,166 +70,5 @@ under the License.
</bridge>
- Example step-by-step
- To run the example, simply type mvn verify -Pexample
from this directory
-
-
- - We create an initial context for looking up JNDI on node 0
-
-
- ic0 = getContext(0);
-
-
-
- - We look up the sausage-factory queue from node 0
-
- Queue sausageFactory = (Queue)ic0.lookup("/queue/sausage-factory");
-
-
- - We look up a JMS ConnectionFactory object from node 0
-
- ConnectionFactory cf0 = (ConnectionFactory)ic0.lookup("/ConnectionFactory");
-
-
- - We create an initial context for looking up JNDI on node 1
-
- ic1 = getContext(1);
-
-
- - We look up the mincing-machine queue on node 1
-
- Queue mincingMachine = (Queue)ic1.lookup("/queue/mincing-machine");
-
-
-
- - We look up a JMS ConnectionFactory object from node 1
-
-
- ConnectionFactory cf1 = (ConnectionFactory)ic1.lookup("/ConnectionFactory");
-
-
-
- - We create a JMS Connection connection0 which is a connection to server 0
-
-
- connection0 = cf0.createConnection();
-
-
-
- - We create a JMS Connection connection1 which is a connection to server 1
-
-
- connection1 = cf1.createConnection();
-
-
-
- - We create a JMS Session on server 0
-
-
- Session session0 = connection0.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
-
-
- - We create a JMS Session on server 1
-
-
- Session session1 = connection1.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
-
-
- - We start the connection to ensure delivery occurs on them
-
-
- connection1.start();
-
-
-
- - We create a JMS MessageConsumer object on server 1
-
-
- MessageConsumer consumer = session1.createConsumer(mincingMachine);
-
-
-
- - We create a JMS MessageProducer object on server 0.
-
-
- MessageProducer producer = session0.createProducer(sausageFactory);
-
-
- - We create and send a message representing an aardvark with a green hat to the sausage-factory
- on node 0
-
-
- Message message = session0.createMessage();
-
- message.setStringProperty("name", "aardvark");
-
- message.setStringProperty("hat", "green");
-
- producer.send(message);
-
-
-
- - 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!
-
-
- Message receivedMessage = consumer.receive(5000);
-
-
-
- - 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 sasquatches.
-
-
- message = session0.createMessage();
-
- message.setStringProperty("name", "sasquatch");
-
- message.setStringProperty("hat", "mauve");
-
- producer.send(message);
-
-
-
- - We don't receive the sasquatch message since it's not an aardvark!
-
-
- receivedMessage = (TextMessage)consumer.receive(1000);
-
-
-
-
- - And finally (no pun intended), always remember to close your JMS resources after use, in a
finally
block. Closing a JMS connection will automatically close all of its sessions, consumers, producer and browser objects
-
-
-
- finally
- {
- if (connection0 != null)
- {
- connection0.close();
- }
-
- if (connection1 != null)
- {
- connection1.close();
- }
-
- if (ic0 != null)
- {
- ic0.close();
- }
-
- if (ic1 != null)
- {
- ic1.close();
- }
- }
-
-
-
-
diff --git a/examples/jms/browser/pom.xml b/examples/jms/browser/pom.xml
index adaf22266d..8cbd2d7392 100644
--- a/examples/jms/browser/pom.xml
+++ b/examples/jms/browser/pom.xml
@@ -18,7 +18,8 @@ specific language governing permissions and limitations
under the License.
-->
-
+
4.0.0
@@ -27,7 +28,7 @@ under the License.
1.0.1-SNAPSHOT
- artemis-jms-browser-example
+ browser
jar
ActiveMQ Artemis JMS Browser Example
@@ -37,72 +38,82 @@ under the License.
- org.apache.geronimo.specs
- geronimo-jms_2.0_spec
+ org.apache.activemq
+ artemis-jms-client
+ ${project.version}
- example
-
-
-
- org.apache.activemq
- artemis-maven-plugin
-
-
- create
- verify
-
- create
-
-
-
- start
-
- cli
-
-
- true
- tcp://localhost:61616
-
- run
-
-
-
-
- runClient
-
- runClient
-
-
- org.apache.activemq.artemis.jms.example.QueueBrowserExample
-
-
-
- stop
-
- cli
-
-
-
- stop
-
-
-
-
-
-
- org.apache.activemq.examples.jms
- artemis-jms-browser-example
- ${project.version}
-
-
-
-
-
+
+ noServer
+
+ true
+
+
+
+
+ org.apache.activemq
+ artemis-maven-plugin
+
+
+ create
+ verify
+
+ ${noServer}
+
+
+ create
+
+
+
+ start
+
+ cli
+
+
+ true
+ ${noServer}
+ tcp://localhost:61616
+
+ run
+
+
+
+
+ runClient
+
+ runClient
+
+
+ org.apache.activemq.artemis.jms.example.QueueBrowserExample
+
+
+
+ stop
+
+ cli
+
+
+ ${noServer}
+
+ stop
+
+
+
+
+
+
+ org.apache.activemq.examples.jms
+ browser
+ ${project.version}
+
+
+
+
+
diff --git a/examples/jms/browser/readme.html b/examples/jms/browser/readme.html
index b960ff4115..76f349f97e 100644
--- a/examples/jms/browser/readme.html
+++ b/examples/jms/browser/readme.html
@@ -26,122 +26,15 @@ under the License.
JMS QueueBrowser Example
+ To run the example, simply type mvn verify from this directory,
or mvn -PnoServer verify if you want to start and create the server manually.
This example shows you how to use a JMS QueueBrowser with ActiveMQ Artemis.
Queues are a standard part of JMS, please consult the JMS 1.1 specification for full details.
- A QueueBrowser is used to look at messages on the queue without removing them.
+ A QueueBrowser is used to look at messages on the queue without removing them.
It can scan the entire content of a queue or only messages matching a message selector.
- The example will send 2 messages on a queue, use a QueueBrowser to browse
+ The example will send 2 messages on a queue, use a QueueBrowser to browse
the queue (looking at the message without removing them) and finally consume the 2 messages
- Example step-by-step
- To run the example, simply type mvn verify -Pexample
from this directory
-
-
- - First we need to get an initial context so we can look-up the JMS connection factory and destination objects from JNDI. This initial context will get it's properties from the
client-jndi.properties
file in the directory ../common/config
-
- InitialContext initialContext = getContext();
-
-
- - We look up the JMS queue object from JNDI
-
- Queue queue = (Queue) initialContext.lookup("/queue/exampleQueue");
-
-
- - We look up the JMS connection factory object from JNDI
-
- ConnectionFactory cf = (ConnectionFactory) initialContext.lookup("/ConnectionFactory");
-
-
- - We create a JMS connection
-
- connection = cf.createConnection();
-
-
- - We create a JMS session. The session is created as non transacted and will auto acknowledge messages.
-
- Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
-
- - We create a JMS message producer on the session. This will be used to send the messages.
-
- MessageProducer messageProducer = session.createProducer(topic);
-
-
- - We create 2 JMS text messages that we are going to send.
-
- TextMessage message_1 = session.createTextMessage("this is the 1st message");
- TextMessage message_2 = session.createTextMessage("this is the 2nd message");
-
-
- - We send messages to the queue
-
- messageProducer.send(message_1);
- messageProducer.send(message_2);
-
-
- - We create a JMS QueueBrowser.
- We have not specified a message selector so the browser will enumerate the entire content of the queue.
-
-
- QueueBrowser browser = session.createBrowser(queue);
-
-
- - We browse the queue and display all the messages' text
-
-
- Enumeration messageEnum = browser.getEnumeration();
- while (messageEnum.hasMoreElements())
- {
- TextMessage message = (TextMessage)messageEnum.nextElement();
- System.out.println("Browsing: " + message.getText());
- }
-
-
- - We close the browser once we have finished to use it
-
- browser.close();
-
-
- The messages were browsed but they were not removed from the queue. We will now consume them.
-
- - We create a JMS Message Consumer to receive the messages.
-
- MessageConsumer messageConsumer = session.createConsumer(queue);
-
-
- - We start the connection. In order for delivery to occur on any consumers or subscribers on a connection, the connection must be started
-
- connection.start();
-
-
- - The 2 messages arrive at the consumer
-
- TextMessage messageReceived = (TextMessage)messageConsumer.receive(5000);
- System.out.println("Received message: " + messageReceived.getText());
- messageReceived = (TextMessage)messageConsumer.receive(5000);
- System.out.println("Received message: " + messageReceived.getText());
-
-
- - And finally, always remember to close your JMS connections and resources after use, in a
finally
block. Closing a JMS connection will automatically close all of its sessions, consumers, producer and browser objects
-
-
- finally
- {
- if (initialContext != null)
- {
- initialContext.close();
- }
- if (connection != null)
- {
- connection.close();
- }
- }
-
-
-
-
-