Hi,
I get the error below when trying to write - Writer.write(instance, ref instance_handle);
What is the problem?
PRESWriterHistoryDriver_initializeSample:!serialize
WriterHistoryMemoryPlugin_addEntryToSessions:!initialize sample
WriterHistoryMemoryPlugin_getEntry:!add virtual sample to sessions
WriterHistoryMemoryPlugin_addSample:!get entry
PRESWriterHistoryDriver_addWrite:!add_sample
PRESPsWriter_writeInternal:!collator addWrite
write error DDS.Retcode_Error:
PRESWriterHistoryDriver_initializeSample:!serialize
WriterHistoryMemoryPlugin_addEntryToSessions:!initialize sample
WriterHistoryMemoryPlugin_getEntry:!add virtual sample to sessions
WriterHistoryMemoryPlugin_addSample:!get entry
PRESWriterHistoryDriver_addWrite:!add_sample
PRESPsWriter_writeInternal:!collator addWrite
Thank
Hi,
You could be setting an illegal value in the sample you're trying to publish. Can you share the type you're publishing or narrow down the potential problem by setting one field at a time, and publishing that sample until write() fails?
Alex
Hi,
I see it's happened when I send null for string field. if I send empty string - "", the error does not happen.
But I don't think it's the right way - to send empty string instead of null.
struct MyType{
long Id; //@key
string Name;
};
Thank
Hey,
As far as I'm aware, null values are only supported for fields which are set to be Optional (and I believe it only works if you set mutable extensibility).
Otherwise you can use a workaround:
1. determine "null" values and wrap the entities you've generated with a class which sets null values of entites before you send them (and then you'll need to identify null values receievd by the readers).
2. use a Sequence of length 1 and wrap the entities you've generated with a class which sends an empty sequence for fields that aren't initialized or sequences containing the 1 value that was set for a field (again, you'll need to unwrap the entities you read)
3. some other workaround I'm not familiar with
Roy.
Roy's right. If you want to not send a field (that is, write 'null'), you need to make it optional. In your case:
Optional works with all extensibility kinds (final, extensible, and mutable).
Alex
The solution isn't good enough for me. Because
I want send the field always, whether there is value and whether it has null.
I don't want not to send the field.
Thank
Assuming that both the reader and the writer use the same type, when you don't set an optional member (i.e. make it NULL), the receiving application will also see NULL.
If you write {2, "Hi"} and {3, NULL}, the receiving application will see exactly that: {2, "Hi"} and {3, NULL}.
As I wrote in my question- my problem is -
I don't receive null - it threw the exception
- "write error DDS.Retcode_Error:" (see above)
Did you add "//@Optional" after "string Name;" ?