Line | |
---|
1 | package omq.test.stopBroker; |
---|
2 | |
---|
3 | import omq.client.annotation.AsyncMethod; |
---|
4 | import omq.common.broker.Broker; |
---|
5 | import omq.server.RemoteObject; |
---|
6 | |
---|
7 | public 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.