KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > activemq > tool > JmsProducerSystem


1 /**
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one or more
4  * contributor license agreements. See the NOTICE file distributed with
5  * this work for additional information regarding copyright ownership.
6  * The ASF licenses this file to You under the Apache License, Version 2.0
7  * (the "License"); you may not use this file except in compliance with
8  * the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */

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 JavaDoc;
27 import java.util.Properties JavaDoc;
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 JavaDoc 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 JavaDoc e) {
66             e.printStackTrace();
67         }
68     }
69
70     public static void main(String JavaDoc[] args) {
71         JmsProducerSystem sys = new JmsProducerSystem();
72         sys.configureProperties(AbstractJmsClientSystem.parseStringArgs(args));
73
74         try {
75             sys.runSystemTest();
76         } catch (JMSException JavaDoc e) {
77             e.printStackTrace();
78         }
79     }
80 }
81
Popular Tags