public static void main(String[] args) throws Exception {
//
// Creating and initially configuring the broker.
Broker broker = new Broker();
broker.setTmp(new File("./tmp"));
broker.setConfig(createConfig());
//
// The broker starts asynchronously. The runnable is invoked once
// the broker if fully started.
System.out.println("Starting the broker.");
broker.start(new Runnable(){
public void run() {
System.out.println("The broker has now started.");
System.out.println("Press enter to change the broker port...");
}
});
System.in.read();
System.out.println("Updating the broker configuration.");
//
// The configuration update also occurs asnyc.
broker.update(createUpdate(), new Runnable() {
public void run() {
System.out.println("The configuration has been applied.");
System.out.println("Press enter to stop the broker...");
}
});
System.in.read();
System.out.println("Stopping the broker.");
//
// The broker stops asynchronously. The runnable is invoked once
// the broker if fully stopped.
broker.stop(new Runnable(){
public void run() {
System.out.println("The broker has now stopped.");
}
});