Le 7/23/12 10:53 PM, Leonardo D'Alimonte a écrit :
Hi,
we are using in our application Apache Mina 2.0.4 with the 1.6_u26
JDK, we are really stuck with the communication to a device.
We are trying to send a message "synchronously", waiting to the device
response before sending another message...the problem is that MINA
seems to write on the IoSession two messages instantaneously (our logs
report the same millisecond..) , without waiting for the first message
to be dispatched.
Probably this is big feature of Mina.
We are sure this behaviour is not fully supported by the device, which
often send a response to just one of the two messages, telling us also
it wasn't able to manage it correctly (we don't know which of the two..)
Can we tell MINA to write on the Session waiting to a sort of
response, or something similar?
Hope to be quite clear about our issue.
When you write on a session, it tells you when the message has been
written. You can get back a WriteFuture in order to wait for the message
to be written before writing a second one.
However, that will not help you a lot, because the only thing it does is
that it tells you when the first message has been pushed into the write
queue.
You can also think that waiting for the messageSent() event would help,
but it's only slightly better : you still have no guarantee whatsoever
that the recipient has received the message.
In order to be sure that the device has received the message the server
sent, your device *must* send a Ack of some sort. In other word, you
have to implement this in your protocol. There is absolutly *no way* for
the server to know that the device has received the message.
This is the very base of TCP, writing a IO server without this
understanding is the guaranteed way to get some very bad surprises...
--
Regards,
Cordialement,
Emmanuel Lécharny
www.iktek.com