Thank you Marteen,
you are right I found the error in my ProtocolDecoder. The problem was
that I did not considered the possibility that the ByteBuffer to decode
contained more than one message.
It worked ok if you are in a single thread scenario because there where
no possibility to group messages in single write (I always waited the
answer of a message before sending a new one).
Now it is working fine with multiple threads using the IoSession.
Stefano
Maarten Bosteels wrote:
Hi Stefano,
I haven't tried it myself but I think MINA was designed to allow
multiple
threads to
write to the same IoSession instance.
If it doesn't work, try to create a simple TestCase that reproduces the
problem.
Maarten
On 7/13/07, Stefano Antonelli <[EMAIL PROTECTED]>
wrote:
Hi 向秦贤,
thank you for your prompt replay.
The code I am writing is a Diameter test client
(http://www.ietf.org/rfc/rfc4006.txt). I have to simulate a load caming
from a multi-threaded server that uses Diameter for Accounting
purposes.
Because of that the different commands sent from the different threads
are not related each other.
I was thinking not to use any queue in order to gather all the commands
but I wanted to directly use IoSession from the different thread to
send
the commands.
If I understand correctly IoSession does not support concurrent use of
the sendMessage method, in this case I must use some sort of queueuing
in order to serialize the commands sent by the different threads.
thanks again
Stefano
向秦贤 wrote:
> Hi,
> Just awt event processing like.
> there are
> 1,don't share IoSession self in multiple thread. If there are some
stuff
> need shared, just create other state object by yourself, IoSession
should
> not and not know your state.
> 2, even if mina to do it with queue support, nor use it. Your
protocol
> must
> assure some order of command.
> 3, I guess if you want Full Duplex works, but you must assure
command
> orders. As I known, there are few protocol works in network in
tcp. udp
> works for it. If tcp, you can check out jira with a ftp client
provide
> multiple IoSession community local.
>
> Regards
>
> 2007/7/13, Stefano Antonelli <[EMAIL PROTECTED]>:
>>
>> Hi All,
>>
>> I want to write a multi threaded client protocol using Mina
but I am
>> having some problem.
>>
>> I did the fallowing:
>> - I wrote a ProtocolDecoded/ProtocolEncoder ant tested it
carefully
>> - The protocol is TCP
>> - The usage scenario is:
>>
>> 1. I configure a Connector to use the Encoder/Decoder
>> 2. I connect it and get The IoSession
>> 3. I share the IoSession between some threads. Each thread
calls
>> session.write, that means taht the IoSession is accessed
>> concurrently.
>> 4. I also wrote an IoHandler class in order to process the
answer
>> from the server
>>
>> The problem is that it is working ok with just one thread but
it is
>> failing to send some message in a multi threaded scenario.
>> I checked my code and it seems ok.
>> Am I doing something wrong with Mina? Is it ok to concurrently
access
>> the
>> IoSession from different threads?
>>
>> Thank you all
>>
>> Stefano
>>
>>
>
>
|