public static void main(String[] args) {
AbstractApplicationContext context =
new ClassPathXmlApplicationContext("/META-INF/spring/integration/cafeDemo-control-bus.xml");
WaiterMonitor waiterMonitor = (WaiterMonitor) context.getBean("waiterMonitor");
int totalDeliveries = 0;
while (totalDeliveries <= 3) {
try {
Thread.sleep(1000);
}
catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
totalDeliveries = (Integer)waiterMonitor.sendControlScript("waiter.totalDeliveries");
logger.info("Total cafe deliveries: " + totalDeliveries);
if (totalDeliveries > 3) {
logger.info("stopping orders...");
waiterMonitor.sendControlScript("cafe.stop()");
logger.info("orders stopped");
}
}
context.close();
System.exit(0);