On Dec 18, 2007 5:50 PM, Steve Johns <[EMAIL PROTECTED]> wrote: > > On Dec 18, 2007 4:41 PM, Trustin Lee <[EMAIL PROTECTED]> wrote: > > > On Dec 18, 2007 4:24 PM, Steve Johns <[EMAIL PROTECTED]> wrote: > > > On Dec 18, 2007 3:15 PM, Trustin Lee <[EMAIL PROTECTED]> wrote: > > > > > > > On Dec 17, 2007 5:20 PM, Steve Johns <[EMAIL PROTECTED]> > > 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
