Question
Create Thing Dynamically OK but doesn't appear in Composer until reboot !!
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 ; 
