Link to home
Start Free TrialLog in
Avatar of Valeri
ValeriFlag for Bulgaria

asked on

What server do I need?!

Hi everybody,
I have written an client application with Swing interface, that reads and writes some data to MySQL database. Next to this database, on the server side, I need some kind of server that will send some messages to the clients, considering users logged on the client side. I mean when some message is intended for some user, this message to be send only to this user.
So, what kind of server do I need? RMI Server, something like servlet, or something else?
I'm not so familiar with server side technologies, that's way I'm asking you.
In my poor opinion RMI server is the best solution for me. But it will support some kind of multitasking... I suppose?!?! How to do this?
Also, I will appreciate some cool articles, related to my problem.
Thanks in advance!
Best regards,
Valeri
ASKER CERTIFIED SOLUTION
Avatar of Tommy Braas
Tommy Braas
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Valeri

ASKER

If  I use RMI I don't think that I need sockets?! Except the communication with the client this server must work permanently.... and if it is informed from the database "Send message to this user", the server must send this message immediately. So RMI is the best solution?
Best regards,
Valeri
>>  If  I use RMI I don't think that I need sockets?
From your point of view that assumption is correct. Under the covers RMI uses sockets, but that will be of no concern to you.

>> So RMI is the best solution?
RMI will make things a lot easier for you than sockets. RMI also has some nice features that you would be able to use, like naming and lookup.
Avatar of Valeri

ASKER

Could you please send me some articles, related to managing different users(clients) in my RMI server. I suppose that I'll have to use threads. Working with threads is very difficult, so I need some code examples. Do you have any clue, where can I find such kind of articles?
Thanks in advance!
Best regards,
Valeri
Read the first link I provided, it has everything you need regarding RMI.

Like you stated, threading is difficult. There are many, many articles on the subject. I would recommend that you go to your local bookstore and pick up O'Reilly's books on Java Threads and on RMI.

http://www.onjava.com/ is another great resource, so is http://sys-con.com/java/ and http://java.net/
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ShannonE
ShannonE

I would suggest using JSP instead of RMI, it should be a lot simpler. When the user logs on through their web browser, the webserver that executes the JSP code presents the user with his/her messages. What exactly is the requirements of your system?? You need to explain more clearly....

Remember: focus on requirements 1st, only then worry about how to implement it.
ShannonE, the requirements are that the Swing client needs to communicate with a server to receive messages.

A JSP in this case would not be a solution because a) it's html based and b) it is pull, i.e. the server can't send messages to the clients, the clients have to get the messages.
"the requirements are that the Swing client needs to communicate with a server to receive messages"

That's not a requirement, that's an implementation. A requirement would be something like "a user needs to register for a course, and then recieve notification of acceptance/refusal from the instructor."  In that case I would suggest JSP because it's much easier.  The user could register through the web and check his registration status through the web (eliminating need for messaging) or simply have his status emailed to him.

...Or maybe he would need message based architecture, it would depend on what he really wants to do. that's why I asked for more detail ;)
>> That's not a requirement, that's an implementation.
Oh, but it is a requirement. That has been made abundantly clear in the question. That it be Swing might not have been an initial requirement, but is possible. Depends on at which level you look at the requirements doesn't it!?!

>> The user could register through the web and check his registration status through the web (eliminating need for messaging) or simply have his status emailed to him.
I see no mention of this use case anywhere.

However there is a mention of messages being sent to clients, i.e. server-push, not client-pull.
Avatar of Valeri

ASKER

Hi again :-)
orangehead911 is right! My client is Swing  application. I need a server, that will sent notifications to the clients, and I'm looking for the best technology. RMI, CORBA or something else, I don't know which one is the most appropriate?!?!
The only thing that I know is that I don't need something like JSP's, because I have nothing common with web browser's.
So, for now, RMI is the best solution for me or not? I think "Yes", but is there any other opinions?
Best Regards,
Valeri
I would vote for RMI.
Avatar of Valeri

ASKER

... and I'm still looking for some good links related to RMI.
How to send message to only one or to group of users. Do I need threads on the server or not?!
If I need threads is there a links with code that explains how to use threads in this case?
Best Regards,
Valeri
I had posted a link for RMI examples above. You can search on the same site for threads. It has loads of examples.
I second mayankeagle's vote.

There are several links in this thread, plenty to start with. You could also do a search on Google: http://www.google.com/search?hl=en&ie=UTF-8&oe=UTF-8&q=java+rmi+tutorial&btnG=Google+Search

Good luck!
Valeri, if your application is going to be complex, then JMS (Java Message Service) might be a better option. You can think of it as another abstraction above RMI, in other words it'll be harder to get JMS to work, but once its working it'll be easier to develop applications.

http://java.sun.com/j2ee/1.4/docs/tutorial/doc/index.html

(See Chapter 33 & 34 on JMS in above tutorial)
The downsides to using JMS in this case, is that an additional jar would have to be added to the client application and the server would have to be running a J2EE app server with JMS support. However, it is certainly an option.