You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by Kevin Williams <ke...@gmail.com> on 2007/04/17 23:46:28 UTC

need help using a long session

I'm not sure if "long session" is the right term. What I want to do is
use a Mina SocketConnector to connect to a service, send a bunch of
messages back and forth, then close the connection. I'm thinking in
sort of a top-down mode rather than bottom-up. Perhaps some
pseudo-code will help explain.

IoSession session = new SocketConnector().connect( new
InetSocketAddress( 999 ), new MyHandler() );
for( int i = 0; i < 10000; i++ ) {
  session.write( "hello world" );
  // read back result
  // verify result
}
session.close();

I understand how the IoHandler sends and receives messages, but I
can't figure out how to drive that multiple times over one session.

Clear as mud? :)

Any ideas would be appreciated.

-- 
Cheers,

Kevin Williams
http://www.almostserio.us/

"Any sufficiently advanced technology is indistinguishable from
Magic." - Arthur C. Clarke

Re: need help using a long session

Posted by Kevin Williams <ke...@gmail.com>.
This is an attempt to load-test a server over a single open socket.
Yes, the intent is to verify the response to give us a failure rate
for the server (how many requests were not processed correctly).

On 4/19/07, mat <fo...@gmail.com> wrote:
> Is that kind of synchronous task? I think sometimes it is neccessary since
> right now mina is asynchronous.(send message and forget it).
> But in some cases, we need know the response from this session before doing
> more action. Did I understand correctly?
>
>
> 2007/4/18, Trustin Lee <tr...@gmail.com>:
> >
> > Hi Kevin,
> >
> > On 4/18/07, Kevin Williams <ke...@gmail.com> wrote:
> > > I'm not sure if "long session" is the right term. What I want to do is
> > > use a Mina SocketConnector to connect to a service, send a bunch of
> > > messages back and forth, then close the connection. I'm thinking in
> > > sort of a top-down mode rather than bottom-up. Perhaps some
> > > pseudo-code will help explain.
> > >
> > > IoSession session = new SocketConnector().connect( new
> > > InetSocketAddress( 999 ), new MyHandler() );
> > > for( int i = 0; i < 10000; i++ ) {
> > >   session.write( "hello world" );
> > >   // read back result
> > >   // verify result
> > > }
> > > session.close();
> > >
> > > I understand how the IoHandler sends and receives messages, but I
> > > can't figure out how to drive that multiple times over one session.
> > >
> > > Clear as mud? :)
> >
> > MyHandler (your IoHandler implementation) will be notified when a
> > result message is received.  There's no way to receive a message
> > outside of an IoHandler for now.  It's a good feature to have, so we
> > are considering adding a related feature as an extension soon in 2.0.
> >
> > If you are a brave guy, you could try the latest revision in our
> > source code repository, or back-port small part of it.  It has a
> > feature that makes it easy to implement a request-response protocol.
> >
> > http://issues.apache.org/jira/browse/DIRMINA-92#action_12488311
> >
> > HTH,
> > Trustin
> > --
> > what we call human nature is actually human habit
> > --
> > http://gleamynode.net/
> > --
> > PGP Key ID: 0x0255ECA6
> >
>


-- 
Cheers,

Kevin Williams
http://www.almostserio.us/

"Any sufficiently advanced technology is indistinguishable from
Magic." - Arthur C. Clarke

Re: need help using a long session

Posted by mat <fo...@gmail.com>.
Is that kind of synchronous task? I think sometimes it is neccessary since
right now mina is asynchronous.(send message and forget it).
But in some cases, we need know the response from this session before doing
more action. Did I understand correctly?


2007/4/18, Trustin Lee <tr...@gmail.com>:
>
> Hi Kevin,
>
> On 4/18/07, Kevin Williams <ke...@gmail.com> wrote:
> > I'm not sure if "long session" is the right term. What I want to do is
> > use a Mina SocketConnector to connect to a service, send a bunch of
> > messages back and forth, then close the connection. I'm thinking in
> > sort of a top-down mode rather than bottom-up. Perhaps some
> > pseudo-code will help explain.
> >
> > IoSession session = new SocketConnector().connect( new
> > InetSocketAddress( 999 ), new MyHandler() );
> > for( int i = 0; i < 10000; i++ ) {
> >   session.write( "hello world" );
> >   // read back result
> >   // verify result
> > }
> > session.close();
> >
> > I understand how the IoHandler sends and receives messages, but I
> > can't figure out how to drive that multiple times over one session.
> >
> > Clear as mud? :)
>
> MyHandler (your IoHandler implementation) will be notified when a
> result message is received.  There's no way to receive a message
> outside of an IoHandler for now.  It's a good feature to have, so we
> are considering adding a related feature as an extension soon in 2.0.
>
> If you are a brave guy, you could try the latest revision in our
> source code repository, or back-port small part of it.  It has a
> feature that makes it easy to implement a request-response protocol.
>
> http://issues.apache.org/jira/browse/DIRMINA-92#action_12488311
>
> HTH,
> Trustin
> --
> what we call human nature is actually human habit
> --
> http://gleamynode.net/
> --
> PGP Key ID: 0x0255ECA6
>

Re: need help using a long session

Posted by Trustin Lee <tr...@gmail.com>.
Hi Kevin,

On 4/18/07, Kevin Williams <ke...@gmail.com> wrote:
> I'm not sure if "long session" is the right term. What I want to do is
> use a Mina SocketConnector to connect to a service, send a bunch of
> messages back and forth, then close the connection. I'm thinking in
> sort of a top-down mode rather than bottom-up. Perhaps some
> pseudo-code will help explain.
>
> IoSession session = new SocketConnector().connect( new
> InetSocketAddress( 999 ), new MyHandler() );
> for( int i = 0; i < 10000; i++ ) {
>   session.write( "hello world" );
>   // read back result
>   // verify result
> }
> session.close();
>
> I understand how the IoHandler sends and receives messages, but I
> can't figure out how to drive that multiple times over one session.
>
> Clear as mud? :)

MyHandler (your IoHandler implementation) will be notified when a
result message is received.  There's no way to receive a message
outside of an IoHandler for now.  It's a good feature to have, so we
are considering adding a related feature as an extension soon in 2.0.

If you are a brave guy, you could try the latest revision in our
source code repository, or back-port small part of it.  It has a
feature that makes it easy to implement a request-response protocol.

http://issues.apache.org/jira/browse/DIRMINA-92#action_12488311

HTH,
Trustin
-- 
what we call human nature is actually human habit
--
http://gleamynode.net/
--
PGP Key ID: 0x0255ECA6