-
Notifications
You must be signed in to change notification settings - Fork 0
/
MOMServer.java
43 lines (31 loc) · 1.16 KB
/
MOMServer.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import exceptions.EMomError;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import java.rmi.server.UnicastRemoteObject;
import static java.lang.System.exit;
public class MOMServer extends MOMServant {
public MOMServer() throws EMomError {}
private static int PORT = 1099;
public static void main(String[] args) {
if (args.length > 0) {
PORT = Integer.parseInt(args[0]);
}
System.out.println("Starting MOM Server...");
MsgQ_Init();
System.out.println("MOM Server up ✓");
}
private static void MsgQ_Init() {
try {
MOMServant mom = new MOMServant();
MOM momStub = (MOM) UnicastRemoteObject.exportObject(mom, 0);
// Create the RMI registry
Registry registry = LocateRegistry.createRegistry(PORT);
System.out.println("RMI registry created on port "+ PORT + " ✓");
// Register the stub in the registry
registry.rebind("MOM", momStub);
} catch (Exception e) {
System.out.println("Error starting the server → " + e.getMessage());
exit(1);
}
}
}