日期:2014-05-18 浏览次数:20708 次
public class ClientSideLoadBalancingExample extends HornetQExample
{
public static void main(final String[] args)
{
new ClientSideLoadBalancingExample().run(args);
}
}
public abstract class HornetQExample
{
protected static Logger log = Logger.getLogger(HornetQExample.class.getName());
private Process[] servers;
protected boolean failure = false;
protected String serverClasspath;
protected String serverProps;
public abstract boolean runExample() throws Exception;
private boolean logServerOutput;
protected String[] configs;
protected boolean runServer;
protected void run(final String[] configs)
{
String runServerProp = System.getProperty("hornetq.example.runServer");
String logServerOutputProp = System.getProperty("hornetq.example.logserveroutput");
serverClasspath = System.getProperty("hornetq.example.server.classpath");
runServer = runServerProp == null ? true : Boolean.valueOf(runServerProp);
logServerOutput = logServerOutputProp == null ? false : Boolean.valueOf(logServerOutputProp);
serverProps = System.getProperty("hornetq.example.server.args");
if (System.getProperty("hornetq.example.server.override.args") != null)
{
serverProps = System.getProperty("hornetq.example.server.override.args");
}
System.out.println("serverProps = " + serverProps);
HornetQExample.log.info("hornetq.example.runServer is " + runServer);
this.configs = configs;
try
{
if (runServer)
{
startServers();
}
if (!runExample())
{
failure = true;
}
System.out.println("example complete");
}
catch (Throwable e)
&nbs