eclipse-cyclonedds / cyclonedds

Eclipse Cyclone DDS project
https://projects.eclipse.org/projects/iot.cyclonedds
Other
799 stars 349 forks source link

Can the subscriber distinguish the message come from? #1984

Closed dspeia closed 2 months ago

dspeia commented 2 months ago

I want to set this domain: 1x subscriber, 2x publisher. and those use the same topic(same message type) to communicate. If 2x publishers write the same message value(such as str "hello world") to the subscriber, Can the subscriber distinguish from whom (participant or publisher) these two messages come from? is there are participant ID or publisher ID to distinguish?

eboasson commented 2 months ago

Yes, the subscriber can distinguish between the two (the publication_handle in the dds_sample_info_t). For example, ddsperf uses it to track things independently for each peer.

I don't know what problem you are trying to solve, but I do want to say that, at least in my experience, it usually works out nicer if you can put a meaningful source id in the topic yourself (and possibly to then make that a key field as well).

dspeia commented 2 months ago

Hi, eboasson

Thanks for your answer, The problem is I don't want to distinguish the message's source writer by the parameter value inside the message. And the key can solve it, I will use the read_instance to distinguish messages before getting their parameter value.