Permalink
Browse files

Updated the pom file to include the correct activemq jar files. I was…

… using

the 5.5.0 jar files instead of the 5.5.1 jar files.

Added the source plugin to the pom file so that the sources are installed in
the maven repo in case someone needs them to debug their code.

Removed the original hub/spoke implementation since this is no longer required.

Move the log4j.properties file from the main/resources directory to the test/resources
directory.

Removed all commented out code that was part of the original implementation
that has been shown to not be required.
  • Loading branch information...
1 parent 06ad30b commit 766c5dbef4cb2446014d30ece162018dab024b12 Claudio Corsi committed Oct 6, 2011
View
19 pom.xml
@@ -12,7 +12,7 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
- <activemq.version>5.5.0-fuse-00-27</activemq.version>
+ <activemq.version>${project.version}</activemq.version>
</properties>
<build>
@@ -26,6 +26,9 @@
<fileset>
<directory>activemq</directory>
</fileset>
+ <fileset>
+ <directory>activemq-data</directory>
+ </fileset>
<fileset>
<directory>hub</directory>
</fileset>
@@ -55,6 +58,20 @@
<extensions>false</extensions>
<inherited>false</inherited>
</plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-source-plugin</artifactId>
+ <version>2.1.2</version>
+ <executions>
+ <execution>
+ <id>attach-sources</id>
+ <phase>verify</phase>
+ <goals>
+ <goal>jar-no-fork</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
</plugins>
</build>
<dependencies>
@@ -28,6 +28,7 @@
import java.net.Socket;
import java.util.Collection;
import java.util.LinkedList;
+import java.util.List;
import java.util.Properties;
import org.slf4j.Logger;
@@ -204,6 +205,11 @@ protected void preCreateSpawners() {
*/
protected abstract void createSpawners();
+ /**
+ * This method will be called prior to the spawning the java command to allow you to add jvm arguments to the java command
+ */
+ protected void addToJVMArgs(List<String> jvmArgs) {}
+
/**
* @throws IOException
*/
@@ -119,6 +119,7 @@ protected void createSpawners() {
spawners[brokerId] = new Spawner(
BrokerServiceProcess.class.getName(), "execute");
List<String> jvmArgs = new LinkedList<String>();
+ addToJVMArgs(jvmArgs);
jvmArgs.add("-Dbroker.config.file=xbean:" + configFileName);
spawners[brokerId].setJVMArgs(jvmArgs);
spawners[brokerId].setIdentifier("ActiveMQBroker" + brokerId);
@@ -98,6 +98,7 @@ protected void createSpawners() {
hubTemplateFileName, hubConfigFileName);
spawners[spawnIdx] = new Spawner(BrokerServiceProcess.class.getName(), "execute");
List<String> jvmArgs = new LinkedList<String>();
+ addToJVMArgs(jvmArgs);
jvmArgs.add("-Dbroker.config.file=xbean:" + hubConfigFileName);
spawners[spawnIdx].setJVMArgs(jvmArgs);
spawners[spawnIdx].setIdentifier("Hub:" + id);
@@ -130,6 +131,7 @@ protected void createSpawners() {
spawners[spawnIdx] = new Spawner(
BrokerServiceProcess.class.getName(), "execute");
List<String> jvmArgs = new LinkedList<String>();
+ addToJVMArgs(jvmArgs);
jvmArgs.add("-Dbroker.config.file=xbean:" + spokeConfigFileName);
spawners[spawnIdx].setJVMArgs(jvmArgs);
spawners[spawnIdx].setIdentifier("Spoke:" + id + ":" + spoke);
@@ -1,194 +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.brokerservice.runner;
-
-import java.io.IOException;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Properties;
-
-import org.valhalla.tools.process.Spawner;
-
-/**
- * @author Claudio Corsi
- *
- */
-public class HubSpokeBrokerServiceSpawnerOrg extends AbstractBrokerServiceSpawner {
-
- private static final int defaultNumberOfHubs = 1;
- private static final int defaultNumberofSpokesPerHub = 5;
-
- private int numberOfHubs = defaultNumberOfHubs;
- private int numberOfSpokesPerHub = defaultNumberofSpokesPerHub;
-
- private int amqPort = -1;
- private String amqDefaultPort;
-
- public enum TYPES { HUB, SPOKE }
-
- public HubSpokeBrokerServiceSpawnerOrg() {
- this("61616");
- }
-
- public HubSpokeBrokerServiceSpawnerOrg(String amqDefaultPort) {
- this.amqDefaultPort = amqDefaultPort;
- }
-
- /**
- * @param args
- * @throws IOException
- */
- public static void main(String[] args) throws IOException {
- AbstractBrokerServiceSpawner spawner = new HubSpokeBrokerServiceSpawnerOrg();
- spawner.execute();
-
- try {
- Thread.sleep(60000);
- } catch (InterruptedException e) {
- }
-
- spawner.stopBrokers();
-
- }
-
- /**
- * @param amqDefaultPort the amqDefaultPort to set
- */
- public void setAmqDefaultPort(String amqDefaultPort) {
- this.amqDefaultPort = amqDefaultPort;
- }
-
- /**
- * @param numberOfSpokesPerHub the numberOfSpokesPerHub to set
- */
- public void setNumberOfSpokesPerHub(int numberOfSpokesPerHub) {
- this.numberOfSpokesPerHub = numberOfSpokesPerHub;
- }
-
- /**
- * @param numberOfHubs the numberOfHubs to set
- */
- public void setNumberOfHubs(int numberOfHubs) {
- this.numberOfHubs = numberOfHubs;
- }
-
- /**
- *
- */
- protected void createSpawners() {
- int port;
- amqPort = Integer.parseInt(System.getProperty("amq.starting.port.number", amqDefaultPort));
- System.out.println("Using starting activemq port number: " + amqPort);
-
- port = amqPort;
-
- spawners = new Spawner[numberOfSpokesPerHub * numberOfHubs + numberOfHubs];
- int spawnIdx = 0;
- Properties properties;
- for(int id = 0 ; id < numberOfHubs ; id++) {
- String kahadbPrefix = String.valueOf(id);
- String hubHostname = "localhost";
- String hubPortNumber = String.valueOf(port++);
- String spokeHostname = "localhost";
- String spokePortNumber = hubPortNumber;
- // Start the hub broker for the given id
- try {
- properties = generateProperties(String.valueOf(id), "hub",
- kahadbPrefix, hubHostname, hubPortNumber, spokeHostname,
- spokePortNumber);
- generateBrokerServiceConfigurationFiles(
- properties, "hub-" + id + ".properties",
- "hub-activemq.xml", "hub-activemq-" + id + ".xml");
- spawners[spawnIdx] = new Spawner(BrokerServiceProcess.class.getName(), "execute");
- List<String> jvmArgs = new LinkedList<String>();
- jvmArgs.add("-Dbroker.config.file=xbean:hub-activemq-" + id + ".xml");
- spawners[spawnIdx].setJVMArgs(jvmArgs);
- spawners[spawnIdx].setIdentifier("Hub:" + id);
- spawners[spawnIdx].spawnProcess();
- } catch (Exception e) {
- System.err.println("An exception was generated when spawning the embedded broker");
- e.printStackTrace();
- }
-
- try {
- // sleep for 5 seconds to allow the spawner hub broker to startup properly....
- Thread.sleep(5000);
- } catch (InterruptedException e) {
- }
- spawnIdx++;
- for (int spoke = 0; spoke < numberOfSpokesPerHub; spoke++) {
- // Start the spoke broker for the given id
- try {
- /*
- * Properties:
- * - spoke.suffix.name
- * - kahadb.dir
- * - kahadb.prefix
- * - hub.hostname
- * - hub.port.number
- * - spoke.hostname
- * - spoke.port.number
- */
- spokePortNumber = String.valueOf(port++);
- kahadbPrefix = String.valueOf(id) + "-" + String.valueOf(spoke);
- properties = generateProperties(String.valueOf(id) + "-" + String.valueOf(spoke),
- "spoke", kahadbPrefix, hubHostname, hubPortNumber,
- spokeHostname, spokePortNumber);
- generateBrokerServiceConfigurationFiles(
- properties, "spoke-" + id + "-" + spoke + ".properties",
- "spoke-activemq.xml", "spoke-activemq-" + id + "-" + spoke + ".xml");
- spawners[spawnIdx] = new Spawner(
- BrokerServiceProcess.class.getName(), "execute");
- List<String> jvmArgs = new LinkedList<String>();
- jvmArgs.add("-Dbroker.config.file=xbean:spoke-activemq-" + id + "-" + spoke + ".xml");
- spawners[spawnIdx].setJVMArgs(jvmArgs);
- spawners[spawnIdx].setIdentifier("Spoke:" + id + ":" + spoke);
- spawners[spawnIdx].spawnProcess();
- } catch (Exception e) {
- System.err
- .println("An exception was generated when spawning the embedded broker");
- e.printStackTrace();
- }
- spawnIdx++;
- }
- }
- }
-
- /**
- * @param id
- * @param amqType
- * @param kahadbPrefix
- * @param hubHostname
- * @param hubPortNumber
- * @param spokeHostname
- * @param spokePortNumber
- * @return
- */
- protected Properties generateProperties(String id, String amqType,
- String kahadbPrefix, String hubHostname, String hubPortNumber,
- String spokeHostname, String spokePortNumber) {
- Properties props = new Properties();
- props.setProperty(amqType + ".suffix.name", id);
- props.setProperty("kahadb.dir", amqType);
- props.setProperty("kahadb.prefix", kahadbPrefix);
- props.setProperty("hub.hostname", hubHostname);
- props.setProperty("hub.port.number", hubPortNumber);
- props.setProperty("spoke.hostname", spokeHostname);
- props.setProperty("spoke.port.number", spokePortNumber);
- return props;
- }
-}
@@ -130,20 +130,13 @@ public void setAmqPort(int amqPort) {
*
*/
protected void createSpawners() {
-// amqPort = Integer.parseInt(System.getProperty("amq.starting.port.number", "61616"));
System.out.println("Using starting activemq port number: " + amqPort);
Properties properties;
spawners = new Spawner[2 * numberOfMasterSlavesPairs];
for(int id = 0 ; id < numberOfMasterSlavesPairs ; id++) {
-// String kahadbPrefix = String.valueOf(id);
-// String masterHostname = "localhost";
-// String masterPortNumber = String.valueOf(amqPort + 2 * id);
-// String slaveHostname = "localhost";
-// String slavePortNumber = String.valueOf(amqPort + 2 * id + 1);
// Start the master broker for the given id
try {
- // properties = generateProperties(id, "master", kahadbPrefix, masterHostname, masterPortNumber, slaveHostname, slavePortNumber);
properties = new Properties();
populateProperties(TYPE.MASTER, properties, id);
String templatePrefix = this.getMasterTemplatePrefix();
@@ -153,6 +146,7 @@ protected void createSpawners() {
templatePrefix + ".xml", configFileName);
spawners[2 * id] = new Spawner(BrokerServiceProcess.class.getName(), "execute");
List<String> jvmArgs = new LinkedList<String>();
+ addToJVMArgs(jvmArgs);
jvmArgs.add("-Dbroker.config.file=xbean:" + configFileName);
spawners[2 * id].setJVMArgs(jvmArgs);
spawners[2 * id].setIdentifier("Master" + id);
@@ -174,8 +168,6 @@ protected void createSpawners() {
* - slave.port.number
*/
Thread.sleep(5000); // sleep for 5 seconds to allow the spawner master broker to startup properly....
- // spawnBroker(id, "slave", kahadbPrefix, masterHostname, masterPortNumber, slaveHostname, slavePortNumber);
- // properties = generateProperties(id, "slave", kahadbPrefix, masterHostname, masterPortNumber, slaveHostname, slavePortNumber);
String templatePrefix = this.getSlaveTemplatePrefix();
String configFileName = templatePrefix + "-" + id + ".xml";
properties = new Properties();
@@ -185,6 +177,7 @@ protected void createSpawners() {
templatePrefix + ".xml", configFileName);
spawners[2 * id + 1] = new Spawner(BrokerServiceProcess.class.getName(), "execute");
List<String> jvmArgs = new LinkedList<String>();
+ addToJVMArgs(jvmArgs);
jvmArgs.add("-Dbroker.config.file=xbean:" + configFileName);
spawners[2 * id + 1].setJVMArgs(jvmArgs);
spawners[2 * id + 1].setIdentifier("Slave" + id);
@@ -148,21 +148,12 @@ public void setNumberOfNetworkBrokers(int numberOfNetworkBrokers) {
*
*/
protected void createSpawners() {
-// amqPort = Integer.parseInt(System.getProperty("amq.starting.port.number", "61616"));
logger.info("Using starting activemq port number: " + amqPort);
-// int port = amqPort;
Properties properties;
spawners = new Spawner[numberOfNetworkBrokers * numberOfNetworks];
int idx = 0;
-// String networkHostname = "localhost";
-// String hostname = "localhost";
for(int net = 0 ; net < numberOfNetworks ; net++) {
-// String kahadbPrefix = net + "-0";
-// String networkPortNumber = String.valueOf(port++);
-// String portNumber = String.valueOf(port);
-// properties = generateProperties(net + "-0", "main", kahadbPrefix,
-// hostname, portNumber, networkHostname, networkPortNumber);
properties = new Properties();
populateProperties(TYPE.MAIN, properties, net);
// Start the master broker for the given id
@@ -175,6 +166,7 @@ protected void createSpawners() {
spawners[idx] = new Spawner(
BrokerServiceProcess.class.getName(), "execute");
List<String> jvmArgs = new LinkedList<String>();
+ addToJVMArgs(jvmArgs);
jvmArgs.add("-Dbroker.config.file=xbean:" + mainConfigFileName);
spawners[idx].setJVMArgs(jvmArgs);
spawners[idx].setIdentifier("MainBroker" + net + "-0");
@@ -186,12 +178,6 @@ protected void createSpawners() {
}
idx++;
for(int id = 1 ; id < numberOfNetworkBrokers ; id++) {
-// kahadbPrefix = net + "-" + id;
-// networkPortNumber = String.valueOf(port++);
-// portNumber = String.valueOf(port);
-// properties = generateProperties(net + "-" + id, "network",
-// kahadbPrefix, hostname, portNumber, networkHostname,
-// networkPortNumber);
properties = new Properties();
this.populateProperties(TYPE.NETWORKED, properties, id);
// Start the master broker for the given id
@@ -203,6 +189,7 @@ protected void createSpawners() {
networkedConfigFileName);
spawners[idx] = new Spawner(BrokerServiceProcess.class.getName(), "execute");
List<String> jvmArgs = new LinkedList<String>();
+ addToJVMArgs(jvmArgs);
jvmArgs.add("-Dbroker.config.file=xbean:" + networkedConfigFileName);
spawners[idx].setJVMArgs(jvmArgs);
spawners[idx].setIdentifier("NetworkBroker" + net + "-" + id);
@@ -105,7 +105,7 @@ protected void populateProperties(Properties props, int id) {
};
spawner.execute();
- logger.info("All brokers have been started"); // Thread.sleep(15000);
+ logger.info("All brokers have been started");
spawner.stopBrokers();

0 comments on commit 766c5db

Please sign in to comment.