0

I have created a sample rti dds java project. However the subscriber is not recieving data if the writer.write() is not within a loop with a thread sleep.

Subscriber doesn't get the data

instance.ID = 10;
instance.value = 3.14;
writer.write(instance, instance_handle);

Subscriber get's the data

        for (int count = 0;
        (sampleCount == 0) || (count < sampleCount);
        ++count) {
            System.out.println("Writing myExample, count " + count);

            /* Modify the instance to be written here */

            /* Write data */
            instance.ID = 10;
            instance.value = 3.14;
            writer.write(instance, instance_handle);
            try {
                Thread.sleep(sendPeriodMillis);
            } catch (InterruptedException ix) {
                System.err.println("INTERRUPTED");
                break;
            }
        }
user1184100
  • 6,742
  • 29
  • 80
  • 121
  • 1
    Are you aware that the proces of publishers discovering the subscribers and vice-versa is asynchronous? This means that you might be doing the `write()` call before the present subscriber and publisher have become aware of each-others existence. Therefore, communication does not (yet) take place. Would this match with your experience? – Reinier Torenbeek Apr 02 '17 at 16:06
  • 1
    Added to Reiner's comment, we don't see what's going on around the direct write -- I've seen people do the write as the last thing before System.exit() and then wonder why the connected subscribers didn't get the final publish. – rip... Apr 02 '17 at 17:20

0 Answers0