You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@directory.apache.org by da...@daune-consult.com on 2006/01/11 12:56:42 UTC

[Mina] 'messageSent' semantic

Hi,

when I receive the 'messageSent' notification, what is its semantic?

Does it mean that the receiving end has received the message (from a TCP point
of view, i.e. that all bytes have been received)?

Regards,

J-F


Re: [Mina] 'messageSent' semantic

Posted by Alessandro Torrisi <al...@eurone.it>.
I think it's not dependent by Java NIO API or by Sockets or by whatever API.
The message shipment and reception, I think, is controlled by the 
underlaying stack, so by the TCP-IP.

This answer, in my poor opinion, is real when you use a SOCKET layer, 
sure not real if you use DATAGRAM
layer and UDP. Do a control yourself if you want it ! :D

Best regards, Alex


daune.jf@daune-consult.com wrote:

> Niklas Therning <ni...@trillian.se> a écrit :
>
>> daune.jf@daune-consult.com wrote:
>>
>>> Hi,
>>>
>>> when I receive the 'messageSent' notification, what is its semantic?
>>>
>>> Does it mean that the receiving end has received the message (from a 
>>> TCP point
>>> of view, i.e. that all bytes have been received)?
>>>
>>> Regards,
>>>
>>> J-F
>>
>>
>> No, it only means that the message has been written to the 
>> SocketChannel corresponding to the session. There's no guarantee that 
>> the receiving side has received any of the message bytes yet.
>>
>> /Niklas
>
>
> Thanks Niklas.
>
> Some clarifications:
>
> - Is it possible to know when message has really been received?
>
> - If not why? Is it due to TCP/IP, OS, sockets, use of non-blocking I/O ?
>
> Thanks,
>
> J-F
>
>
>
>


Re: [Mina] 'messageSent' semantic

Posted by da...@daune-consult.com.
Quoting David Boreham <da...@bozemanpass.com>:

>
>> I am surprised it is stated that TCP does not guarantee that message is
>> received. It does so. It guarantees packet delivery and packet order.
>
> TCP does not guarantee packet delivery. Yes it will retransmit an
> unacknowledged packet but that's quite a bit short of guaranteed delivery.
>
>> I guess they meant that with sockets, reception at TCP/IP level does 
>> not imply
>> consumption of the buffer by the receiving program.
>
> This true, but I think they meant that when an application sends data on
> a socket, the fact that the system call has returned tells you _nothing_
> about where the data has arrived. It might still be sitting in a buffer
> on sending node. Its ethernet cable might be yanked the next milisecond
> and the packet would go exactly nowhere, ever.

Thanks for clarifications.

On the other hand, TCP knows that packet is delivered or not.

And it seems socket API does not do anything with this info (no exception)

This mandates application acknowledge if you really want to be sure messages
have been delivered. In this case, why does bring TCP over UDP? Only ordering?

J-F


Re: [Mina] 'messageSent' semantic

Posted by David Boreham <da...@bozemanpass.com>.
> I am surprised it is stated that TCP does not guarantee that message is
> received. It does so. It guarantees packet delivery and packet order.

TCP does not guarantee packet delivery. Yes it will retransmit an
unacknowledged packet but that's quite a bit short of guaranteed delivery.

> I guess they meant that with sockets, reception at TCP/IP level does 
> not imply
> consumption of the buffer by the receiving program.

This true, but I think they meant that when an application sends data on
a socket, the fact that the system call has returned tells you _nothing_
about where the data has arrived. It might still be sitting in a buffer
on sending node. Its ethernet cable might be yanked the next milisecond
and the packet would go exactly nowhere, ever.





Re: [Mina] 'messageSent' semantic

Posted by Alessandro Torrisi <al...@eurone.it>.
Hi ! Hi there is something confused.

I think that the meaning of the posts was that it's not Java that has  
to take care of transport...
but it's care of the TCP-IP stack implemented in each operating system.

I've read the posts on the Java forum and it's really not clear.

In my poor opinion, I think that differences between TCP/IP and UDP  
protocol are here !
TCP has the SYN-ACK system which is at the base of the communication  
control among
hosts. If a message has not come, or if its sequence is not right,  
packet is retransmitted
to ensure packet delivery, I'm agree with J-F.

If not so, what's the sense of TCP/IP ??? Use UDP...

I hope I have not understood that post or I will be in doubt on  
myself and with all the documentation
I've read...

Best regards, Alex

On 11/gen/06, at 18:59, daune.jf@daune-consult.com wrote:

> Quoting Niklas Therning <ni...@trillian.se>:
>
>> daune.jf@daune-consult.com wrote:
>>> ...
>>>
>>>
>>> Do you mean that when the call
>>> socket.getOutputStream().write(myBufferOf1000Bytes) returns, it  
>>> does not mean
>>> that all 1000 bytes has been transmitted via TCP/IP to receiver?
>>>
>>> What does it mean then? That the 1000 bytes are in TCP/IP stack's  
>>> buffer?
>>
>> Yes, I think so.
>>
>> Read this post:
>>
>> http://forum.java.sun.com/thread.jspa?forumID=11&threadID=635138
>>
>> /Niklas
>
> Thanks. The post is not so clear.
>
> I am surprised it is stated that TCP does not guarantee that  
> message is
> received. It does so. It guarantees packet delivery and packet order.
>
> I guess they meant that with sockets, reception at TCP/IP level  
> does not imply
> consumption of the buffer by the receiving program.
>
> J-F
>
>


Re: [Mina] 'messageSent' semantic

Posted by da...@daune-consult.com.
Quoting Niklas Therning <ni...@trillian.se>:

> daune.jf@daune-consult.com wrote:
>> ...
>>
>>
>> Do you mean that when the call
>> socket.getOutputStream().write(myBufferOf1000Bytes) returns, it does 
>> not mean
>> that all 1000 bytes has been transmitted via TCP/IP to receiver?
>>
>> What does it mean then? That the 1000 bytes are in TCP/IP stack's buffer?
>
> Yes, I think so.
>
> Read this post:
>
> http://forum.java.sun.com/thread.jspa?forumID=11&threadID=635138
>
> /Niklas

Thanks. The post is not so clear.

I am surprised it is stated that TCP does not guarantee that message is
received. It does so. It guarantees packet delivery and packet order.

I guess they meant that with sockets, reception at TCP/IP level does not imply
consumption of the buffer by the receiving program.

J-F



Re: [Mina] 'messageSent' semantic

Posted by Niklas Therning <ni...@trillian.se>.
daune.jf@daune-consult.com wrote:
> ...
> 
> 
> Do you mean that when the call
> socket.getOutputStream().write(myBufferOf1000Bytes) returns, it does not 
> mean
> that all 1000 bytes has been transmitted via TCP/IP to receiver?
> 
> What does it mean then? That the 1000 bytes are in TCP/IP stack's buffer?

Yes, I think so.

Read this post:

http://forum.java.sun.com/thread.jspa?forumID=11&threadID=635138

/Niklas

Re: [Mina] 'messageSent' semantic

Posted by da...@daune-consult.com.
Niklas Therning <ni...@trillian.se> a écrit :

> daune.jf@daune-consult.com wrote:
>> Niklas Therning <ni...@trillian.se> a écrit :
>>
>>> daune.jf@daune-consult.com wrote:
>>>
>>>> Hi,
>>>>
>>>> when I receive the 'messageSent' notification, what is its semantic?
>>>>
>>>> Does it mean that the receiving end has received the message (from 
>>>> a TCP point
>>>> of view, i.e. that all bytes have been received)?
>>>>
>>>> Regards,
>>>>
>>>> J-F
>>>
>>>
>>> No, it only means that the message has been written to the 
>>> SocketChannel corresponding to the session. There's no guarantee 
>>> that the receiving side has received any of the message bytes yet.
>>>
>>> /Niklas
>>
>>
>> Thanks Niklas.
>>
>> Some clarifications:
>>
>> - Is it possible to know when message has really been received?
>
> No, I don't think so unless you add some kind of acknowledge message 
> to your protocol.

Do you mean that when the call
socket.getOutputStream().write(myBufferOf1000Bytes) returns, it does not mean
that all 1000 bytes has been transmitted via TCP/IP to receiver?

What does it mean then? That the 1000 bytes are in TCP/IP stack's buffer?

>> - If not why? Is it due to TCP/IP, OS, sockets, use of non-blocking I/O ?
>
> Well, I'm not an expert on TCP/IP but from what I know I think it 
> will be hard and require very low level programming to achieve that 
> kind of control. The Java abstraction of Socket IO (both blocking and 
> non-blocking) is too high-level.
>
> I guess one would have to map packet sequence numbers to messages and 
> then be able to intercept acknowledges of sent packets to do what you 
> want. I'm not sure if OS:es allows you to get that kind of control.
>
> But as I said, I'm no expert on TCP/IP so please correct me if I'm wrong.
>
> /Niklas
>




Re: [Mina] 'messageSent' semantic

Posted by da...@daune-consult.com.
I was trying to measure *in the server* the time between a message is received
by the client and the reply is received by the server.

This would have been nice for my performance tests.

But it merely seems impossible.

J-F

> Hi,
>
> On 1/11/06, Niklas Therning <ni...@trillian.se> wrote:
>> Well, I'm not an expert on TCP/IP but from what I know I think it will
>> be hard and require very low level programming to achieve that kind of
>> control. The Java abstraction of Socket IO (both blocking and
>> non-blocking) is too high-level.
>>
>> I guess one would have to map packet sequence numbers to messages and
>> then be able to intercept acknowledges of sent packets to do what you
>> want. I'm not sure if OS:es allows you to get that kind of control.
>
> I think what he needs to is to implement a "correlation identifier"
> (http://www.enterpriseintegrationpatterns.com/CorrelationIdentifier.html)
> in his message protocol.
>
>>
>> But as I said, I'm no expert on TCP/IP so please correct me if I'm wrong.
>>
>> /Niklas
>>
>




Re: [Mina] 'messageSent' semantic

Posted by Willian Mitsuda <wm...@gmail.com>.
Hi,

On 1/11/06, Niklas Therning <ni...@trillian.se> wrote:
> Well, I'm not an expert on TCP/IP but from what I know I think it will
> be hard and require very low level programming to achieve that kind of
> control. The Java abstraction of Socket IO (both blocking and
> non-blocking) is too high-level.
>
> I guess one would have to map packet sequence numbers to messages and
> then be able to intercept acknowledges of sent packets to do what you
> want. I'm not sure if OS:es allows you to get that kind of control.

I think what he needs to is to implement a "correlation identifier"
(http://www.enterpriseintegrationpatterns.com/CorrelationIdentifier.html)
in his message protocol.

>
> But as I said, I'm no expert on TCP/IP so please correct me if I'm wrong.
>
> /Niklas
>

Re: [Mina] 'messageSent' semantic

Posted by Niklas Therning <ni...@trillian.se>.
daune.jf@daune-consult.com wrote:
> Niklas Therning <ni...@trillian.se> a écrit :
> 
>> daune.jf@daune-consult.com wrote:
>>
>>> Hi,
>>>
>>> when I receive the 'messageSent' notification, what is its semantic?
>>>
>>> Does it mean that the receiving end has received the message (from a 
>>> TCP point
>>> of view, i.e. that all bytes have been received)?
>>>
>>> Regards,
>>>
>>> J-F
>>
>>
>> No, it only means that the message has been written to the 
>> SocketChannel corresponding to the session. There's no guarantee that 
>> the receiving side has received any of the message bytes yet.
>>
>> /Niklas
> 
> 
> Thanks Niklas.
> 
> Some clarifications:
> 
> - Is it possible to know when message has really been received?

No, I don't think so unless you add some kind of acknowledge message to 
your protocol.

> 
> - If not why? Is it due to TCP/IP, OS, sockets, use of non-blocking I/O ?

Well, I'm not an expert on TCP/IP but from what I know I think it will 
be hard and require very low level programming to achieve that kind of 
control. The Java abstraction of Socket IO (both blocking and 
non-blocking) is too high-level.

I guess one would have to map packet sequence numbers to messages and 
then be able to intercept acknowledges of sent packets to do what you 
want. I'm not sure if OS:es allows you to get that kind of control.

But as I said, I'm no expert on TCP/IP so please correct me if I'm wrong.

/Niklas

Re: [Mina] 'messageSent' semantic

Posted by da...@daune-consult.com.
Niklas Therning <ni...@trillian.se> a écrit :

> daune.jf@daune-consult.com wrote:
>> Hi,
>>
>> when I receive the 'messageSent' notification, what is its semantic?
>>
>> Does it mean that the receiving end has received the message (from a 
>> TCP point
>> of view, i.e. that all bytes have been received)?
>>
>> Regards,
>>
>> J-F
>
> No, it only means that the message has been written to the 
> SocketChannel corresponding to the session. There's no guarantee that 
> the receiving side has received any of the message bytes yet.
>
> /Niklas

Thanks Niklas.

Some clarifications:

- Is it possible to know when message has really been received?

- If not why? Is it due to TCP/IP, OS, sockets, use of non-blocking I/O ?

Thanks,

J-F





Re: [Mina] 'messageSent' semantic

Posted by Niklas Therning <ni...@trillian.se>.
daune.jf@daune-consult.com wrote:
> Hi,
> 
> when I receive the 'messageSent' notification, what is its semantic?
> 
> Does it mean that the receiving end has received the message (from a TCP point
> of view, i.e. that all bytes have been received)?
> 
> Regards,
> 
> J-F

No, it only means that the message has been written to the SocketChannel 
corresponding to the session. There's no guarantee that the receiving 
side has received any of the message bytes yet.

/Niklas