Hai All,
I have been doing some performance testing with MINA for our stock
info application. I slightly modified echo server , i had wrote two handler,one
is for FeedHandler(Message receiver this bind the port 8081) and Another one is
EchoHandler(that bind the port 9401 ).All the client is connectd throws this
port(9401).When the message received from feed handler , the message is put
into message queue.
When the client is connected to the port 9401 , the MessageThreade r
will start and get the message from message queue and sent this message to all
the connected clients.
What is my problem is , when iterate the session and sent each message to
everyone i got the exception.'Already releaed the buufer. You have released the
buffer too many times'
I want to know is this right way,i also need to know the is there available
to sent message to everyone.Please help me i am new to Apache and Java N/W also.
My ThreadCode is shown
public class StartThread implements Runnable
{
public static Set sessions = Collections.synchronizedSet( new HashSet()
);
private Queue que = null;
public StartThread(Queue que,Set sessions) {
this.sessions = sessions;
this.que = que;
System.out.println("Constructer");
}
public void run() {
int count = 0;
while(true) {
try{
System.out.println("getQueue");
ByteBuffer rb = null;
//synchronized( sessions) {
try{
rb = (ByteBuffer)que.deQueue();
//System.out.println("rb is ------->"+rb);
}catch(Exception ee) {
System.out.println("Error While getting Msg
from Queue ---->"+ee);
}
System.out.println("No of Session
--------->"+sessions.size());
// Write the received data back to remote peer
//ByteBuffer wb = ByteBuffer.allocate( rb.remaining() );
String str ="Hai Ramesh"+count;
ByteBuffer wb = ByteBuffer.allocate( str.length() + 2
);
rb.release();
wb.put( str.getBytes() );
wb.flip();
System.out.println("Hai ");
Iterator iter = sessions.iterator();
while( iter.hasNext() )
{
IoSession s = ( IoSession ) iter.next();
if( s.isConnected() )
{
s.write( wb);
}
}
wb.release();
}catch(Exception e) {
}
}
}
regds
Ramesh.M