Yes, it should be possible, but it needs a bit more setup. After they are created writers and readers (as well as any DDS::Entity
) have an enable
function that has to be called before they can be used. By default this is called automatically by create_datawriter
and create_datareader
. This is important because readers and writers can't change their config after they're enabled. You have to disable the autoenable_created_entities
property in parent entity's QoS, create the reader or writer, call bin_config
, and finally call enable
manually. Section 3.2.16 of the OpenDDS Developer's Guide talks a bit about this, but doesn't have an example, so here's snippet that I tested with the error checks and unrelated args omitted:
DDS::PublisherQos pub_qos;
participant->get_default_publisher_qos(pub_qos);
pub_qos.entity_factory.autoenable_created_entities = false;
DDS::Publisher_var publisher =
participant->create_publisher(pub_qos, /*...*/);
DDS::DataWriter_var datawriter1 = publisher->create_datawriter(/*...*/);
TheTransportRegistry->bind_config("tcp1", datawriter1);
datawriter1->enable();
You can also set this QoS on the domain participant or the service participant instead of the publisher or subscriber, but that requires manually enabling all the entities, which includes the publishers, subscribers, and topics, so I'm not sure I recommend that.