On Distributed Computing using RMI
28/Jan 2006
Ok, so I have this assignment in one of my courses at the University of Sussex, Distributed Systems. The thing is that we need to implement a distributed event notification system, in which clients subscribe themselves to the server to which some event generators sends their events.
All of this, using RMI (Remote Method Invocation) in Java.
The assignment is an introduction to distributed objects in java by implementing this little system. In it, each Event Generator, sends events to the server, made of an identification string and a message (in fact, it could be any kind of object).
On the other hand, the server get subscriptions of clients. These send the server a regular expression and a timeout, each of which would be used to choose among the different events received and to set a maximu time in which the subscription is valid. When doing so, the server sets up a callback function to the clients so, when a matching event is received, the server has a way to send the clients the object (event). I think it can be better understood by looking at the graph above.
So far, it’s been quite interesting to learn this kind of distributed framework, although java is not my kind of language. I want to do some more researh on how to do this kind of things with other languages like ruby o r python. Seems to me interesting.
Here is a little bit of the code used, just for curiosity:
[sourcecode lang=“java”] public static void main(String[] args) { if (System.getSecurityManager() == null) { System.setSecurityManager(new RMISecurityManager()); } try { EventNotificationServer server = new EventNotificationServerImpl(); String hostName = InetAddress.getLocalHost().getHostName(); Naming.rebind(“//” + hostName + “/” + EventNotificationServer.rmiName, server); System.out.println(“EventNotificationServerImpl bound to “ + hostName);
} catch (Exception e) {
System.err.println("EventNotificationServerImpl exception: "
+ e.getMessage());
e.printStackTrace();
}
} [/sourcecode]
The assignment is an introduction to distributed objects in java by implementing this little system. In it, each Event Generator, sends events to the server, made of an identification string and a message (in fact, it could be any kind of object).
On the other hand, the server get subscriptions of clients. These send the server a regular expression and a timeout, each of which would be used to choose among the different events received and to set a maximum time in which the subscription is valid. When doing so, the server sets up a callback function to the clients so, when a matching event is received, the server has a way to send the clients the object (event). I think it can be better understood by looking at the graph above.
So far, it’s been quite interesting to learn this kind of distributed framework, although java is not my kind of language. I want to do some more researh on how to do this kind of things with other languages like ruby o r python. Seems to me interesting.
Here is a little bit of the code used, just for curiosity:
[sourcecode lang=“java”] public static void main(String[] args) { if (System.getSecurityManager() == null) { System.setSecurityManager(new RMISecurityManager()); } try { EventNotificationServer server = new EventNotificationServerImpl(); String hostName = InetAddress.getLocalHost().getHostName(); Naming.rebind(“//” + hostName + “/” + EventNotificationServer.rmiName, server); System.out.println(“EventNotificationServerImpl bound to “ + hostName);
} catch (Exception e) {
System.err.println("EventNotificationServerImpl exception: "
+ e.getMessage());
e.printStackTrace();
}
} [/sourcecode]