You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by chihiro <ga...@gmail.com> on 2007/10/09 11:52:01 UTC

Reusing SocketConnector

My requirement is simple:

1) Object <=read from a queue (ConcurrentLinkedQueue)
2) Connect to a remote server via MINA and transmit the Object.

In one of the previous posts, Trustin mentioned that one could just reuse
the SocketConnector
if one were connecting to the same host.

Being a newbie to MINA:
a) Is it ok for me to reuse the SocketConnector in each thread but just pass
in a different IoHandler to connect( ... ) ?
b) What does the handler.multiton package give me ? Are there samples on how
to use it ?
c) I'm starting a new Thread whenever a new item is dequeued. Is this a wise
move ?

Thanks



-- 
View this message in context: http://www.nabble.com/Reusing-SocketConnector-tf4593153s16868.html#a13112488
Sent from the Apache MINA Support Forum mailing list archive at Nabble.com.


Re: Reusing SocketConnector

Posted by Mike Heath <mh...@apache.org>.
chihiro wrote:
> My requirement is simple:
> 
> 1) Object <=read from a queue (ConcurrentLinkedQueue)
> 2) Connect to a remote server via MINA and transmit the Object.
> 
> In one of the previous posts, Trustin mentioned that one could just reuse
> the SocketConnector
> if one were connecting to the same host.
> 
> Being a newbie to MINA:
> a) Is it ok for me to reuse the SocketConnector in each thread but just pass
> in a different IoHandler to connect( ... ) ?
> b) What does the handler.multiton package give me ? Are there samples on how
> to use it ?
> c) I'm starting a new Thread whenever a new item is dequeued. Is this a wise
> move ?

a) I don't see anything in the MINA API for specifying an IoHandler when 
calling connect(...) but this might be a good feature to add.

b) handler.multiton routes message to different handlers based on the 
class type of the messages received.

c) I don't see why you would want to start a new thread since everything 
in MINA is done asynchronously and MINA uses it's own threads for IO. 
Perhaps you could elaborate on why you're doing this.

-Mike