source: trunk/objectmq/test/test2/ClientTest.java @ 29

Last change on this file since 29 was 29, checked in by stoda, 11 years ago

Singleton didn't worked in parallel threads solved adding synchronized.
Num threads by property added.
Example with different threads added.

File size: 1.2 KB
Line 
1package test2;
2
3import java.util.Properties;
4
5import omq.common.broker.Broker;
6import omq.common.util.ParameterQueue;
7
8public class ClientTest {
9
10        public static void main(String[] args) throws Exception {
11                Properties env = new Properties();
12                env.setProperty(ParameterQueue.USER_NAME, "guest");
13                env.setProperty(ParameterQueue.USER_PASS, "guest");
14
15                // Set host info of rabbimq (where it is)
16                env.setProperty(ParameterQueue.SERVER_HOST, "127.0.0.1");
17                env.setProperty(ParameterQueue.SERVER_PORT, "5672");
18                // env.setProperty(ParameterQueue.SERIALIZERNAME,
19                // "omq.common.util.Serializers.GsonImp");
20                env.setProperty(ParameterQueue.ENABLECOMPRESSION, "false");
21
22                // Set info about where the message will be sent
23                env.setProperty(ParameterQueue.RPC_EXCHANGE, "rpc_exchange");
24                // Set info about the queue & the exchange where the ResponseListener
25                // will listen to.
26                env.setProperty(ParameterQueue.RPC_REPLY_QUEUE, "reply_queue");
27                env.setProperty(ParameterQueue.EVENT_REPLY_QUEUE, "event_queue");
28
29                Broker.initBroker(env);
30
31                String car = "audi";
32                String tfn = "aifon";
33                Object lock = new Object();
34                CarThread t1 = new CarThread(car, tfn, lock);
35                MobileThread t2 = new MobileThread(tfn, lock);
36
37                t1.start();
38                t2.start();
39               
40        }
41}
Note: See TracBrowser for help on using the repository browser.