Dear All, 
 
      We have developed one server using Apache MINA V2.0.9 where multiple
vendors connect and send the messages which needs to be processed and then
response have to be sent back to vendor. Currently we have put a strategy
that vendor has to send one message per connection and after getting
response or timeout vendor has to close the connection.
      
      We also have persistance connection open from our MINA based server
with third party server whcih is tcp/ip channel and for each vendor request
we get we have to send the received message to this third party server. Past
3-4 days we have observed that some of the received vendor messages when we
try to send on the third party server over persistance connection they are
actually not sent even after calling iosession.write(object message) method.
This operation is asynchronous; IoHandler.messageSent(IoSession, Object)
will be invoked when the message is actually sent to remote peer. In our
observation we found that the messageSent was not called for those missing
messages.
      
      We have our own ProtocolCodecFactory implemented is used for
endocing/decoding messages from our server to third party server.
      
      In the IoSession Interface documentation it is mentioned that 
      
      Thread Safety
      
IoSession is thread-safe. But please note that performing more than one
write(Object) calls at the same time will cause the
IoFilter.filterWrite(IoFilter.NextFilter,IoSession,WriteRequest) to be
executed simultaneously, and therefore you have to make sure the IoFilter
implementations you're using are thread-safe, too. 
 
 Does above statement means that I have to make sure my encoder should be
thread-safe. 
 
Below is my Protocol Encoder class
 
public class DefaultMyMsgEncoder extends ProtocolEncoderAdapter
{
    public DefaultMyMsgEncoder()
    {
    }
 
    public void encode(IoSession session, Object msg, ProtocolEncoderOutput
out) throws Exception
    {
        
            MyMsg myMsg = (MyMsg) msg;
            IoBuffer buffer =
IoBuffer.allocate(myMsg.getLengthBytes().length+myMsg.getMsgBytes().length
);
         buffer.put(myMsg.getLengthBytes());
         buffer.put(myMsg.getMsgBytes());
         buffer.flip();
         out.write(buffer);
        
    }
}
 

Thanks in advance. 
 
Thanks And Regards,
Nitin Phuria

Reply via email to