Hello emoejoe,
On Jan 23, 2008 7:04 PM, emoejoe <[EMAIL PROTECTED]> wrote:
>
> Hi
>
> I have a question and here are my requirements
>
> Client <-> Server A <-> Server B
>
> I'd like to implement client socket on server A to comunicate with server B.
> First the request is triggered by client and Server A retrieve the request
> msg from Client do some processing and send a request to Server B to process
> another logic, in the meanwhile Server B 's going to send response back to
> Server A and Server A will do some processing again before pass the response
> back to Client.
>
> the requirement on the connection between Server A and Server B is allowed
> only one persistent socket connection on Server B, so that's mean Server A
> must create and use only one socket connection in order to communicate with
> Server B. But the problem is I have many many Clients which every single
> Client's gonna send the different msg to Server A and B, if I create 30
> threads to be listeners for Client on Server A and in order to send the
> requests to Server B by using just only one object of socket connection.
> some threads in Server A may get the wrong response from Server B. but if i
> implement synchronized block on Server A like this
>
> synchronized(socketConnectionObject) {
> write -> to Server B
> read -> from Server B
> }
>
> if I have 100 Clients in the same time, the Client #100 must wait till
> Client #1-#99 completed everything, This is not async.
>
> But if i use NIO , How to implement just only one socket connection on
> Server A so that this object can be used by those 30 threads in Async.
>
> How can i use MINA to solve this problem? Please kindly advise
It seems like you are writing a kind of proxy server.
In MINA, all operations are asynchronous. Write operation is also
asynchronous. MINA maintains an internal write request, so you can
write as many times as you want not worring about synchronization
issue. You don't even need a synchronized block in this case.
HTH,
Trustin
--
what we call human nature is actually human habit
--
http://gleamynode.net/
--
PGP Key ID: 0x0255ECA6