You should override the filterWrite method in your custom filter rather than the messageSent method.

If you stick a println in both methods you'll see the order of events.

RG


Frederic Soulier <[EMAIL PROTECTED]>

10/05/2006 14:07
Please respond to mina-dev

       
        To:        [email protected]
        cc:        
        Subject:        Filter chain with ProtocolCodecFilter and CustomFilter



Hi

Starting a new thread because I'm hitting a wall here.

I've implemented:
  MyProtocolCodecFactory "codec"
     MyDecoder
     MyEncoder

  CustomFilter
     messageReceived
     messageSent

builder.addFirst("filter1", new ProtocolCodecFilter(codec));
builder.addLast("filter2", new CustomFilter ());

I was expecting when receiving a message:
MyDecoder (decode) -> CustomerFilter <messageReceived> -> IoHandler
and I get that.

I was expecting when writing a message using IoSession.write(Object)
CustomFilter <messageSent> -> MyEncoder (encode) -> IoHandler
but instead I get:
MyEncoder (encode) -> CustomFilter <messageSent> -> IoHandler
which ruins my plans :)

How can I get the behaviour I was expecting?
message
 -> MyDecoder (decode)
      -> CustomerFilter <messageReceived>
           -> IoHandler (messageReceived)
                 (do some work)
                 - IoSession.write(Object)
                        CustomFilter (messageSent) <-
                    MyDecoder (encode) <-
        IoHandler (messageSent) <-

Or do I need to fallback on having everything in MyDecoder and
MyEncoder?

Many thx for any help.                    

--
Frederic Soulier <[EMAIL PROTECTED]>
OpenPGP key available on http://www.keyserver.net
1024D/BA6700ED   49A6 8E8E 4230 8D41 1ADE  B649 3203 1DD2 BA67 00ED



This communication is for informational purposes only. It is not intended
as an offer or solicitation for the purchase or sale of any financial
instrument or as an official confirmation of any transaction. All market prices,
data and other information are not warranted as to completeness or accuracy and
are subject to change without notice. Any comments or statements made herein
do not necessarily reflect those of JPMorgan Chase & Co., its subsidiaries
and affiliates.

Reply via email to