rticonnextdds-connector resource cleanup

4 posts / 0 new
Last post
Offline
Last seen: 2 months 2 weeks ago
Joined: 02/07/2020
Posts: 10
rticonnextdds-connector resource cleanup

In my case, I am using rticonnextdds-connector-js, but suspect the question applies to the connectors in general:  how do you clean up individual datareaders and datawriters?

For instance, when getOutput() is called, it looks like a datawriter is created internally.  Even though a write({action: 'dispose'}) might release internal resouces, I don't see a means of releasing the datawriter itself.

Offline
Last seen: 1 month 5 days ago
Joined: 10/22/2018
Posts: 64

Connector uses XML Application Creation to create the entities. All of the entities which you have defined in your XML file are created when the Connector object is created. When you call get_input for example, that DataReader has already been created, you just get a handle to it in your application. When you close the Connector object, they are deleted.

Offline
Last seen: 2 months 2 weeks ago
Joined: 02/07/2020
Posts: 10

I'm more concerned about the writers, but maybe the answer is the same?  Because I have only one publisher and writer defined in the XML, multiple calls to getOutput() with the same name is just going to return that writer? 

As a follow-up question, based on what I see, each call to getOutput creates an Output wrapper object that gets its own Instance object, but I don't see how the API calls distinguish between keyed instances.  Does this mean that I need to create multiple datawriters in the XML configuration?

Offline
Last seen: 1 month 5 days ago
Joined: 10/22/2018
Posts: 64

1. Correct, for DataWriters it is the same -- they are created when the XML is parsed upon Connector creation and deleted upon Connector deletion.

2. Correct again, each DataWriter you define represents a single DataWriter. Multiple calls to get the same DataWriter will just return the handle to the same writer.

3. Each time you call getOutput you are obtaining the same DataWriter. You could use this single DataWriter to write multiple instances by changing the key fields between writes. The other option is, as you mention, define multiple DataWriters in your XML file. I wouldn't reccommend having multiple handles to the same DataWriter in your application.