Ok, I've asked similar question a few days back, but it was marked as too general so I'll try one more time.

I have an assingment to create a master-slave application out of client-server. Professor specifically said that slave should not know the task until master had sent it to him. My plan is to pass task object to slave, which should run it, and after finishing send results back to the master.

To this moment i tried several things:

  1. I've used RMI mechanishm to export task object from master and lookup it from slave. And it is working, but as i found out when slave calls a stub method it uses master's resources. And i can't have that.

  2. I've tried to send a task using JMS/ActiveMQ. The problem here is that in order to deserialize object on slave you need to have original class there. But i see it as a condition violation.

How can i transmit a task from master to slave under this condition?

有帮助吗?

解决方案

With RMI, it is possible to not only do remote invocations (as the name implies) but also to pass objects by value between nodes, i.e. your task would not implement Remote and be passed by reference but implement Serializable and be passed by value. For the receiver to be able to handle what it gets, there is the RMIClassLoader.

See http://code.nomad-labs.com/2010/03/26/an-improved-rmi-tutorial-with-eclipse/ or http://www.javaworld.com/jw-12-1998/jw-12-enterprise.html?page=1 for examples.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top