U
udupi_mail
I have a situation where I will be writing a standalone Multithreaded
Server(Server-1) (which also acts as a delegate client to another
server appln(Server-2, written by 3rd party), which can only
communicates thru sockets).
Multiple clients(webservices, EJBs ..I'll call this as Clients-1) call
on Server-1 which is listening on a pre-defined port. On every client
request, Server-1 will spawn a new thread to handle the client socket.
Now each of these threads in turn would need to connect to Server-2.
Server-2 will be listening on pre-defined ports. Depending on the
configuration there may be 3-6 ports it is listening on.
The restriction is, each of these threads(created in Server-1) cannot
open their own client socket instances and IO-streams to connect to the
Server-2.
The socket and the streams should be established at startup whcih
depends on the config, and all threads would have to use the same
stream references for IO.
So to be precise, is there a way in java that multiple threads
read/write on the same socket instance streams?
In this case will by read/write methods have to be synchronized? Can I
implement asynchronous communication between Server-1 and Server-2?
...would have been nice if there was a possibility of using JMS.
How do I handle a situation where client-thread1 had read data
belonging to client-thread2? Is there some callback mechanism?
Any feedback will be very very helpful. Sorry for being so wordy.
- Guru.
Server(Server-1) (which also acts as a delegate client to another
server appln(Server-2, written by 3rd party), which can only
communicates thru sockets).
Multiple clients(webservices, EJBs ..I'll call this as Clients-1) call
on Server-1 which is listening on a pre-defined port. On every client
request, Server-1 will spawn a new thread to handle the client socket.
Now each of these threads in turn would need to connect to Server-2.
Server-2 will be listening on pre-defined ports. Depending on the
configuration there may be 3-6 ports it is listening on.
The restriction is, each of these threads(created in Server-1) cannot
open their own client socket instances and IO-streams to connect to the
Server-2.
The socket and the streams should be established at startup whcih
depends on the config, and all threads would have to use the same
stream references for IO.
So to be precise, is there a way in java that multiple threads
read/write on the same socket instance streams?
In this case will by read/write methods have to be synchronized? Can I
implement asynchronous communication between Server-1 and Server-2?
...would have been nice if there was a possibility of using JMS.
How do I handle a situation where client-thread1 had read data
belonging to client-thread2? Is there some callback mechanism?
Any feedback will be very very helpful. Sorry for being so wordy.
- Guru.