0
$\begingroup$

Rosanswers logo

Suppose I have two publishers P1 and P2 that publish a same topic M, which is received by two other subscribers S1 and S2, is there a way to ensure that both subscribers will receive M messages in a same order as published from P1 and P2? For example, if P1 publishes a M message and after some time P2 publishes another M message, is it possible to guarantee that both S1 and S2 will receive the M message from P1 and then the one from P2? My understanding is that this can be generally hard to ensure in a message-passing based distributed system. Thanks for any answering or clarification!


Originally posted by hongkedavid on ROS Answers with karma: 3 on 2018-06-22

Post score: 0


Original comments

Comment by gvdhoorn on 2018-06-22:
This reads a little like a homework question.

Can you give a little more context and clarify why you are asking this?

Comment by hongkedavid on 2018-06-22:
I am a PhD student working on autonomous vehicle (AV) security. I used this example to simplify my question for ease of understanding. I am working on a ROS-based autonomous vehicle system that relies on ROS pub-sub messaging model to interact between self-driving modules, including P1, P2, S1, S2

Comment by pengjiawei on 2018-06-23:
does "a same topic M" means that the name and type of topic is same?

Comment by hongkedavid on 2018-06-26:
Yes, "a same topic M" means that the name and type of topic are same.

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

There is no guarantee for inorder delivery from multiple publishers to one or more subscribers. Nor is the order guaranteed to be the same for the two subscribers. Each publisher and subscriber pair has a separate communication channel open.

You're right that in a distributed system this is generally hard. Knowing the order of who published first is no really even known. Generally I'd recommend making sure that you put timestamps in your messages and make your algorithm robust to out of order delivery. As well as making sure that your system clocks are well synchronized.

If you want guaranteed ordering and confirmed delivery I'd recommend using services which provide confirmation of delivery. There's more overhead and they block, but that's the trade-off for the guarantees.


Originally posted by tfoote with karma: 58457 on 2018-06-23

This answer was ACCEPTED on the original site

Post score: 1


Original comments

Comment by hongkedavid on 2018-06-26:
Got it. Thanks very much for your detailed explanation!

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.