You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by Steve Johns <st...@gmail.com> on 2007/12/13 15:49:25 UTC

Send Message Failure

Thanks for Mina. It is a great project.

After I am trying out the Mina, I had some questions.

1) If the server session.write() a message, however client network is really
SLOW. Will mina keep trying to send
out the message until timeout?(I guess session.settimeout() is applied
here). If so, how IoHandler get notified from this
event message? (Through exceptionCaught, close session?). Why
NOT accumulated writeQueue size > user defined size and exception?

2) If the server wants to send the same message to all 1000 sessions, should
I encode the same message 1000 times
in the encoder extend the messageEncoder? If so, that kinda affects the
performance.
3) In Mina web document, source code 1.1.x->main
the "WORK" class link under org.apache.mina.transport.socket.nio is wrong.

Finally, thanks Trustin.

Re: Send Message Failure

Posted by Steve Johns <st...@gmail.com>.
Thanks a lot.

On Dec 21, 2007 2:20 PM, Trustin Lee <tr...@gmail.com> wrote:

> On Dec 18, 2007 7:01 PM, Maarten Bosteels <mb...@gmail.com> wrote:
> > I think an EncodedMessageCachingFilter is a great idea !
> > As Trustin wrote, this question comes up regularly and IMO it's a very
> > elegant solution to the problem.
>
> I've just filed a JIRA issue related with this for easier tracking
> before my inbox explodes :)
>
> https://issues.apache.org/jira/browse/DIRMINA-500
>
> Cheers,
>  Trustin
> --
> what we call human nature is actually human habit
> --
> http://gleamynode.net/
> --
> PGP Key ID: 0x0255ECA6
>

Re: Send Message Failure

Posted by Trustin Lee <tr...@gmail.com>.
On Dec 18, 2007 7:01 PM, Maarten Bosteels <mb...@gmail.com> wrote:
> I think an EncodedMessageCachingFilter is a great idea !
> As Trustin wrote, this question comes up regularly and IMO it's a very
> elegant solution to the problem.

I've just filed a JIRA issue related with this for easier tracking
before my inbox explodes :)

https://issues.apache.org/jira/browse/DIRMINA-500

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

Re: Send Message Failure

Posted by Maarten Bosteels <mb...@gmail.com>.
I think an EncodedMessageCachingFilter is a great idea !
As Trustin wrote, this question comes up regularly and IMO it's a very
elegant solution to the problem.

Maarten

On Dec 18, 2007 10:24 AM, Steve Johns <st...@gmail.com> wrote:
>
> On Dec 18, 2007 5:16 PM, Trustin Lee <tr...@gmail.com> wrote:
>
> >  On Dec 18, 2007 5:50 PM, Steve Johns <st...@gmail.com> wrote:
> > >
> > > On Dec 18, 2007 4:41 PM, Trustin Lee <tr...@gmail.com> wrote:
> > >
> > > > On Dec 18, 2007 4:24 PM, Steve Johns <st...@gmail.com>
> > wrote:
> > > > > On Dec 18, 2007 3:15 PM, Trustin Lee <tr...@gmail.com> wrote:
> > > > >
> > > > > > On Dec 17, 2007 5:20 PM, Steve Johns <st...@gmail.com>
> > > > wrote:
> > > > > > <snip/>
> > > > > >
> > > > > > > > > Can you give more hints about what the CACHE is?
> > > > > > > >
> > > > > > > > In you encoder, you could maintain a Map whose key is some
> > message
> > > > key
> > > > > > > > and whose value is encoded ByteBuffer (or byte[]).  It could
> > > > probably
> > > > > > > > be a LRUMap implementation that is provided by 3rd party
> > > > collections
> > > > > > > > API such as Apache Commons Collections.  You could query the
> > map
> > > > if
> > > > > > > > there's already an encoded form of the message, and reuse the
> > > > encoded
> > > > > > > > data if there's one in your encoder implementation.
> > > > > > >
> > > > > > > Thanks. Trustin. I totally understood. However, where I do the
> > > > message -
> > > > > > >
> > > > > > > byte[]  part? Is that supposed to be in the Encoder? But what
> > > > suggested
> > > > > > > seems doing the encoding message -> byte[] part in
> > IoHandlerAdapter
> > > > or
> > > > > > > Busniess logic.
> > > > > >
> > > > > Actually this issue bothered me for quite a while, I am working on a
> > > > > financial quotation server which broadcasts the quot data to all the
> > end
> > > > > users connected. It seemed there is no choice than encoding
> > > > message->byte[]
> > > > > in my IoHandlerAdapter in my case. If I do encoding in this way, I
> > don't
> > > > > even need a cache and just send the byte[] to all the sessions with
> > a
> > > > LOOP(
> > > > > bytebuffer.duplicat() of course). Thanks. Anyways.
> > > >
> > > > What about adding EncodedMessageCachingFilter into MINA?  Then you
> > > > don't need to worry about encoding the same message many times.  Would
> > > > it work for you?
> > >
> > > Thanks. However, my sessions are maintained in the IoHandlerAdapter
> > layer
> > > where I send out the bytebuffer to all sessions from. Therefore, I must
> > > encode the message -> byte[] in the IoHandlerAdapter. Adding a
> > > EncodedMessageCachingFilter between the encoder layer and the
> > > IoHandlerAdapter layer doesn't help out. Maybe I misunderstood your?
> >
> > You understood correctly.  I was asking about your will to refactor
> > your code if we are going to add such a filter.  It's better from the
> > viewpoint of separation of concerns, no?
> >
> > Anyways, we have received the same question some time ago, so I think
> > we still need such a filter.
>
> Certainly it is a good idea. Any idea from other commitee? :)
>
>
> >
> >
> > Trustin
> > --
> > what we call human nature is actually human habit
> > --
> > http://gleamynode.net/
> > --
> > PGP Key ID: 0x0255ECA6
> >
>

Re: Send Message Failure

Posted by Steve Johns <st...@gmail.com>.
On Dec 18, 2007 5:16 PM, Trustin Lee <tr...@gmail.com> wrote:

>  On Dec 18, 2007 5:50 PM, Steve Johns <st...@gmail.com> wrote:
> >
> > On Dec 18, 2007 4:41 PM, Trustin Lee <tr...@gmail.com> wrote:
> >
> > > On Dec 18, 2007 4:24 PM, Steve Johns <st...@gmail.com>
> wrote:
> > > > On Dec 18, 2007 3:15 PM, Trustin Lee <tr...@gmail.com> wrote:
> > > >
> > > > > On Dec 17, 2007 5:20 PM, Steve Johns <st...@gmail.com>
> > > wrote:
> > > > > <snip/>
> > > > >
> > > > > > > > Can you give more hints about what the CACHE is?
> > > > > > >
> > > > > > > In you encoder, you could maintain a Map whose key is some
> message
> > > key
> > > > > > > and whose value is encoded ByteBuffer (or byte[]).  It could
> > > probably
> > > > > > > be a LRUMap implementation that is provided by 3rd party
> > > collections
> > > > > > > API such as Apache Commons Collections.  You could query the
> map
> > > if
> > > > > > > there's already an encoded form of the message, and reuse the
> > > encoded
> > > > > > > data if there's one in your encoder implementation.
> > > > > >
> > > > > > Thanks. Trustin. I totally understood. However, where I do the
> > > message -
> > > > > >
> > > > > > byte[]  part? Is that supposed to be in the Encoder? But what
> > > suggested
> > > > > > seems doing the encoding message -> byte[] part in
> IoHandlerAdapter
> > > or
> > > > > > Busniess logic.
> > > > >
> > > > Actually this issue bothered me for quite a while, I am working on a
> > > > financial quotation server which broadcasts the quot data to all the
> end
> > > > users connected. It seemed there is no choice than encoding
> > > message->byte[]
> > > > in my IoHandlerAdapter in my case. If I do encoding in this way, I
> don't
> > > > even need a cache and just send the byte[] to all the sessions with
> a
> > > LOOP(
> > > > bytebuffer.duplicat() of course). Thanks. Anyways.
> > >
> > > What about adding EncodedMessageCachingFilter into MINA?  Then you
> > > don't need to worry about encoding the same message many times.  Would
> > > it work for you?
> >
> > Thanks. However, my sessions are maintained in the IoHandlerAdapter
> layer
> > where I send out the bytebuffer to all sessions from. Therefore, I must
> > encode the message -> byte[] in the IoHandlerAdapter. Adding a
> > EncodedMessageCachingFilter between the encoder layer and the
> > IoHandlerAdapter layer doesn't help out. Maybe I misunderstood your?
>
> You understood correctly.  I was asking about your will to refactor
> your code if we are going to add such a filter.  It's better from the
> viewpoint of separation of concerns, no?
>
> Anyways, we have received the same question some time ago, so I think
> we still need such a filter.

Certainly it is a good idea. Any idea from other commitee? :)

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

Re: Send Message Failure

Posted by Trustin Lee <tr...@gmail.com>.
On Dec 18, 2007 5:50 PM, Steve Johns <st...@gmail.com> wrote:
>
> On Dec 18, 2007 4:41 PM, Trustin Lee <tr...@gmail.com> wrote:
>
> > On Dec 18, 2007 4:24 PM, Steve Johns <st...@gmail.com> wrote:
> > > On Dec 18, 2007 3:15 PM, Trustin Lee <tr...@gmail.com> wrote:
> > >
> > > > On Dec 17, 2007 5:20 PM, Steve Johns <st...@gmail.com>
> > wrote:
> > > > <snip/>
> > > >
> > > > > > > Can you give more hints about what the CACHE is?
> > > > > >
> > > > > > In you encoder, you could maintain a Map whose key is some message
> > key
> > > > > > and whose value is encoded ByteBuffer (or byte[]).  It could
> > probably
> > > > > > be a LRUMap implementation that is provided by 3rd party
> > collections
> > > > > > API such as Apache Commons Collections.  You could query the map
> > if
> > > > > > there's already an encoded form of the message, and reuse the
> > encoded
> > > > > > data if there's one in your encoder implementation.
> > > > >
> > > > > Thanks. Trustin. I totally understood. However, where I do the
> > message -
> > > > >
> > > > > byte[]  part? Is that supposed to be in the Encoder? But what
> > suggested
> > > > > seems doing the encoding message -> byte[] part in IoHandlerAdapter
> > or
> > > > > Busniess logic.
> > > >
> > > Actually this issue bothered me for quite a while, I am working on a
> > > financial quotation server which broadcasts the quot data to all the end
> > > users connected. It seemed there is no choice than encoding
> > message->byte[]
> > > in my IoHandlerAdapter in my case. If I do encoding in this way, I don't
> > > even need a cache and just send the byte[] to all the sessions with a
> > LOOP(
> > > bytebuffer.duplicat() of course). Thanks. Anyways.
> >
> > What about adding EncodedMessageCachingFilter into MINA?  Then you
> > don't need to worry about encoding the same message many times.  Would
> > it work for you?
>
> Thanks. However, my sessions are maintained in the IoHandlerAdapter layer
> where I send out the bytebuffer to all sessions from. Therefore, I must
> encode the message -> byte[] in the IoHandlerAdapter. Adding a
> EncodedMessageCachingFilter between the encoder layer and the
> IoHandlerAdapter layer doesn't help out. Maybe I misunderstood your?

You understood correctly.  I was asking about your will to refactor
your code if we are going to add such a filter.  It's better from the
viewpoint of separation of concerns, no?

Anyways, we have received the same question some time ago, so I think
we still need such a filter.

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

Re: Send Message Failure

Posted by Steve Johns <st...@gmail.com>.
On Dec 18, 2007 4:41 PM, Trustin Lee <tr...@gmail.com> wrote:

> On Dec 18, 2007 4:24 PM, Steve Johns <st...@gmail.com> wrote:
> > On Dec 18, 2007 3:15 PM, Trustin Lee <tr...@gmail.com> wrote:
> >
> > > On Dec 17, 2007 5:20 PM, Steve Johns <st...@gmail.com>
> wrote:
> > > <snip/>
> > >
> > > > > > Can you give more hints about what the CACHE is?
> > > > >
> > > > > In you encoder, you could maintain a Map whose key is some message
> key
> > > > > and whose value is encoded ByteBuffer (or byte[]).  It could
> probably
> > > > > be a LRUMap implementation that is provided by 3rd party
> collections
> > > > > API such as Apache Commons Collections.  You could query the map
> if
> > > > > there's already an encoded form of the message, and reuse the
> encoded
> > > > > data if there's one in your encoder implementation.
> > > >
> > > > Thanks. Trustin. I totally understood. However, where I do the
> message -
> > > >
> > > > byte[]  part? Is that supposed to be in the Encoder? But what
> suggested
> > > > seems doing the encoding message -> byte[] part in IoHandlerAdapter
> or
> > > > Busniess logic.
> > >
> > Actually this issue bothered me for quite a while, I am working on a
> > financial quotation server which broadcasts the quot data to all the end
> > users connected. It seemed there is no choice than encoding
> message->byte[]
> > in my IoHandlerAdapter in my case. If I do encoding in this way, I don't
> > even need a cache and just send the byte[] to all the sessions with a
> LOOP(
> > bytebuffer.duplicat() of course). Thanks. Anyways.
>
> What about adding EncodedMessageCachingFilter into MINA?  Then you
> don't need to worry about encoding the same message many times.  Would
> it work for you?

Thanks. However, my sessions are maintained in the IoHandlerAdapter layer
where I send out the bytebuffer to all sessions from. Therefore, I must
encode the message -> byte[] in the IoHandlerAdapter. Adding a
EncodedMessageCachingFilter between the encoder layer and the
IoHandlerAdapter layer doesn't help out. Maybe I misunderstood your?

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

Re: Send Message Failure

Posted by Trustin Lee <tr...@gmail.com>.
On Dec 18, 2007 4:24 PM, Steve Johns <st...@gmail.com> wrote:
> On Dec 18, 2007 3:15 PM, Trustin Lee <tr...@gmail.com> wrote:
>
> > On Dec 17, 2007 5:20 PM, Steve Johns <st...@gmail.com> wrote:
> > <snip/>
> >
> > > > > Can you give more hints about what the CACHE is?
> > > >
> > > > In you encoder, you could maintain a Map whose key is some message key
> > > > and whose value is encoded ByteBuffer (or byte[]).  It could probably
> > > > be a LRUMap implementation that is provided by 3rd party collections
> > > > API such as Apache Commons Collections.  You could query the map if
> > > > there's already an encoded form of the message, and reuse the encoded
> > > > data if there's one in your encoder implementation.
> > >
> > > Thanks. Trustin. I totally understood. However, where I do the message -
> > >
> > > byte[]  part? Is that supposed to be in the Encoder? But what suggested
> > > seems doing the encoding message -> byte[] part in IoHandlerAdapter or
> > > Busniess logic.
> >
> Actually this issue bothered me for quite a while, I am working on a
> financial quotation server which broadcasts the quot data to all the end
> users connected. It seemed there is no choice than encoding message->byte[]
> in my IoHandlerAdapter in my case. If I do encoding in this way, I don't
> even need a cache and just send the byte[] to all the sessions with a LOOP(
> bytebuffer.duplicat() of course). Thanks. Anyways.

What about adding EncodedMessageCachingFilter into MINA?  Then you
don't need to worry about encoding the same message many times.  Would
it work for you?

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

Re: Send Message Failure

Posted by Steve Johns <st...@gmail.com>.
On Dec 18, 2007 3:15 PM, Trustin Lee <tr...@gmail.com> wrote:

> On Dec 17, 2007 5:20 PM, Steve Johns <st...@gmail.com> wrote:
> <snip/>
>
> > > > Can you give more hints about what the CACHE is?
> > >
> > > In you encoder, you could maintain a Map whose key is some message key
> > > and whose value is encoded ByteBuffer (or byte[]).  It could probably
> > > be a LRUMap implementation that is provided by 3rd party collections
> > > API such as Apache Commons Collections.  You could query the map if
> > > there's already an encoded form of the message, and reuse the encoded
> > > data if there's one in your encoder implementation.
> >
> > Thanks. Trustin. I totally understood. However, where I do the message -
> >
> > byte[]  part? Is that supposed to be in the Encoder? But what suggested
> > seems doing the encoding message -> byte[] part in IoHandlerAdapter or
> > Busniess logic.
>
Actually this issue bothered me for quite a while, I am working on a
financial quotation server which broadcasts the quot data to all the end
users connected. It seemed there is no choice than encoding message->byte[]
in my IoHandlerAdapter in my case. If I do encoding in this way, I don't
even need a cache and just send the byte[] to all the sessions with a LOOP(
bytebuffer.duplicat() of course). Thanks. Anyways.

>
>
> Yes, you are supposed to do that in the ProtocolEncoder.  It doesn't
> mean that you can't do that in the IoHandlerAdaptor or business logic,
> but it's not recommended in most cases.  That's why I suggested you to
> use cache in the encoder.
>
> HTH,
> Trustin
> --
> what we call human nature is actually human habit
> --
> http://gleamynode.net/
> --
> PGP Key ID: 0x0255ECA6
>

Re: Send Message Failure

Posted by Trustin Lee <tr...@gmail.com>.
On Dec 17, 2007 5:20 PM, Steve Johns <st...@gmail.com> wrote:
<snip/>

> > > Can you give more hints about what the CACHE is?
> >
> > In you encoder, you could maintain a Map whose key is some message key
> > and whose value is encoded ByteBuffer (or byte[]).  It could probably
> > be a LRUMap implementation that is provided by 3rd party collections
> > API such as Apache Commons Collections.  You could query the map if
> > there's already an encoded form of the message, and reuse the encoded
> > data if there's one in your encoder implementation.
>
> Thanks. Trustin. I totally understood. However, where I do the message - >
> byte[]  part? Is that supposed to be in the Encoder? But what suggested
> seems doing the encoding message -> byte[] part in IoHandlerAdapter or
> Busniess logic.

Yes, you are supposed to do that in the ProtocolEncoder.  It doesn't
mean that you can't do that in the IoHandlerAdaptor or business logic,
but it's not recommended in most cases.  That's why I suggested you to
use cache in the encoder.

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

Re: Send Message Failure

Posted by Steve Johns <st...@gmail.com>.
On Dec 17, 2007 12:31 PM, Trustin Lee <tr...@gmail.com> wrote:

>  On Dec 14, 2007 7:56 AM, Steve Johns <st...@gmail.com> wrote:
> >
> > On Dec 14, 2007 6:40 AM, mat <fo...@gmail.com> wrote:
> >
> > > On Dec 14, 2007 1:35 AM, Trustin Lee <tr...@gmail.com> wrote:
> > >
> > > > Hi Steve,
> > > >
> > > > On Dec 13, 2007 11:49 PM, Steve Johns <st...@gmail.com>
> > > wrote:
> > > > > Thanks for Mina. It is a great project.
> > > >
> > > > Whenever we hear this, we become happy and try to work harder for
> > > > MINA.  Thank you too!
> > >
> > > :D
> > >
> > > >
> > > >
> > > > > After I am trying out the Mina, I had some questions.
> > > > >
> > > > > 1) If the server session.write() a message, however client network
> is
> > > > really
> > > > > SLOW. Will mina keep trying to send
> > > > > out the message until timeout?(I guess session.settimeout() is
> applied
> > > > > here). If so, how IoHandler get notified from this
> > > > > event message? (Through exceptionCaught, close session?).
> > > >
> > > > There's writeTimeout property in IoSessionConfig, so you can adjust
> > > > the timeout value.  Once the write it timed out,
> WriteTimeoutException
> > > > is raised and forwarded to your IoHandler's exceptionCaught method.
> > > > And then the connection will be closed automatically.
> > > >
> > > > > Why
> > > > > NOT accumulated writeQueue size > user defined size and exception?
> > > >
> > > > Could you explain this question more in detail?
> > >
> > > Which meant: I need close the session whenever the write queue
> size(buffer
> > > size) for this session reaches a certain number.
> >
> > Yup. That was what I meant.
>
> You can always check the size of the write request queue via
> IoSession.getScheduledWriteRequests/Bytes().  You can call
> IoSession.close() explicitly when it returns the greater value than
> you expected.
>
> > > > 2) If the server wants to send the same message to all 1000
> sessions,
> > > should
> > > > I encode the same message 1000 times
> > > > in the encoder extend the messageEncoder? If so, that kinda affects
> the
> > > > performance.
> > >
> > > Right.  We got the same request before and I suggested him to use some
> > > cache.  Would it work for you, either?
> >
> > A cache sounded workable. However where should I do the MESSAGE ->
> byte[] ->
> > > cache(If I do in IoHandler, is that kinda mixing business logic and
> > > protocol
> > > handler)?
> >
> > Can you give more hints about what the CACHE is?
>
> In you encoder, you could maintain a Map whose key is some message key
> and whose value is encoded ByteBuffer (or byte[]).  It could probably
> be a LRUMap implementation that is provided by 3rd party collections
> API such as Apache Commons Collections.  You could query the map if
> there's already an encoded form of the message, and reuse the encoded
> data if there's one in your encoder implementation.

Thanks. Trustin. I totally understood. However, where I do the message - >
byte[]  part? Is that supposed to be in the Encoder? But what suggested
seems doing the encoding message -> byte[] part in IoHandlerAdapter or
Busniess logic.

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

Re: Send Message Failure

Posted by Trustin Lee <tr...@gmail.com>.
On Dec 14, 2007 7:56 AM, Steve Johns <st...@gmail.com> wrote:
>
> On Dec 14, 2007 6:40 AM, mat <fo...@gmail.com> wrote:
>
> > On Dec 14, 2007 1:35 AM, Trustin Lee <tr...@gmail.com> wrote:
> >
> > > Hi Steve,
> > >
> > > On Dec 13, 2007 11:49 PM, Steve Johns <st...@gmail.com>
> > wrote:
> > > > Thanks for Mina. It is a great project.
> > >
> > > Whenever we hear this, we become happy and try to work harder for
> > > MINA.  Thank you too!
> >
> > :D
> >
> > >
> > >
> > > > After I am trying out the Mina, I had some questions.
> > > >
> > > > 1) If the server session.write() a message, however client network is
> > > really
> > > > SLOW. Will mina keep trying to send
> > > > out the message until timeout?(I guess session.settimeout() is applied
> > > > here). If so, how IoHandler get notified from this
> > > > event message? (Through exceptionCaught, close session?).
> > >
> > > There's writeTimeout property in IoSessionConfig, so you can adjust
> > > the timeout value.  Once the write it timed out, WriteTimeoutException
> > > is raised and forwarded to your IoHandler's exceptionCaught method.
> > > And then the connection will be closed automatically.
> > >
> > > > Why
> > > > NOT accumulated writeQueue size > user defined size and exception?
> > >
> > > Could you explain this question more in detail?
> >
> > Which meant: I need close the session whenever the write queue size(buffer
> > size) for this session reaches a certain number.
>
> Yup. That was what I meant.

You can always check the size of the write request queue via
IoSession.getScheduledWriteRequests/Bytes().  You can call
IoSession.close() explicitly when it returns the greater value than
you expected.

> > > 2) If the server wants to send the same message to all 1000 sessions,
> > should
> > > I encode the same message 1000 times
> > > in the encoder extend the messageEncoder? If so, that kinda affects the
> > > performance.
> >
> > Right.  We got the same request before and I suggested him to use some
> > cache.  Would it work for you, either?
>
> A cache sounded workable. However where should I do the MESSAGE -> byte[] ->
> > cache(If I do in IoHandler, is that kinda mixing business logic and
> > protocol
> > handler)?
>
> Can you give more hints about what the CACHE is?

In you encoder, you could maintain a Map whose key is some message key
and whose value is encoded ByteBuffer (or byte[]).  It could probably
be a LRUMap implementation that is provided by 3rd party collections
API such as Apache Commons Collections.  You could query the map if
there's already an encoded form of the message, and reuse the encoded
data if there's one in your encoder implementation.

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

Re: Send Message Failure

Posted by Steve Johns <st...@gmail.com>.
On Dec 14, 2007 6:40 AM, mat <fo...@gmail.com> wrote:

> On Dec 14, 2007 1:35 AM, Trustin Lee <tr...@gmail.com> wrote:
>
> > Hi Steve,
> >
> > On Dec 13, 2007 11:49 PM, Steve Johns <st...@gmail.com>
> wrote:
> > > Thanks for Mina. It is a great project.
> >
> > Whenever we hear this, we become happy and try to work harder for
> > MINA.  Thank you too!
>
> :D
>
> >
> >
> > > After I am trying out the Mina, I had some questions.
> > >
> > > 1) If the server session.write() a message, however client network is
> > really
> > > SLOW. Will mina keep trying to send
> > > out the message until timeout?(I guess session.settimeout() is applied
> > > here). If so, how IoHandler get notified from this
> > > event message? (Through exceptionCaught, close session?).
> >
> > There's writeTimeout property in IoSessionConfig, so you can adjust
> > the timeout value.  Once the write it timed out, WriteTimeoutException
> > is raised and forwarded to your IoHandler's exceptionCaught method.
> > And then the connection will be closed automatically.
> >
> > > Why
> > > NOT accumulated writeQueue size > user defined size and exception?
> >
> > Could you explain this question more in detail?
>
> Which meant: I need close the session whenever the write queue size(buffer
> size) for this session reaches a certain number.

Yup. That was what I meant.

>
>
> > 2) If the server wants to send the same message to all 1000 sessions,
> should
> > I encode the same message 1000 times
> > in the encoder extend the messageEncoder? If so, that kinda affects the
> > performance.
>
> Right.  We got the same request before and I suggested him to use some
> cache.  Would it work for you, either?

A cache sounded workable. However where should I do the MESSAGE -> byte[] ->
> cache(If I do in IoHandler, is that kinda mixing business logic and
> protocol
> handler)?

Can you give more hints about what the CACHE is?

>
>
> >
> >
> > > 3) In Mina web document, source code 1.1.x->main
> > > the "WORK" class link under org.apache.mina.transport.socket.nio is
> > wrong.
> >
> > Ah.. you meant the 'Worker' class, right?  It's an inner class and it
> > seems like the Xref report generator has some bug dealing with inner
> > classes.  Hopefully it should be fixed in the maven xref plugin.
> >
> > > Finally, thanks Trustin.
> >
> > Please don't thank me.  Please thank all the community members who
> > made this project keep going. :)
>
> Certainly I want to thank all the community members too.

Thanks. matt.

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

Re: Send Message Failure

Posted by mat <fo...@gmail.com>.
On Dec 14, 2007 1:35 AM, Trustin Lee <tr...@gmail.com> wrote:

> Hi Steve,
>
> On Dec 13, 2007 11:49 PM, Steve Johns <st...@gmail.com> wrote:
> > Thanks for Mina. It is a great project.
>
> Whenever we hear this, we become happy and try to work harder for
> MINA.  Thank you too!

:D

>
>
> > After I am trying out the Mina, I had some questions.
> >
> > 1) If the server session.write() a message, however client network is
> really
> > SLOW. Will mina keep trying to send
> > out the message until timeout?(I guess session.settimeout() is applied
> > here). If so, how IoHandler get notified from this
> > event message? (Through exceptionCaught, close session?).
>
> There's writeTimeout property in IoSessionConfig, so you can adjust
> the timeout value.  Once the write it timed out, WriteTimeoutException
> is raised and forwarded to your IoHandler's exceptionCaught method.
> And then the connection will be closed automatically.
>
> > Why
> > NOT accumulated writeQueue size > user defined size and exception?
>
> Could you explain this question more in detail?

Which meant: I need close the session whenever the write queue size(buffer
size) for this session reaches a certain number.

>
>
> > 2) If the server wants to send the same message to all 1000 sessions,
> should
> > I encode the same message 1000 times
> > in the encoder extend the messageEncoder? If so, that kinda affects the
> > performance.
>
> Right.  We got the same request before and I suggested him to use some
> cache.  Would it work for you, either?

A cache sounded workable. However where should I do the MESSAGE -> byte[] ->
cache(If I do in IoHandler, is that kinda mixing business logic and protocol
handler)?

>
>
> > 3) In Mina web document, source code 1.1.x->main
> > the "WORK" class link under org.apache.mina.transport.socket.nio is
> wrong.
>
> Ah.. you meant the 'Worker' class, right?  It's an inner class and it
> seems like the Xref report generator has some bug dealing with inner
> classes.  Hopefully it should be fixed in the maven xref plugin.
>
> > Finally, thanks Trustin.
>
> Please don't thank me.  Please thank all the community members who
> made this project keep going. :)

Certainly I want to thank all the community members too.

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

Re: Send Message Failure

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

On Dec 13, 2007 11:49 PM, Steve Johns <st...@gmail.com> wrote:
> Thanks for Mina. It is a great project.

Whenever we hear this, we become happy and try to work harder for
MINA.  Thank you too!

> After I am trying out the Mina, I had some questions.
>
> 1) If the server session.write() a message, however client network is really
> SLOW. Will mina keep trying to send
> out the message until timeout?(I guess session.settimeout() is applied
> here). If so, how IoHandler get notified from this
> event message? (Through exceptionCaught, close session?).

There's writeTimeout property in IoSessionConfig, so you can adjust
the timeout value.  Once the write it timed out, WriteTimeoutException
is raised and forwarded to your IoHandler's exceptionCaught method.
And then the connection will be closed automatically.

> Why
> NOT accumulated writeQueue size > user defined size and exception?

Could you explain this question more in detail?

> 2) If the server wants to send the same message to all 1000 sessions, should
> I encode the same message 1000 times
> in the encoder extend the messageEncoder? If so, that kinda affects the
> performance.

Right.  We got the same request before and I suggested him to use some
cache.  Would it work for you, either?

> 3) In Mina web document, source code 1.1.x->main
> the "WORK" class link under org.apache.mina.transport.socket.nio is wrong.

Ah.. you meant the 'Worker' class, right?  It's an inner class and it
seems like the Xref report generator has some bug dealing with inner
classes.  Hopefully it should be fixed in the maven xref plugin.

> Finally, thanks Trustin.

Please don't thank me.  Please thank all the community members who
made this project keep going. :)

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