Community Tip - You can subscribe to a forum, label or individual post and receive email notifications when someone posts a new topic or reply. Learn more! X
Hello
I'm creating things when not existing using code recommandations.
It works fine, I can use the things in services, MAshups ... but it doesn't appear in the list of things of the composer.
restart tomcat8 : not OK
reboot server : OK
any ideas ?
my code :
try { var params = { name: DeviceName, description: "This is a device automatically created on data reception at " + today, thingTemplateName: "MyTemplate" }; Resources["EntityServices"].CreateThing(params); // Always enable and restart a new thing to make it active on the Platform Things[DeviceName].EnableThing(); Things[DeviceName].RestartThing(); // Any code that could potentially cause an exception should // also be included in the try-catch block. logger.debug ( logprefix + DeviceName + " created !!!"); } catch (err) { // If an exception is caught, we need to attempt to delete everything // that was created to roll back the entire transaction. // If we do not do this a "ghost" entity will remain in memory // We must do this in reverse order of creation so there are no dependency conflicts // We also do not know where it failed so we must attempt to remove all of them, // but also handle exceptions in case they were not created logger.debug ( logprefix + DeviceName + " EXCEPTION! = " + err + " --- to be deleted" ); try { var devicename = devicename ; var params = {name: DeviceName}; Resources["EntityServices"].DeleteThing(params); logger.debug ( logprefix + DeviceName + " deleted !"); } catch(ex2) {//Thing was not created logger.debug ( logprefix + DeviceName + " not deleted ! EXCEPTION! = " + ex2); } } result = DeviceName ;
Hi @pjoly does it behaves the same if you were to manually call the CreateThing service? I tried testing it by calling CreateThing in a loop all created things shows up for me without any reboot.
Which ThingWorx version are you on?
Hello @supandey
Yes if I create the thing manually with the composer or if I call manually the service from the composer, I can see it directly in the list of things.
I'm using Thingworx 7.4.9
FYI the service to create the thing is called from MQTT subscriber (user is system) . But the thing is well created, just not displayed
Regards
@pjoly sorry for some delay in getting back to this, I could not reproduce this issue so far, even when i have the thing creation service automatically triggered based on a dummy event raised by a Timer i tested this on v8.3.1. Based on the the timer event thing gets created and i can instantly see that once i navigate to the ThingWorx Composer > Things
Have you tried this on any other ThingWorx version?