1 18 package org.apache.activemq.benchmark; 19 20 21 25 public class ProducerConsumer extends Producer { 26 27 private Consumer consumer = new Consumer(); 28 29 public static void main(String [] args) { 30 ProducerConsumer tool = new ProducerConsumer(); 31 if (args.length > 0) { 32 tool.setUrl(args[0]); 33 } 34 if (args.length > 1) { 35 tool.setTopic(parseBoolean(args[1])); 36 } 37 if (args.length > 2) { 38 tool.setSubject(args[2]); 39 } 40 if (args.length > 3) { 41 tool.setDurable(Boolean.getBoolean(args[3])); 42 } 43 if (args.length > 4) { 44 tool.setConnectionCount(Integer.parseInt(args[4])); 45 } 46 try { 47 tool.run(); 48 } 49 catch (Exception e) { 50 System.out.println("Caught: " + e); 51 e.printStackTrace(); 52 } 53 } 54 55 public ProducerConsumer() { 56 } 57 58 public void run() throws Exception { 59 consumer.start(); 60 consumer.subscribe(); 61 start(); 62 publish(); 63 } 64 65 public void setTopic(boolean topic) { 66 super.setTopic(topic); 67 consumer.setTopic(topic); 68 } 69 70 public void setSubject(String subject) { 71 super.setSubject(subject); 72 consumer.setSubject(subject); 73 } 74 75 public void setUrl(String url) { 76 super.setUrl(url); 77 consumer.setUrl(url); 78 } 79 80 protected boolean useTimerLoop() { 81 return false; 82 } 83 } 84 | Popular Tags |