QoS Settings to Resolve Lost Samples PreviousNext
Data Distribution Service (DDS) Forum > DDS FAQ >
Message/Author
Next message Jawaad Ahmad  posted on Friday, March 09, 2012 - 07:41 pm
Hello. I'm using OpenSplice DDS Community Edition version 5.4.1 with Visual Studio 2010.

This question has been asked and answered several times on different forums; however, I have not come across any code to show exactly how to accomplish this. I would appreciate if someone can show me exactly what I'm doing wrong below so I don't lose samples when I write without sleeping.

I'm trying to take all written samples in a simple application without losing anything; however, I don't think I have my QoS settings perfectly right to get this behavior.

My IDL file specifies a structure without a key:


struct ChatMessage
{
string message;
};
#pragma keylist ChatMessage


My loop sends a certain number of messages as fast as possible:


for (uint i = 0; i < numMessages; ++i)
{
StringBuilder s = new StringBuilder();

if (i == 0)
{
s.Append("Flood started. ");
}
else if (i + 1 >= numMessages)
{
s.Append("Flood complete. ");
}

s.AppendFormat("Flooding: Message {0} of {1}.", i+1, numMessages);
ChatMessage message = new ChatMessage();
message.message = text;
message.messageIndex = ++_messageIndex;
message.publisherId = _publisherId.ToString();
message.userId = _userId;

ReturnCode status = _talker.Write(message);
ErrorHandler.checkStatus(status, "Chat.ChatMessageDataWriter.Write");
}


Here are the QoS settings I have set:


qos.[b]Reliability.Kind [/b]= ReliabilityQosPolicyKind.ReliableReliabilityQos;
qos.[b]History.Kind [/b]= HistoryQosPolicyKind.KeepAllHistoryQos;
qos.History.Depth = 1000;
qos.Durability.Kind = DurabilityQosPolicyKind.TransientDurabilityQos;
qos.ResourceLimits.MaxInstances = 10000;
qos.ResourceLimits.MaxSamples = 10000; // >= max samples per instance
qos.ResourceLimits.MaxSamplesPerInstance = 10000; // >= history depth


I have applied these settings to: TopicQos, DataWriterQos, DataReaderQos.

The same application is supposed to receive the samples:


ReturnCode result = _waitset.Wait(ref conditions, timeout);

if (conditions != null)
{
foreach (ICondition condition in conditions)
{
SampleInfo[] infolist = null;

if (condition == _listener.StatusCondition)
{
ChatMessage[] datalist = null;
_listener.Take(ref datalist, ref infolist, SampleStateKind.Any, ViewStateKind.Any, InstanceStateKind.Any);

if (datalist.Length > 0)
{
if (datalist.Length > 1)
{
Log("Ignoring excess messages");
}

ChatMessage message = datalist[0];
AppendChat(String.Format("\r\n{0}[{1}]: {2}", message.userId, message.messageIndex, message.message));
}
else
{
Log("Status condition triggered but no data available");
}
}
else if ...
else
{
Log("Unexpected condition triggered");
}
}
}
else
{
Log("Message lost");
}


When I run the code, I press a button to run the loop a number of times: maybe 10, maybe 100, maybe 1000. In eachc case, I only receive back a small number of my original messages. Sometimes two, maybe four.

Does anyone know what I'm doing wrong?

Thanks.
Next message Hans van 't Hag  posted on Monday, March 12, 2012 - 02:37 pm
Hi Jawaad, better to post on the OpenSplice specific forum(s) at forums.opensplice.org

Anyhow, maybe your 'issue' is that you treat receival of multiple samples from a single take() operation as 'excessive' samples (which they would be in the pingpong scenario where you only expect 1) yet in your usecase, these are all 'valid' samples so you should count each and every one of them and perhaps then you don't "loose" any data anymore,

Regards,
Hans
Next message Jawaad Ahmad  posted on Tuesday, March 20, 2012 - 04:53 pm
Hello, Hans,

Thanks for the help. You were absolutely correct. The "excess messages" case was the culprit.

We modified the code to replace the "if (datalist.Length > 1)" condition with a loop to go through all elements of datalist. This works perfectly.

Thanks again for your help!
Back to top
Add Your Message Here
Post:
Username: Posting Information:
This is a private posting area. Only registered users and moderators may post messages here.
Password:
Options: Post as "Anonymous"
Enable HTML code in message
Automatically activate URLs in message
Action: