1 18 package org.apache.activemq.tool; 19 20 import org.apache.activemq.tool.properties.JmsClientSystemProperties; 21 import org.apache.activemq.tool.properties.JmsProducerSystemProperties; 22 import org.apache.activemq.tool.properties.JmsProducerProperties; 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 JmsProducerSystem extends AbstractJmsClientSystem { 30 protected JmsProducerSystemProperties sysTest = new JmsProducerSystemProperties(); 31 protected JmsProducerProperties producer = new JmsProducerProperties(); 32 33 public JmsClientSystemProperties getSysTest() { 34 return sysTest; 35 } 36 37 public void setSysTest(JmsClientSystemProperties sysTestProps) { 38 sysTest = (JmsProducerSystemProperties)sysTestProps; 39 } 40 41 public JmsClientProperties getJmsClientProperties() { 42 return getProducer(); 43 } 44 45 public JmsProducerProperties getProducer() { 46 return producer; 47 } 48 49 public void setProducer(JmsProducerProperties producer) { 50 this.producer = producer; 51 } 52 53 protected void runJmsClient(String clientName, int clientDestIndex, int clientDestCount) { 54 ThroughputSamplerTask sampler = getTpSampler(); 55 56 JmsProducerClient producerClient = new JmsProducerClient(producer, jmsConnFactory); 57 producerClient.setClientName(clientName); 58 59 if (sampler != null) { 60 sampler.registerClient(producerClient); 61 } 62 63 try { 64 producerClient.sendMessages(clientDestIndex, clientDestCount); 65 } catch (JMSException e) { 66 e.printStackTrace(); 67 } 68 } 69 70 public static void main(String [] args) { 71 JmsProducerSystem sys = new JmsProducerSystem(); 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 |