source: trunk/src/test/java/omq/test/stopBroker/BrokerKillerImpl.java @ 62

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

Adding @MultiMethod?
Broker is not a singleton.

File size: 862 bytes
Line 
1package omq.test.stopBroker;
2
3import omq.client.annotation.AsyncMethod;
4import omq.common.broker.Broker;
5import omq.server.RemoteObject;
6
7public class BrokerKillerImpl extends RemoteObject implements BrokerKiller {
8
9        /**
10         *
11         */
12        private static final long serialVersionUID = 1L;
13
14        private Broker broker;
15
16        public BrokerKillerImpl(Broker broker) {
17                this.broker = broker;
18        }
19
20        @Override
21        @AsyncMethod
22        public void killServerBroker() throws Exception {
23                System.out.println("Kill broker");
24
25                // A remote method cannot stop the Broker because the stop method is
26                // thought to wait for the methods finish before it stops. For this
27                // reason it actually cannot stop itself
28                new Thread() {
29                        public void run() {
30                                try {
31                                        Thread.sleep(1000);
32                                        broker.stopBroker();
33                                } catch (Exception e) {
34                                        e.printStackTrace();
35                                }
36                        };
37                }.start();
38
39        }
40
41}
Note: See TracBrowser for help on using the repository browser.