http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/21bf4406/examples/core/embedded-remote/pom.xml ---------------------------------------------------------------------- diff --git a/examples/core/embedded-remote/pom.xml b/examples/core/embedded-remote/pom.xml deleted file mode 100644 index 7ba7d7a..0000000 --- a/examples/core/embedded-remote/pom.xml +++ /dev/null @@ -1,126 +0,0 @@ -<?xml version='1.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. ---> - -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> - <modelVersion>4.0.0</modelVersion> - - <parent> - <groupId>org.apache.activemq.examples.core</groupId> - <artifactId>core-examples</artifactId> - <version>1.0.1-SNAPSHOT</version> - </parent> - - <artifactId>artemis-core-embedded-remote-example</artifactId> - <packaging>jar</packaging> - <name>ActiveMQ Artemis Core Embedded Remote Example</name> - - <properties> - <activemq.basedir>${project.basedir}/../../..</activemq.basedir> - </properties> - - <dependencies> - <dependency> - <groupId>org.apache.activemq</groupId> - <artifactId>artemis-core-client</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.apache.activemq</groupId> - <artifactId>artemis-commons</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.apache.activemq</groupId> - <artifactId>artemis-server</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>io.netty</groupId> - <artifactId>netty-all</artifactId> - </dependency> - <dependency> - <groupId>org.apache.geronimo.specs</groupId> - <artifactId>geronimo-jms_2.0_spec</artifactId> - </dependency> - </dependencies> - - <profiles> - <profile> - <id>server</id> - <dependencies> - <dependency> - <groupId>org.apache.activemq</groupId> - <artifactId>artemis-server</artifactId> - <version>${project.version}</version> - </dependency> - </dependencies> - <build> - <plugins> - <plugin> - <groupId>org.codehaus.mojo</groupId> - <artifactId>exec-maven-plugin</artifactId> - <version>1.1</version> - <executions> - <execution> - <phase>package</phase> - <goals> - <goal>java</goal> - </goals> - </execution> - </executions> - <configuration> - <mainClass>org.apache.activemq.artemis.core.example.EmbeddedServer</mainClass> - </configuration> - </plugin> - </plugins> - </build> - </profile> - <profile> - <id>client</id> - <dependencies> - <dependency> - <groupId>org.apache.activemq</groupId> - <artifactId>artemis-core-client</artifactId> - <version>${project.version}</version> - </dependency> - </dependencies> - <build> - <plugins> - <plugin> - <groupId>org.codehaus.mojo</groupId> - <artifactId>exec-maven-plugin</artifactId> - <version>1.1</version> - <executions> - <execution> - <phase>package</phase> - <goals> - <goal>java</goal> - </goals> - </execution> - </executions> - <configuration> - <mainClass>org.apache.activemq.artemis.core.example.EmbeddedRemoteExample</mainClass> - </configuration> - </plugin> - </plugins> - </build> - </profile> - </profiles> -</project>
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/21bf4406/examples/core/embedded-remote/readme.html ---------------------------------------------------------------------- diff --git a/examples/core/embedded-remote/readme.html b/examples/core/embedded-remote/readme.html deleted file mode 100644 index 4e389ad..0000000 --- a/examples/core/embedded-remote/readme.html +++ /dev/null @@ -1,104 +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. ---> - -<html> - <head> - <title>ActiveMQ Artemis Embedded Example</title> - <link rel="stylesheet" type="text/css" href="../../common/common.css" /> - <link rel="stylesheet" type="text/css" href="../../common/prettify.css" /> - <script type="text/javascript" src="../../common/prettify.js"></script> - </head> - <body onload="prettyPrint()"> - <h1>Embedded Example</h1> - <p>This example shows how to setup and run ActiveMQ Artemis embedded with remote clients connecting.</p> - <p>ActiveMQ Artemis was designed to use POJOs (Plain Old Java Objects), what makes embedding ActiveMQ Artemis as simple as instantiating a few objects.</p> - - <p>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.</p> - - - <h2>Example step-by-step</h2> - <p><i>To run the example, simply type <code>mvn verify -Pserver</code> from this directory to start the server and <code>mvn verify -Pclient</code> to run the client example</i></p> - <p>In this we don't use any configuration files. (Everything is embedded). We simply instantiate ConfigurationImpl, ActiveMQServer, start it and operate on JMS regularly</p> - <br/> - <ol> - <li>On EmbeddedServer: Create the Configuration, and set the properties accordingly</li> - <pre class="prettyprint"> - Configuration configuration = new ConfigurationImpl(); - configuration.setEnablePersistence(false); - configuration.setSecurityEnabled(false); - </pre> - - <li>On EmbeddedServer: Create and start the server</li> - <pre class="prettyprint"> - ActiveMQServer server = ActiveMQ.newActiveMQServer(configuration); - server.start(); - </pre> - - <li>As we are not using a JNDI environment we instantiate the objects directly</li> - <pre class="prettyprint"> - ServerLocator serverLocator = ActiveMQClient.createServerLocatorWithoutHA(new TransportConfiguration(NettyConnectorFactory.class.getName())); - ClientSessionFactory sf = serverLocator.createSessionFactory(); - </pre> - - <li>Create a Core Queue</li> - <pre class="prettyprint"> - ClientSession coreSession = sf.createSession(false, false, false); - final String queueName = "queue.exampleQueue"; - coreSession.createQueue(queueName, queueName, true); - coreSession.close(); - </pre> - - <li>Create the session and producer</li> - <pre class="prettyprint"> - session = sf.createSession(); - - ClientProducer producer = session.createProducer(queueName); - </pre> - - <li>Create and send a Message</li> - <pre class="prettyprint"> - ClientMessage message = session.createMessage(false); - message.putStringProperty(propName, "Hello sent at " + new Date()); - System.out.println("Sending the message."); - producer.send(message); - </pre> - - <li>Create the message consumer and start the connection</li> - <pre class="prettyprint"> - ClientConsumer messageConsumer = session.createConsumer(queueName); - session.start(); - </pre> - - <li>Receive the message</li> - <pre class="prettyprint"> - ClientMessage messageReceived = messageConsumer.receive(1000); - System.out.println("Received TextMessage:" + messageReceived.getProperty(propName)); - </pre> - - <li>Be sure to close our resources!</li> - - <pre class="prettyprint"> - if (sf != null) - { - sf.close(); - } - </pre> - </ol> - </body> -</html> http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/21bf4406/examples/core/embedded-remote/src/main/java/org/apache/activemq/artemis/core/example/EmbeddedRemoteExample.java ---------------------------------------------------------------------- diff --git a/examples/core/embedded-remote/src/main/java/org/apache/activemq/artemis/core/example/EmbeddedRemoteExample.java b/examples/core/embedded-remote/src/main/java/org/apache/activemq/artemis/core/example/EmbeddedRemoteExample.java deleted file mode 100644 index cec295a..0000000 --- a/examples/core/embedded-remote/src/main/java/org/apache/activemq/artemis/core/example/EmbeddedRemoteExample.java +++ /dev/null @@ -1,104 +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.core.example; - -import java.util.Date; -import java.util.HashMap; -import java.util.Map; - -import org.apache.activemq.artemis.api.core.TransportConfiguration; -import org.apache.activemq.artemis.api.core.client.ClientConsumer; -import org.apache.activemq.artemis.api.core.client.ClientMessage; -import org.apache.activemq.artemis.api.core.client.ClientProducer; -import org.apache.activemq.artemis.api.core.client.ClientSession; -import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; -import org.apache.activemq.artemis.api.core.client.ActiveMQClient; -import org.apache.activemq.artemis.api.core.client.ServerLocator; -import org.apache.activemq.artemis.core.remoting.impl.netty.NettyConnectorFactory; - -/** - * This example shows how to run an ActiveMQ Artemis core client and server embedded in your - * own application - */ -public class EmbeddedRemoteExample { - - public static void main(final String[] args) { - try { - // Step 3. As we are not using a JNDI environment we instantiate the objects directly - - /** - * this map with configuration values is not necessary (it configures the default values). - * If you modify it to run the example in two different hosts, remember to also modify the - * server's Acceptor at {@link EmbeddedServer} - */ - Map<String, Object> map = new HashMap<String, Object>(); - map.put("host", "localhost"); - map.put("port", 61616); - // ------------------------------------------------------- - - ServerLocator serverLocator = ActiveMQClient.createServerLocatorWithoutHA(new TransportConfiguration(NettyConnectorFactory.class.getName(), map)); - ClientSessionFactory sf = serverLocator.createSessionFactory(); - - // Step 4. Create a core queue - ClientSession coreSession = sf.createSession(false, false, false); - - final String queueName = "queue.exampleQueue"; - - coreSession.createQueue(queueName, queueName, true); - - coreSession.close(); - - ClientSession session = null; - - try { - - // Step 5. Create the session, and producer - session = sf.createSession(); - - ClientProducer producer = session.createProducer(queueName); - - // Step 6. Create and send a message - ClientMessage message = session.createMessage(false); - - final String propName = "myprop"; - - message.putStringProperty(propName, "Hello sent at " + new Date()); - - System.out.println("Sending the message."); - - producer.send(message); - - // Step 7. Create the message consumer and start the connection - ClientConsumer messageConsumer = session.createConsumer(queueName); - session.start(); - - // Step 8. Receive the message. - ClientMessage messageReceived = messageConsumer.receive(1000); - System.out.println("Received TextMessage:" + messageReceived.getStringProperty(propName)); - } - finally { - // Step 9. Be sure to close our resources! - if (sf != null) { - sf.close(); - } - } - } - catch (Exception e) { - e.printStackTrace(); - } - } -} http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/21bf4406/examples/core/embedded-remote/src/main/java/org/apache/activemq/artemis/core/example/EmbeddedServer.java ---------------------------------------------------------------------- diff --git a/examples/core/embedded-remote/src/main/java/org/apache/activemq/artemis/core/example/EmbeddedServer.java b/examples/core/embedded-remote/src/main/java/org/apache/activemq/artemis/core/example/EmbeddedServer.java deleted file mode 100644 index 16993f7..0000000 --- a/examples/core/embedded-remote/src/main/java/org/apache/activemq/artemis/core/example/EmbeddedServer.java +++ /dev/null @@ -1,68 +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.core.example; - -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; - -import org.apache.activemq.artemis.api.core.TransportConfiguration; -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; -import org.apache.activemq.artemis.core.server.ActiveMQServer; -import org.apache.activemq.artemis.core.server.ActiveMQServers; - -/** - * An EmbeddedServer - */ -public class EmbeddedServer { - - public static void main(final String arg[]) throws Exception { - try { - // Step 1. Create the Configuration, and set the properties accordingly - Configuration configuration = new ConfigurationImpl(); - //we only need this for the server lock file - configuration.setJournalDirectory("target/data/journal"); - configuration.setPersistenceEnabled(false); - configuration.setSecurityEnabled(false); - /** - * this map with configuration values is not necessary (it configures the default values). - * If you want to modify it to run the example in two different hosts, remember to also - * modify the client's Connector at {@link EmbeddedRemoteExample}. - */ - Map<String, Object> map = new HashMap<String, Object>(); - map.put("host", "localhost"); - map.put("port", 61616); - - TransportConfiguration transpConf = new TransportConfiguration(NettyAcceptorFactory.class.getName(), map); - - HashSet<TransportConfiguration> setTransp = new HashSet<TransportConfiguration>(); - setTransp.add(transpConf); - - configuration.setAcceptorConfigurations(setTransp); - - // Step 2. Create and start the server - ActiveMQServer server = ActiveMQServers.newActiveMQServer(configuration); - server.start(); - } - catch (Exception e) { - e.printStackTrace(); - throw e; - } - } -} http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/21bf4406/examples/core/embedded/pom.xml ---------------------------------------------------------------------- diff --git a/examples/core/embedded/pom.xml b/examples/core/embedded/pom.xml deleted file mode 100644 index ebe5254..0000000 --- a/examples/core/embedded/pom.xml +++ /dev/null @@ -1,84 +0,0 @@ -<?xml version='1.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. ---> - -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> - <modelVersion>4.0.0</modelVersion> - - <parent> - <groupId>org.apache.activemq.examples.core</groupId> - <artifactId>core-examples</artifactId> - <version>1.0.1-SNAPSHOT</version> - </parent> - - <artifactId>artemis-core-embedded-example</artifactId> - <packaging>jar</packaging> - <name>ActiveMQ Artemis Core Embedded Example</name> - - <properties> - <activemq.basedir>${project.basedir}/../../..</activemq.basedir> - </properties> - - <dependencies> - <dependency> - <groupId>org.apache.activemq</groupId> - <artifactId>artemis-server</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.apache.activemq</groupId> - <artifactId>artemis-core-client</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.apache.activemq</groupId> - <artifactId>artemis-commons</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>io.netty</groupId> - <artifactId>netty-all</artifactId> - </dependency> - <dependency> - <groupId>org.apache.geronimo.specs</groupId> - <artifactId>geronimo-jms_2.0_spec</artifactId> - </dependency> - </dependencies> - - <build> - <plugins> - <plugin> - <groupId>org.codehaus.mojo</groupId> - <artifactId>exec-maven-plugin</artifactId> - <version>1.1</version> - <executions> - <execution> - <phase>package</phase> - <goals> - <goal>java</goal> - </goals> - </execution> - </executions> - <configuration> - <mainClass>org.apache.activemq.artemis.core.example.EmbeddedExample</mainClass> - </configuration> - </plugin> - </plugins> - </build> -</project> http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/21bf4406/examples/core/embedded/readme.html ---------------------------------------------------------------------- diff --git a/examples/core/embedded/readme.html b/examples/core/embedded/readme.html deleted file mode 100644 index d65caa2..0000000 --- a/examples/core/embedded/readme.html +++ /dev/null @@ -1,116 +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. ---> - -<html> - <head> - <title>ActiveMQ Artemis Embedded Example</title> - <link rel="stylesheet" type="text/css" href="../../common/common.css" /> - <link rel="stylesheet" type="text/css" href="../../common/prettify.css" /> - <script type="text/javascript" src="../../common/prettify.js"></script> - </head> - <body onload="prettyPrint()"> - <h1>Embedded Example</h1> - - <p>This example shows how to setup and run ActiveMQ Artemis embedded.</p> - <p>ActiveMQ Artemis was designed to use POJOs (Plain Old Java Objects), what makes embedding ActiveMQ Artemis as simple as instantiating a few objects.</p> - <p>In this example, we are using two jars:</p> - <ul> - <li>activemq-server.jar</li> - <li>netty.jar</li> - </ul> - - <p>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.</p> - - <h2>Example step-by-step</h2> - <p><i>To run the example, simply type <code>mvn verify</code> from this directory</i></p> - <p>In this we don't use any configuration files. (Everything is embedded). We simply instantiate ConfigurationImpl, ActiveMQServer, start it and operate on JMS regularly</p> - - <ol> - <li>Create the Configuration, and set the properties accordingly</li> - <pre class="prettyprint"> - Configuration configuration = new ConfigurationImpl(); - configuration.setEnablePersistence(false); - configuration.setSecurityEnabled(false); - configuration.getAcceptorConfigurations().add(new TransportConfiguration(InVMAcceptorFactory.class.getName())); - </pre> - - <li>Create and start the server</li> - <pre class="prettyprint"> - ActiveMQServer server = ActiveMQ.newActiveMQServer(configuration); - server.start(); - </pre> - - <li>As we are not using a JNDI environment we instantiate the objects directly</li> - <pre class="prettyprint"> - ServerLocator serverLocator = ActiveMQClient.createServerLocatorWithoutHA(new TransportConfiguration(InVMConnectorFactory.class.getName())); - ClientSessionFactory sf = serverLocator.createSessionFactory(); - </pre> - - <li>Create a Core Queue</li> - <pre class="prettyprint"> - ClientSession coreSession = sf.createSession(false, false, false); - final String queueName = "queue.exampleQueue"; - coreSession.createQueue(queueName, queueName, true); - coreSession.close(); - </pre> - - <li>Create the session and producer</li> - <pre class="prettyprint"> - session = sf.createSession(); - - ClientProducer producer = session.createProducer(queueName); - </pre> - - <li>Create and send a Message</li> - <pre class="prettyprint"> - ClientMessage message = session.createMessage(false); - message.putStringProperty(propName, "Hello sent at " + new Date()); - System.out.println("Sending the message."); - producer.send(message); - </pre> - - <li>Create the message consumer and start the connection</li> - <pre class="prettyprint"> - ClientConsumer messageConsumer = session.createConsumer(queueName); - session.start(); - </pre> - - <li>Receive the message</li> - <pre class="prettyprint"> - ClientMessage messageReceived = messageConsumer.receive(1000); - System.out.println("Received TextMessage:" + messageReceived.getProperty(propName)); - </pre> - - <li>Be sure to close our resources!</li> - - <pre class="prettyprint"> - if (sf != null) - { - sf.close(); - } - </pre> - - <li>Stop the server</li> - - <pre class="prettyprint"> - server.stop(); - </pre> - </ol> - </body> -</html> http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/21bf4406/examples/core/embedded/src/main/java/org/apache/activemq/artemis/core/example/EmbeddedExample.java ---------------------------------------------------------------------- diff --git a/examples/core/embedded/src/main/java/org/apache/activemq/artemis/core/example/EmbeddedExample.java b/examples/core/embedded/src/main/java/org/apache/activemq/artemis/core/example/EmbeddedExample.java deleted file mode 100644 index d3f8f86..0000000 --- a/examples/core/embedded/src/main/java/org/apache/activemq/artemis/core/example/EmbeddedExample.java +++ /dev/null @@ -1,112 +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.core.example; - -import java.util.Date; - -import org.apache.activemq.artemis.api.core.TransportConfiguration; -import org.apache.activemq.artemis.api.core.client.ClientConsumer; -import org.apache.activemq.artemis.api.core.client.ClientMessage; -import org.apache.activemq.artemis.api.core.client.ClientProducer; -import org.apache.activemq.artemis.api.core.client.ClientSession; -import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; -import org.apache.activemq.artemis.api.core.client.ActiveMQClient; -import org.apache.activemq.artemis.api.core.client.ServerLocator; -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.invm.InVMAcceptorFactory; -import org.apache.activemq.artemis.core.remoting.impl.invm.InVMConnectorFactory; -import org.apache.activemq.artemis.core.server.ActiveMQServer; -import org.apache.activemq.artemis.core.server.ActiveMQServers; - -/** - * This example shows how to run an ActiveMQ Artemis core client and server embedded in your - * own application - */ -public class EmbeddedExample { - - public static void main(final String[] args) throws Exception { - try { - // Step 1. Create the Configuration, and set the properties accordingly - Configuration configuration = new ConfigurationImpl(); - //we only need this for the server lock file - configuration.setJournalDirectory("target/data/journal"); - configuration.setPersistenceEnabled(false); - configuration.setSecurityEnabled(false); - configuration.getAcceptorConfigurations().add(new TransportConfiguration(InVMAcceptorFactory.class.getName())); - - // Step 2. Create and start the server - ActiveMQServer server = ActiveMQServers.newActiveMQServer(configuration); - server.start(); - - // Step 3. As we are not using a JNDI environment we instantiate the objects directly - ServerLocator serverLocator = ActiveMQClient.createServerLocatorWithoutHA(new TransportConfiguration(InVMConnectorFactory.class.getName())); - ClientSessionFactory sf = serverLocator.createSessionFactory(); - - // Step 4. Create a core queue - ClientSession coreSession = sf.createSession(false, false, false); - - final String queueName = "queue.exampleQueue"; - - coreSession.createQueue(queueName, queueName, true); - - coreSession.close(); - - ClientSession session = null; - - try { - - // Step 5. Create the session, and producer - session = sf.createSession(); - - ClientProducer producer = session.createProducer(queueName); - - // Step 6. Create and send a message - ClientMessage message = session.createMessage(false); - - final String propName = "myprop"; - - message.putStringProperty(propName, "Hello sent at " + new Date()); - - System.out.println("Sending the message."); - - producer.send(message); - - // Step 7. Create the message consumer and start the connection - ClientConsumer messageConsumer = session.createConsumer(queueName); - session.start(); - - // Step 8. Receive the message. - ClientMessage messageReceived = messageConsumer.receive(1000); - System.out.println("Received TextMessage:" + messageReceived.getStringProperty(propName)); - } - finally { - // Step 9. Be sure to close our resources! - if (sf != null) { - sf.close(); - } - - // Step 10. Stop the server - server.stop(); - } - } - catch (Exception e) { - e.printStackTrace(); - throw e; - } - } -} http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/21bf4406/examples/core/perf/perf.properties ---------------------------------------------------------------------- diff --git a/examples/core/perf/perf.properties b/examples/core/perf/perf.properties deleted file mode 100644 index 9a53c8b..0000000 --- a/examples/core/perf/perf.properties +++ /dev/null @@ -1,38 +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. - -num-messages=100000 -num-warmup-messages=1000 -message-size=1024 -durable=false -transacted=false -batch-size=1048576 -drain-queue=false -throttle-rate=-1 -address=perfAddress -queue-name=perfQueue -host=localhost -port=61616 -tcp-buffer=2048576 -tcp-no-delay=false -confirmation-window=1048576 -producer-window=1048576 -consumer-window=1048576 -pre-ack=false -block-ack=false -block-persistent=false -use-send-acks=true http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/21bf4406/examples/core/perf/pom.xml ---------------------------------------------------------------------- diff --git a/examples/core/perf/pom.xml b/examples/core/perf/pom.xml deleted file mode 100644 index 0681d2a..0000000 --- a/examples/core/perf/pom.xml +++ /dev/null @@ -1,163 +0,0 @@ -<?xml version='1.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. ---> - -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> - <modelVersion>4.0.0</modelVersion> - - <parent> - <groupId>org.apache.activemq.examples.core</groupId> - <artifactId>core-examples</artifactId> - <version>1.0.1-SNAPSHOT</version> - </parent> - - <artifactId>artemis-core-perf-example</artifactId> - <packaging>jar</packaging> - <name>ActiveMQ Artemis Perf Example</name> - - <properties> - <activemq.basedir>${project.basedir}/../../..</activemq.basedir> - </properties> - - <dependencies> - <dependency> - <groupId>org.apache.activemq</groupId> - <artifactId>artemis-core-client</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.apache.activemq</groupId> - <artifactId>artemis-commons</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>io.netty</groupId> - <artifactId>netty-all</artifactId> - <version>${netty.version}</version> - </dependency> - <dependency> - <groupId>org.apache.geronimo.specs</groupId> - <artifactId>geronimo-jms_2.0_spec</artifactId> - </dependency> - </dependencies> - - <profiles> - <profile> - <id>server</id> - <build> - <plugins> - <plugin> - <groupId>org.apache.activemq</groupId> - <artifactId>artemis-maven-plugin</artifactId> - <executions> - <execution> - <id>create0</id> - <goals> - <goal>create</goal> - </goals> - <configuration> - <instance>${basedir}/target/server0</instance> - <configuration>${basedir}/target/classes/activemq/server0</configuration> - </configuration> - </execution> - </executions> - <dependencies> - <dependency> - <groupId>org.apache.activemq.examples.core</groupId> - <artifactId>artemis-core-perf-example</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.apache.activemq</groupId> - <artifactId>artemis-core-client</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.apache.activemq</groupId> - <artifactId>artemis-server</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.apache.activemq</groupId> - <artifactId>artemis-jms-client</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.apache.activemq</groupId> - <artifactId>artemis-jms-server</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>io.netty</groupId> - <artifactId>netty-all</artifactId> - <version>${netty.version}</version> - </dependency> - </dependencies> - </plugin> - </plugins> - </build> - </profile> - <profile> - <id>listener</id> - <build> - <plugins> - <plugin> - <groupId>org.codehaus.mojo</groupId> - <artifactId>exec-maven-plugin</artifactId> - <version>1.1</version> - <executions> - <execution> - <phase>package</phase> - <goals> - <goal>java</goal> - </goals> - </execution> - </executions> - <configuration> - <mainClass>org.apache.activemq.artemis.core.example.PerfListener</mainClass> - </configuration> - </plugin> - </plugins> - </build> - </profile> - <profile> - <id>sender</id> - <build> - <plugins> - <plugin> - <groupId>org.codehaus.mojo</groupId> - <artifactId>exec-maven-plugin</artifactId> - <version>1.1</version> - <executions> - <execution> - <phase>package</phase> - <goals> - <goal>java</goal> - </goals> - </execution> - </executions> - <configuration> - <mainClass>org.apache.activemq.artemis.core.example.PerfSender</mainClass> - </configuration> - </plugin> - </plugins> - </build> - </profile> - </profiles> -</project> http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/21bf4406/examples/core/perf/src/main/java/org/apache/activemq/artemis/core/example/PerfBase.java ---------------------------------------------------------------------- diff --git a/examples/core/perf/src/main/java/org/apache/activemq/artemis/core/example/PerfBase.java b/examples/core/perf/src/main/java/org/apache/activemq/artemis/core/example/PerfBase.java deleted file mode 100644 index c1988c9..0000000 --- a/examples/core/perf/src/main/java/org/apache/activemq/artemis/core/example/PerfBase.java +++ /dev/null @@ -1,474 +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.core.example; - -import java.io.FileInputStream; -import java.io.InputStream; -import java.util.HashMap; -import java.util.Map; -import java.util.Properties; -import java.util.Random; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.atomic.AtomicLong; -import java.util.logging.Logger; - -import org.apache.activemq.artemis.api.core.Message; -import org.apache.activemq.artemis.api.core.TransportConfiguration; -import org.apache.activemq.artemis.api.core.client.ClientConsumer; -import org.apache.activemq.artemis.api.core.client.ClientMessage; -import org.apache.activemq.artemis.api.core.client.ClientProducer; -import org.apache.activemq.artemis.api.core.client.ClientSession; -import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; -import org.apache.activemq.artemis.api.core.client.ActiveMQClient; -import org.apache.activemq.artemis.api.core.client.MessageHandler; -import org.apache.activemq.artemis.api.core.client.SendAcknowledgementHandler; -import org.apache.activemq.artemis.api.core.client.ServerLocator; -import org.apache.activemq.artemis.core.remoting.impl.netty.NettyConnectorFactory; -import org.apache.activemq.artemis.core.remoting.impl.netty.TransportConstants; -import org.apache.activemq.artemis.utils.TokenBucketLimiter; -import org.apache.activemq.artemis.utils.TokenBucketLimiterImpl; - -/** - * A PerfBase - */ -public abstract class PerfBase { - - private static final Logger log = Logger.getLogger(PerfSender.class.getName()); - - private static final String DEFAULT_PERF_PROPERTIES_FILE_NAME = "perf.properties"; - - private static byte[] randomByteArray(final int length) { - byte[] bytes = new byte[length]; - - Random random = new Random(); - - for (int i = 0; i < length; i++) { - bytes[i] = Integer.valueOf(random.nextInt()).byteValue(); - } - - return bytes; - } - - protected static String getPerfFileName(final String[] args) { - String fileName; - - if (args.length > 0) { - fileName = args[0]; - } - else { - fileName = PerfBase.DEFAULT_PERF_PROPERTIES_FILE_NAME; - } - - PerfBase.log.info("Using file name " + fileName); - - return fileName; - } - - protected static PerfParams getParams(final String fileName) throws Exception { - Properties props = null; - - InputStream is = null; - - try { - is = new FileInputStream(fileName); - - props = new Properties(); - - props.load(is); - } - finally { - if (is != null) { - is.close(); - } - } - - int noOfMessages = Integer.valueOf(props.getProperty("num-messages")); - int noOfWarmupMessages = Integer.valueOf(props.getProperty("num-warmup-messages")); - int messageSize = Integer.valueOf(props.getProperty("message-size")); - boolean durable = Boolean.valueOf(props.getProperty("durable")); - boolean transacted = Boolean.valueOf(props.getProperty("transacted")); - int batchSize = Integer.valueOf(props.getProperty("batch-size")); - boolean drainQueue = Boolean.valueOf(props.getProperty("drain-queue")); - String queueName = props.getProperty("queue-name"); - String address = props.getProperty("address"); - int throttleRate = Integer.valueOf(props.getProperty("throttle-rate")); - String host = props.getProperty("host"); - int port = Integer.valueOf(props.getProperty("port")); - int tcpBufferSize = Integer.valueOf(props.getProperty("tcp-buffer")); - boolean tcpNoDelay = Boolean.valueOf(props.getProperty("tcp-no-delay")); - boolean preAck = Boolean.valueOf(props.getProperty("pre-ack")); - int confirmationWindowSize = Integer.valueOf(props.getProperty("confirmation-window")); - int producerWindowSize = Integer.valueOf(props.getProperty("producer-window")); - int consumerWindowSize = Integer.valueOf(props.getProperty("consumer-window")); - boolean blockOnACK = Boolean.valueOf(props.getProperty("block-ack", "false")); - boolean blockOnPersistent = Boolean.valueOf(props.getProperty("block-persistent", "false")); - boolean useSendAcks = Boolean.valueOf(props.getProperty("use-send-acks", "false")); - - PerfBase.log.info("num-messages: " + noOfMessages); - PerfBase.log.info("num-warmup-messages: " + noOfWarmupMessages); - PerfBase.log.info("message-size: " + messageSize); - PerfBase.log.info("durable: " + durable); - PerfBase.log.info("transacted: " + transacted); - PerfBase.log.info("batch-size: " + batchSize); - PerfBase.log.info("drain-queue: " + drainQueue); - PerfBase.log.info("address: " + address); - PerfBase.log.info("queue name: " + queueName); - PerfBase.log.info("throttle-rate: " + throttleRate); - PerfBase.log.info("host:" + host); - PerfBase.log.info("port: " + port); - PerfBase.log.info("tcp buffer: " + tcpBufferSize); - PerfBase.log.info("tcp no delay: " + tcpNoDelay); - PerfBase.log.info("pre-ack: " + preAck); - PerfBase.log.info("confirmation-window: " + confirmationWindowSize); - PerfBase.log.info("producer-window: " + producerWindowSize); - PerfBase.log.info("consumer-window: " + consumerWindowSize); - PerfBase.log.info("block-ack:" + blockOnACK); - PerfBase.log.info("block-persistent:" + blockOnPersistent); - PerfBase.log.info("use-send-acks:" + useSendAcks); - - if (useSendAcks && confirmationWindowSize < 1) { - throw new IllegalArgumentException("If you use send acks, then need to set confirmation-window-size to a positive integer"); - } - - PerfParams perfParams = new PerfParams(); - perfParams.setNoOfMessagesToSend(noOfMessages); - perfParams.setNoOfWarmupMessages(noOfWarmupMessages); - perfParams.setMessageSize(messageSize); - perfParams.setDurable(durable); - perfParams.setSessionTransacted(transacted); - perfParams.setBatchSize(batchSize); - perfParams.setDrainQueue(drainQueue); - perfParams.setQueueName(queueName); - perfParams.setAddress(address); - perfParams.setThrottleRate(throttleRate); - perfParams.setHost(host); - perfParams.setPort(port); - perfParams.setTcpBufferSize(tcpBufferSize); - perfParams.setTcpNoDelay(tcpNoDelay); - perfParams.setPreAck(preAck); - perfParams.setConfirmationWindow(confirmationWindowSize); - perfParams.setProducerWindow(producerWindowSize); - perfParams.setConsumerWindow(consumerWindowSize); - perfParams.setBlockOnACK(blockOnACK); - perfParams.setBlockOnPersistent(blockOnPersistent); - perfParams.setUseSendAcks(useSendAcks); - - return perfParams; - } - - private final PerfParams perfParams; - - protected PerfBase(final PerfParams perfParams) { - this.perfParams = perfParams; - } - - private ClientSessionFactory factory; - - private long start; - - private void init(final boolean transacted, final String queueName) throws Exception { - Map<String, Object> params = new HashMap<String, Object>(); - - params.put(TransportConstants.TCP_NODELAY_PROPNAME, perfParams.isTcpNoDelay()); - params.put(TransportConstants.TCP_SENDBUFFER_SIZE_PROPNAME, perfParams.getTcpBufferSize()); - params.put(TransportConstants.TCP_RECEIVEBUFFER_SIZE_PROPNAME, perfParams.getTcpBufferSize()); - - params.put(TransportConstants.HOST_PROP_NAME, perfParams.getHost()); - params.put(TransportConstants.PORT_PROP_NAME, perfParams.getPort()); - - ServerLocator serverLocator = ActiveMQClient.createServerLocatorWithoutHA(new TransportConfiguration(NettyConnectorFactory.class.getName(), params)); - serverLocator.setPreAcknowledge(perfParams.isPreAck()); - serverLocator.setConfirmationWindowSize(perfParams.getConfirmationWindow()); - serverLocator.setProducerWindowSize(perfParams.getProducerWindow()); - serverLocator.setConsumerWindowSize(perfParams.getConsumerWindow()); - serverLocator.setAckBatchSize(perfParams.getBatchSize()); - - serverLocator.setBlockOnAcknowledge(perfParams.isBlockOnACK()); - serverLocator.setBlockOnDurableSend(perfParams.isBlockOnPersistent()); - factory = serverLocator.createSessionFactory(); - - } - - private void displayAverage(final long numberOfMessages, final long start, final long end) { - double duration = (1.0 * end - start) / 1000; // in seconds - double average = 1.0 * numberOfMessages / duration; - PerfBase.log.info(String.format("average: %.2f msg/s (%d messages in %2.2fs)", average, numberOfMessages, duration)); - } - - protected void runSender() { - try { - PerfBase.log.info("params = " + perfParams); - - init(perfParams.isSessionTransacted(), perfParams.getQueueName()); - - if (perfParams.isDrainQueue()) { - drainQueue(); - } - - start = System.currentTimeMillis(); - PerfBase.log.info("warming up by sending " + perfParams.getNoOfWarmupMessages() + " messages"); - sendMessages(perfParams.getNoOfWarmupMessages(), perfParams.getBatchSize(), perfParams.isDurable(), perfParams.isSessionTransacted(), false, perfParams.getThrottleRate(), perfParams.getMessageSize(), perfParams.isUseSendAcks()); - PerfBase.log.info("warmed up"); - start = System.currentTimeMillis(); - sendMessages(perfParams.getNoOfMessagesToSend(), perfParams.getBatchSize(), perfParams.isDurable(), perfParams.isSessionTransacted(), true, perfParams.getThrottleRate(), perfParams.getMessageSize(), perfParams.isUseSendAcks()); - long end = System.currentTimeMillis(); - displayAverage(perfParams.getNoOfMessagesToSend(), start, end); - } - catch (Exception e) { - e.printStackTrace(); - } - } - - protected void runListener() { - ClientSession session = null; - - try { - init(perfParams.isSessionTransacted(), perfParams.getQueueName()); - - session = factory.createSession(!perfParams.isSessionTransacted(), !perfParams.isSessionTransacted()); - - if (perfParams.isDrainQueue()) { - drainQueue(); - } - - ClientConsumer consumer = session.createConsumer(perfParams.getQueueName()); - - session.start(); - - PerfBase.log.info("READY!!!"); - - CountDownLatch countDownLatch = new CountDownLatch(1); - consumer.setMessageHandler(new PerfListener(session, countDownLatch, perfParams)); - countDownLatch.await(); - long end = System.currentTimeMillis(); - // start was set on the first received message - displayAverage(perfParams.getNoOfMessagesToSend(), start, end); - } - catch (Exception e) { - e.printStackTrace(); - } - finally { - if (factory != null) { - try { - factory.close(); - } - catch (Exception e) { - e.printStackTrace(); - } - } - } - } - - private void drainQueue() throws Exception { - PerfBase.log.info("Draining queue"); - - ClientSession session = null; - - try { - session = factory.createSession(); - - ClientConsumer consumer = session.createConsumer(perfParams.getQueueName()); - - session.start(); - - ClientMessage message = null; - - int count = 0; - do { - message = consumer.receive(3000); - - if (message != null) { - message.acknowledge(); - - count++; - } - } while (message != null); - - PerfBase.log.info("Drained " + count + " messages"); - } - finally { - if (session != null) { - session.close(); - } - } - } - - private void sendMessages(final int numberOfMessages, - final int txBatchSize, - final boolean durable, - final boolean transacted, - final boolean display, - final int throttleRate, - final int messageSize, - final boolean useSendAcks) throws Exception { - ClientSession session = null; - - try { - session = factory.createSession(!transacted, !transacted); - - CountDownLatch theLatch = null; - - if (useSendAcks) { - final CountDownLatch latch = new CountDownLatch(numberOfMessages); - - class MySendAckHandler implements SendAcknowledgementHandler { - - public void sendAcknowledged(Message message) { - latch.countDown(); - } - } - - session.setSendAcknowledgementHandler(new MySendAckHandler()); - - theLatch = latch; - } - - ClientProducer producer = session.createProducer(perfParams.getAddress()); - - ClientMessage message = session.createMessage(durable); - - byte[] payload = PerfBase.randomByteArray(messageSize); - - message.getBodyBuffer().writeBytes(payload); - - final int modulo = 2000; - - TokenBucketLimiter tbl = throttleRate != -1 ? new TokenBucketLimiterImpl(throttleRate, false) : null; - - boolean committed = false; - - for (int i = 1; i <= numberOfMessages; i++) { - producer.send(message); - - if (transacted) { - if (i % txBatchSize == 0) { - session.commit(); - committed = true; - } - else { - committed = false; - } - } - if (display && i % modulo == 0) { - double duration = (1.0 * System.currentTimeMillis() - start) / 1000; - PerfBase.log.info(String.format("sent %6d messages in %2.2fs", i, duration)); - } - - // log.info("sent message " + i); - - if (tbl != null) { - tbl.limit(); - } - } - - if (transacted && !committed) { - session.commit(); - } - - session.close(); - - if (useSendAcks) { - theLatch.await(); - } - } - finally { - if (session != null) { - session.close(); - } - } - } - - private class PerfListener implements MessageHandler { - - private final CountDownLatch countDownLatch; - - private final PerfParams perfParams; - - private boolean warmingUp = true; - - private boolean started = false; - - private final int modulo; - - private final AtomicLong count = new AtomicLong(0); - - private final ClientSession session; - - public PerfListener(final ClientSession session, - final CountDownLatch countDownLatch, - final PerfParams perfParams) { - this.session = session; - this.countDownLatch = countDownLatch; - this.perfParams = perfParams; - warmingUp = perfParams.getNoOfWarmupMessages() > 0; - modulo = 2000; - } - - public void onMessage(final ClientMessage message) { - try { - if (warmingUp) { - boolean committed = checkCommit(session); - if (count.incrementAndGet() == perfParams.getNoOfWarmupMessages()) { - PerfBase.log.info("warmed up after receiving " + count.longValue() + " msgs"); - if (!committed) { - checkCommit(session); - } - warmingUp = false; - } - return; - } - - if (!started) { - started = true; - // reset count to take stats - count.set(0); - start = System.currentTimeMillis(); - } - - message.acknowledge(); - - long currentCount = count.incrementAndGet(); - boolean committed = checkCommit(session); - if (currentCount == perfParams.getNoOfMessagesToSend()) { - if (!committed) { - checkCommit(session); - } - countDownLatch.countDown(); - } - if (currentCount % modulo == 0) { - double duration = (1.0 * System.currentTimeMillis() - start) / 1000; - PerfBase.log.info(String.format("received %6d messages in %2.2fs", currentCount, duration)); - } - } - catch (Exception e) { - e.printStackTrace(); - } - } - - private boolean checkCommit(final ClientSession session) throws Exception { - if (perfParams.isSessionTransacted()) { - if (count.longValue() % perfParams.getBatchSize() == 0) { - session.commit(); - - return true; - } - } - return false; - } - } - -} http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/21bf4406/examples/core/perf/src/main/java/org/apache/activemq/artemis/core/example/PerfListener.java ---------------------------------------------------------------------- diff --git a/examples/core/perf/src/main/java/org/apache/activemq/artemis/core/example/PerfListener.java b/examples/core/perf/src/main/java/org/apache/activemq/artemis/core/example/PerfListener.java deleted file mode 100644 index 1ad3257..0000000 --- a/examples/core/perf/src/main/java/org/apache/activemq/artemis/core/example/PerfListener.java +++ /dev/null @@ -1,46 +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.core.example; - -import java.util.logging.Logger; - -public class PerfListener extends PerfBase { - - private static final Logger log = Logger.getLogger(PerfListener.class.getName()); - - public static void main(final String[] args) { - try { - String fileName = PerfBase.getPerfFileName(args); - - PerfParams params = PerfBase.getParams(fileName); - - new PerfListener(params).run(); - } - catch (Exception e) { - e.printStackTrace(); - } - } - - private PerfListener(final PerfParams perfParams) { - super(perfParams); - } - - public void run() throws Exception { - runListener(); - } - -} http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/21bf4406/examples/core/perf/src/main/java/org/apache/activemq/artemis/core/example/PerfParams.java ---------------------------------------------------------------------- diff --git a/examples/core/perf/src/main/java/org/apache/activemq/artemis/core/example/PerfParams.java b/examples/core/perf/src/main/java/org/apache/activemq/artemis/core/example/PerfParams.java deleted file mode 100644 index 933322a..0000000 --- a/examples/core/perf/src/main/java/org/apache/activemq/artemis/core/example/PerfParams.java +++ /dev/null @@ -1,257 +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.core.example; - -import java.io.Serializable; - -/** - * Class that holds the parameters used in the performance examples - */ -public class PerfParams implements Serializable { - - private static final long serialVersionUID = -4336539641012356002L; - - private int noOfMessagesToSend = 1000; - - private int noOfWarmupMessages; - - private int messageSize = 1024; // in bytes - - private boolean durable = false; - - private boolean isSessionTransacted = false; - - private int batchSize = 5000; - - private boolean drainQueue = true; - - private String queueName; - - private String address; - - private int throttleRate; - - private String host; - - private int port; - - private int tcpBufferSize; - - private boolean tcpNoDelay; - - private boolean preAck; - - private int confirmationWindow = -1; - - private int producerWindow; - - private int consumerWindow; - - private boolean blockOnPersistent = true; - - private boolean blockOnACK = true; - - private boolean useSendAcks; - - public boolean isBlockOnPersistent() { - return blockOnPersistent; - } - - public void setBlockOnPersistent(final boolean blockOnPersistent) { - this.blockOnPersistent = blockOnPersistent; - } - - public boolean isBlockOnACK() { - return blockOnACK; - } - - public void setBlockOnACK(final boolean blockOnACK) { - this.blockOnACK = blockOnACK; - } - - public int getNoOfMessagesToSend() { - return noOfMessagesToSend; - } - - public void setNoOfMessagesToSend(final int noOfMessagesToSend) { - this.noOfMessagesToSend = noOfMessagesToSend; - } - - public int getNoOfWarmupMessages() { - return noOfWarmupMessages; - } - - public void setNoOfWarmupMessages(final int noOfWarmupMessages) { - this.noOfWarmupMessages = noOfWarmupMessages; - } - - public int getMessageSize() { - return messageSize; - } - - public void setMessageSize(final int messageSize) { - this.messageSize = messageSize; - } - - public boolean isDurable() { - return durable; - } - - public void setDurable(final boolean durable) { - this.durable = durable; - } - - public boolean isSessionTransacted() { - return isSessionTransacted; - } - - public void setSessionTransacted(final boolean sessionTransacted) { - isSessionTransacted = sessionTransacted; - } - - public int getBatchSize() { - return batchSize; - } - - public void setBatchSize(final int batchSize) { - this.batchSize = batchSize; - } - - public boolean isDrainQueue() { - return drainQueue; - } - - public void setDrainQueue(final boolean drainQueue) { - this.drainQueue = drainQueue; - } - - public String getQueueName() { - return queueName; - } - - public void setQueueName(final String queueName) { - this.queueName = queueName; - } - - public String getAddress() { - return address; - } - - public void setAddress(final String address) { - this.address = address; - } - - public int getThrottleRate() { - return throttleRate; - } - - public void setThrottleRate(final int throttleRate) { - this.throttleRate = throttleRate; - } - - @Override - public String toString() { - return "message to send = " + noOfMessagesToSend + - ", Durable = " + - durable + - ", session transacted = " + - isSessionTransacted + - (isSessionTransacted ? ", transaction batch size = " + batchSize : "") + - ", drain queue = " + - drainQueue + - ", queue name = " + - queueName + - ", Throttle rate = " + - throttleRate + - ", blockOnPersistent = " + - blockOnPersistent + - ". blockOnACK = " + - blockOnACK; - } - - public synchronized String getHost() { - return host; - } - - public synchronized void setHost(final String host) { - this.host = host; - } - - public synchronized int getPort() { - return port; - } - - public synchronized void setPort(final int port) { - this.port = port; - } - - public synchronized int getTcpBufferSize() { - return tcpBufferSize; - } - - public synchronized void setTcpBufferSize(final int tcpBufferSize) { - this.tcpBufferSize = tcpBufferSize; - } - - public synchronized boolean isTcpNoDelay() { - return tcpNoDelay; - } - - public synchronized void setTcpNoDelay(final boolean tcpNoDelay) { - this.tcpNoDelay = tcpNoDelay; - } - - public synchronized boolean isPreAck() { - return preAck; - } - - public synchronized void setPreAck(final boolean preAck) { - this.preAck = preAck; - } - - public synchronized int getConfirmationWindow() { - return confirmationWindow; - } - - public synchronized void setConfirmationWindow(final int confirmationWindow) { - this.confirmationWindow = confirmationWindow; - } - - public int getProducerWindow() { - return producerWindow; - } - - public void setProducerWindow(final int producerWindow) { - this.producerWindow = producerWindow; - } - - public int getConsumerWindow() { - return consumerWindow; - } - - public void setConsumerWindow(final int consumerWindow) { - this.consumerWindow = consumerWindow; - } - - public boolean isUseSendAcks() { - return useSendAcks; - } - - public void setUseSendAcks(boolean useSendAcks) { - this.useSendAcks = useSendAcks; - } -} http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/21bf4406/examples/core/perf/src/main/java/org/apache/activemq/artemis/core/example/PerfSender.java ---------------------------------------------------------------------- diff --git a/examples/core/perf/src/main/java/org/apache/activemq/artemis/core/example/PerfSender.java b/examples/core/perf/src/main/java/org/apache/activemq/artemis/core/example/PerfSender.java deleted file mode 100644 index 4fed6b5..0000000 --- a/examples/core/perf/src/main/java/org/apache/activemq/artemis/core/example/PerfSender.java +++ /dev/null @@ -1,46 +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.core.example; - -import java.util.logging.Logger; - -public class PerfSender extends PerfBase { - - private static final Logger log = Logger.getLogger(PerfSender.class.getName()); - - public static void main(final String[] args) { - try { - String fileName = PerfBase.getPerfFileName(args); - - PerfParams params = PerfBase.getParams(fileName); - - new PerfSender(params).run(); - } - catch (Exception e) { - e.printStackTrace(); - } - } - - private PerfSender(final PerfParams perfParams) { - super(perfParams); - } - - public void run() throws Exception { - runSender(); - } - -} http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/21bf4406/examples/core/perf/src/main/resources/activemq/server0/broker.xml ---------------------------------------------------------------------- diff --git a/examples/core/perf/src/main/resources/activemq/server0/broker.xml b/examples/core/perf/src/main/resources/activemq/server0/broker.xml deleted file mode 100644 index 6e787fb..0000000 --- a/examples/core/perf/src/main/resources/activemq/server0/broker.xml +++ /dev/null @@ -1,69 +0,0 @@ -<?xml version='1.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. ---> - -<configuration xmlns="urn:activemq" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="urn:activemq /schema/artemis-server.xsd"> - <core xmlns="urn:activemq:core"> - - <bindings-directory>./data/bindings</bindings-directory> - - <journal-directory>./data/journal</journal-directory> - - <large-messages-directory>./data/largemessages</large-messages-directory> - - <paging-directory>./data/paging</paging-directory> - - <!-- Acceptors --> - <acceptors> - <acceptor name="netty-acceptor">tcp://localhost:61616?tcpNoDelay=false;tcpSendBufferSize=1048576;tcpReceiveBufferSize=1048576</acceptor> - </acceptors> - - <security-enabled>false</security-enabled> - - <persistence-enabled>true</persistence-enabled> - - <journal-sync-non-transactional>true</journal-sync-non-transactional> - <journal-sync-transactional>true</journal-sync-transactional> - <journal-type>ASYNCIO</journal-type> - <journal-min-files>20</journal-min-files> - <journal-buffer-timeout>20000</journal-buffer-timeout> - <log-journal-write-rate>false</log-journal-write-rate> - <run-sync-speed-test>false</run-sync-speed-test> - - <!-- <perf-blast-pages>5000</perf-blast-pages> --> - - <queues> - <queue name="perfQueue"> - <address>perfAddress</address> - </queue> - </queues> - - <!-- - <address-settings> - <address-setting match="perfAddress"> - <max-size-bytes>10485760</max-size-bytes> - <address-full-policy>BLOCK</address-full-policy> - </address-setting> - </address-settings> - --> - </core> - -</configuration> http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/21bf4406/examples/core/perf/src/main/resources/activemq/server0/hornetq-configuration-messaging-lab.xml ---------------------------------------------------------------------- diff --git a/examples/core/perf/src/main/resources/activemq/server0/hornetq-configuration-messaging-lab.xml b/examples/core/perf/src/main/resources/activemq/server0/hornetq-configuration-messaging-lab.xml deleted file mode 100644 index 74b120e..0000000 --- a/examples/core/perf/src/main/resources/activemq/server0/hornetq-configuration-messaging-lab.xml +++ /dev/null @@ -1,53 +0,0 @@ -<?xml version='1.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. ---> - -<configuration xmlns="urn:activemq" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="urn:activemq /schema/artemis-server.xsd"> - <core xmlns="urn:activemq:core"> - <bindings-directory>${build.directory}/server0/data/messaging/bindings</bindings-directory> - - <journal-directory>${build.directory}/server0/data/messaging/journal</journal-directory> - - <large-messages-directory>${build.directory}/server0/data/messaging/largemessages</large-messages-directory> - - <paging-directory>${build.directory}/server0/data/messaging/paging</paging-directory> - <!-- Acceptors --> - <acceptors> - <acceptor name="netty-acceptor">tcp://172.16.8.10:61616?tcpNoDelay=false;tcpSendBufferSize=1048576;tcpReceiveBufferSize=1048576</acceptor> - </acceptors> - - <security-enabled>false</security-enabled> - - <persistence-enabled>true</persistence-enabled> - - <large-messages-directory>/activemq-data/large-messages</large-messages-directory> - <bindings-directory>/activemq-data/bindings</bindings-directory> - <journal-directory>/activemq-data/journal</journal-directory> - <paging-directory>/activemq-data/paging</paging-directory> - - <queues> - <queue name="perfQueue"> - <address>perfAddress</address> - </queue> - </queues> - </core> - -</configuration> http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/21bf4406/examples/core/pom.xml ---------------------------------------------------------------------- diff --git a/examples/core/pom.xml b/examples/core/pom.xml deleted file mode 100644 index fd3ba18..0000000 --- a/examples/core/pom.xml +++ /dev/null @@ -1,53 +0,0 @@ -<?xml version='1.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. ---> - -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> - <modelVersion>4.0.0</modelVersion> - - <parent> - <groupId>org.apache.activemq.examples</groupId> - <artifactId>artemis-examples</artifactId> - <version>1.0.1-SNAPSHOT</version> - </parent> - - <groupId>org.apache.activemq.examples.core</groupId> - <artifactId>core-examples</artifactId> - <packaging>pom</packaging> - <name>ActiveMQ Artemis Core Examples</name> - - <properties> - <udp-address>231.7.7.7</udp-address> - <activemq.basedir>${project.basedir}/../..</activemq.basedir> - </properties> - - <profiles> - <profile> - <!-- You need to activate -Pexamples to run all the examples --> - <id>examples</id> - <modules> - <module>embedded</module> - <module>embedded-remote</module> - <module>perf</module> - <module>vertx-connector</module> - </modules> - </profile> - </profiles> - -</project> http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/21bf4406/examples/core/vertx-connector/pom.xml ---------------------------------------------------------------------- diff --git a/examples/core/vertx-connector/pom.xml b/examples/core/vertx-connector/pom.xml deleted file mode 100644 index 8d8ba8e..0000000 --- a/examples/core/vertx-connector/pom.xml +++ /dev/null @@ -1,189 +0,0 @@ -<?xml version='1.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. ---> - -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> - <modelVersion>4.0.0</modelVersion> - - <parent> - <groupId>org.apache.activemq.examples.core</groupId> - <artifactId>core-examples</artifactId> - <version>1.0.1-SNAPSHOT</version> - </parent> - - <artifactId>artemis-vertx-example</artifactId> - <packaging>jar</packaging> - <name>ActiveMQ Artemis Vert.x Example</name> - - <properties> - <activemq.basedir>${project.basedir}/../../..</activemq.basedir> - <vertx.version>2.1.2</vertx.version> - </properties> - - <dependencies> - <dependency> - <groupId>org.apache.activemq</groupId> - <artifactId>artemis-server</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.apache.activemq</groupId> - <artifactId>artemis-core-client</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.apache.activemq</groupId> - <artifactId>artemis-commons</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>io.netty</groupId> - <artifactId>netty-all</artifactId> - <version>${netty.version}</version> - </dependency> - <dependency> - <groupId>org.apache.geronimo.specs</groupId> - <artifactId>geronimo-jms_2.0_spec</artifactId> - </dependency> - <dependency> - <groupId>io.vertx</groupId> - <artifactId>vertx-core</artifactId> - <version>${vertx.version}</version> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>io.vertx</groupId> - <artifactId>vertx-platform</artifactId> - <version>${vertx.version}</version> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>io.vertx</groupId> - <artifactId>vertx-hazelcast</artifactId> - <version>${vertx.version}</version> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>org.apache.activemq</groupId> - <artifactId>artemis-vertx-integration</artifactId> - <version>${project.version}</version> - </dependency> - - </dependencies> - <profiles> - <profile> - <id>example</id> - <build> - <plugins> - <plugin> - <groupId>org.apache.activemq</groupId> - <artifactId>artemis-maven-plugin</artifactId> - <executions> - <execution> - <id>create0</id> - <goals> - <goal>create</goal> - </goals> - <configuration> - <instance>${basedir}/target/server0</instance> - <configuration>${basedir}/target/classes/activemq/server0</configuration> - </configuration> - </execution> - <execution> - <id>start0</id> - <goals> - <goal>cli</goal> - </goals> - <configuration> - <spawn>true</spawn> - <location>${basedir}/target/server0</location> - <testURI>tcp://localhost:61616</testURI> - <args> - <param>run</param> - </args> - </configuration> - </execution> - <execution> - <id>runClient</id> - <goals> - <goal>runClient</goal> - </goals> - <configuration> - <clientClass>org.apache.activemq.artemis.core.example.VertxConnectorExample</clientClass> - </configuration> - </execution> - </executions> - <dependencies> - <dependency> - <groupId>org.apache.activemq.examples.core</groupId> - <artifactId>artemis-vertx-example</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.apache.activemq</groupId> - <artifactId>artemis-vertx-integration</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.apache.activemq</groupId> - <artifactId>artemis-core-client</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.apache.activemq</groupId> - <artifactId>artemis-server</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.apache.activemq</groupId> - <artifactId>artemis-jms-client</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.apache.activemq</groupId> - <artifactId>artemis-jms-server</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>io.netty</groupId> - <artifactId>netty-all</artifactId> - <version>${netty.version}</version> - </dependency> - <dependency> - <groupId>io.vertx</groupId> - <artifactId>vertx-core</artifactId> - <version>${vertx.version}</version> - </dependency> - <dependency> - <groupId>io.vertx</groupId> - <artifactId>vertx-platform</artifactId> - <version>${vertx.version}</version> - </dependency> - <dependency> - <groupId>io.vertx</groupId> - <artifactId>vertx-hazelcast</artifactId> - <version>${vertx.version}</version> - </dependency> - </dependencies> - </plugin> - </plugins> - </build> - </profile> - </profiles> -</project>
