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

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

J

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