1 18 package org.apache.activemq.tool; 19 20 import org.apache.activemq.tool.properties.JmsClientSystemProperties; 21 import org.apache.activemq.tool.properties.JmsConsumerSystemProperties; 22 import org.apache.activemq.tool.properties.JmsConsumerProperties; 23 import org.apache.activemq.tool.properties.JmsClientProperties; 24 import org.apache.activemq.tool.sampler.ThroughputSamplerTask; 25 26 import javax.jms.JMSException ; 27 import java.util.Properties ; 28 29 public class JmsConsumerSystem extends AbstractJmsClientSystem { 30 protected JmsConsumerSystemProperties sysTest = new JmsConsumerSystemProperties(); 31 protected JmsConsumerProperties consumer = new JmsConsumerProperties(); 32 33 public JmsClientSystemProperties getSysTest() { 34 return sysTest; 35 } 36 37 public void setSysTest(JmsClientSystemProperties sysTestProps) { 38 sysTest = (JmsConsumerSystemProperties)sysTestProps; 39 } 40 41 public JmsClientProperties getJmsClientProperties() { 42 return getConsumer(); 43 } 44 45 public JmsConsumerProperties getConsumer() { 46 return consumer; 47 } 48 49 public void setConsumer(JmsConsumerProperties consumer) { 50 this.consumer = consumer; 51 } 52 53 protected void runJmsClient(String clientName, int clientDestIndex, int clientDestCount) { 54 ThroughputSamplerTask sampler = getTpSampler(); 55 56 JmsConsumerClient consumerClient = new JmsConsumerClient(consumer, jmsConnFactory); 57 consumerClient.setClientName(clientName); 58 59 if (sampler != null) { 60 sampler.registerClient(consumerClient); 61 } 62 63 try { 64 consumerClient.receiveMessages(clientDestIndex, clientDestCount); 65 } catch (JMSException e) { 66 e.printStackTrace(); 67 } 68 } 69 70 public static void main(String [] args) { 71 JmsConsumerSystem sys = new JmsConsumerSystem(); 72 sys.configureProperties(AbstractJmsClientSystem.parseStringArgs(args)); 73 74 try { 75 sys.runSystemTest(); 76 } catch (JMSException e) { 77 e.printStackTrace(); 78 } 79 } 80 } 81 | Popular Tags |