Hello Niels,

Thank you for your fast reply. This was in fact the problem, I do receive 
consecutive messages now.

Greetings,

Pepijn

From: developer-boun...@opensplice.org 
[mailto:developer-boun...@opensplice.org] On Behalf Of Niels Kortstee
Sent: dinsdag 15 mei 2012 14:08
To: OpenSplice DDS Developer Mailing List
Subject: Re: [OSPL-Dev] Reading every published message only once per subscriber

Are you pre-allocating the 'hello_dataList' and 'infoList' or are you letting 
the middleware allocate those? If you're doing the latter, the 'return_loan' 
method needs to be called after processing the samples or at least before the 
next take. If that step is omitted a consecutive take will return 
'PRECONDITION_NOT_MET' (return code is not checked in your code) and the 
buffers will remain untouched.
On 15 May 2012 13:32, Pepijn Schoen 
<p.w.sch...@differ.nl<mailto:p.w.sch...@differ.nl>> wrote:
Hello all,

I've created a DataReader, DataWriter and topic with all default QOS policies. 
I'm continually publishing data, but the DataReader keeps on receiving only the 
first message published. I'm using the code shown below to read messages:
result = hello_reader->take (hello_dataList, infoList, LENGTH_UNLIMITED, 
NOT_READ_SAMPLE_STATE, ANY_VIEW_STATE, ALIVE_INSTANCE_STATE);

I've changed this from the default to notice a difference. The default was:
result = hello_reader->take (hello_dataList, infoList, 1, ANY_SAMPLE_STATE, 
ANY_VIEW_STATE, ANY_INSTANCE_STATE);

This did not give any other result. My question is: how do I read messages only 
once, and move up in the queue of available messages? (the relevant sample of 
the code is shown at the end of the message)

Greetings,

Pepijn


- Sample code -

while (!terminate) {
       ConditionSeq_var conditionList = new ConditionSeq();
       result = w.wait (conditionList.inout (), DURATION_INFINITE);

       if (result == DDS::RETCODE_ALREADY_DELETED) {
              terminate = TRUE;
              continue;
       }

       int imax = conditionList->length ();
       for (int i = 0; i < imax; i++) {
              if (conditionList[i].in() == hello_status) {
              result = hello_reader->take (hello_dataList, infoList, 1, 
ANY_SAMPLE_STATE, ANY_VIEW_STATE, ANY_INSTANCE_STATE);

              int jmax = hello_dataList->length ();
              if (jmax != 0) {
                     for (int j = 0; j < jmax; j++) {
                            if (infoList[j].valid_data) {
                                   HelloTopicType ht = hello_dataList[j];
                                   cout << ht.message << endl; // The exact 
same message keeps on being published again and again
                            }
                     }
              }
       } else {
              cout << "unknown condition triggered: " <<  conditionList[i].in() 
<< endl;
       }
}


_______________________________________________
OpenSplice DDS Developer Mailing List
Developer@opensplice.org<mailto:Developer@opensplice.org>
Subscribe / Unsubscribe http://dev.opensplice.org/mailman/listinfo/developer

_______________________________________________
OpenSplice DDS Developer Mailing List
Developer@opensplice.org
Subscribe / Unsubscribe http://dev.opensplice.org/mailman/listinfo/developer

Reply via email to