aspose file tools*
The moose likes Distributed Java and the fly likes What would be the best distributed method to use? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Distributed Java
Bookmark "What would be the best distributed method to use?" Watch "What would be the best distributed method to use?" New topic
Author

What would be the best distributed method to use?

Ben Flowers
Greenhorn

Joined: Sep 12, 2011
Posts: 17
Hi,
I am trying to implement a chat server on the amazon EC2 cloud for a university project.I have decided to use callbacks on the client end using the observer pattern
I initially thought of using RMI but it was an absolute pain to get working on EC2 with callbacks, and i would be limited to using java clients.
So i switched to JAX-WS so that i could use SOAP on a given client, but i can only seem to send messages to the server and get data back when the client requests it rather than the sever update observers when data has been changed (e.g. the client sends a message to the chatroom)

So i thought i would ask, does anyone know what would be a good solution to my problem?
I need to be able to make callbacks from the server to the client and not be limited to Java clients.
Is this possible?
Any help would be great, even if it is only to tell me i NEED to use RMI
Thanks,
Ben
Pat Farrell
Rancher

Joined: Aug 11, 2007
Posts: 4659
    
    5

Use REST. Do *not* use RMI.
Ben Flowers
Greenhorn

Joined: Sep 12, 2011
Posts: 17
Thanks Pat,
Tried looking at some examples of REST. I cant really see how REST can perform an RPC on the client side though?
Do you know where there is any tutorials etc... as i cant seem to find any
Cheers,
Ben
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12821
    
    5
The Web ServiceFAQ here at the ranch may help - there are excellent links to articles that will get you thinking in RESTful terms.

The RESTful architecture requires that you stop thinking in terms of RPC and start thinking in terms of resources.

In the Chat case one resource is the chat buffer, you GET the current state of the chat buffer and POST a new message to the chat buffer.

Bill

Ben Flowers
Greenhorn

Joined: Sep 12, 2011
Posts: 17
Thanks William,
Would that not mean that the client would have to continualy check the chatbuffer rather than simply being informed of when it changes state?
Ben
Pat Farrell
Rancher

Joined: Aug 11, 2007
Posts: 4659
    
    5

You have to understand that REST is simply about messages. You use normal HTTP communications, and send Strings back and forth. So normal HTTP rules apply.

This is great, because HTTP is allowed though all known firewalls, and RMI is nearly impossible to get "allowed" though any corporate firewalls.

You need to simply design around messages.

One might be for the client to issue a GET for "characters typed by other user" and you can POST characters typed by the specific client on their computer.

There is no need to poll for characters available, just have a loop, that GETs the characters. It will get what is available, and then issue the next GET. If there is nothing to send, the GET can wait.

You probably want to have the HTTP client code in a separate thread, so you can decide that you are tired of waiting on the GET.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: What would be the best distributed method to use?