Le 02/02/16 12:10, Abhijit Bhatode a écrit :
> Hi,
>
> We are using MINA 2.0 M1. 
You should switch to 2.0.11 which has been released last wek... 2.0.0-M1
is 8 years old !

> Is there a way to get details of message when an
> exception occurs during write?

It depends...

There are many potential exception you can get, and I suspect you wnat
to get some information in the exceptionCaught() method in your IoHandler.

If you are lucky, the message is still in the write queue. You can get
it by using :

    WriteRequest writeRequest = session.getWriteRequestQueue().poll(
session );

    if (writeRequest != null) {
        Object message = writeRequest.getMessage();
    }

Otherwise, check the cause.

One other possibility is to store in your session the messages that you
are sending before writing them, and in the exceptionCaught() method,
you can most certainly check on the session to see what is the message
that was the cause. This is, again, not guaranteed, because you may have
many messages waiting to be sent when you get the exception.


Keep in mind that this is asynchonous, so the exceptionCaught event can
be received way after you tried to write a message.

Last, not least, you will receive a messageSent() event for every single
message that has successfully sent. You can also use this information to
detect what is the message causing the problem.


In any case, as I said, there are many reson why you would receive an
exception, and a lot of them might be totally disconnect to the fact
that you tried to write a message.


Wht is your use case ?


Reply via email to