cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Your Friends List is a way to easily have access to the community members that you interact with the most! X

How to rollback in case failure in execution of statements

rkandasamy
7-Bedrock

How to rollback in case failure in execution of statements

Hi Team,

In a service of thing say DeviceMaster, we have three steps.

1. Update a property in DeviceMaster.

2. Create another thing say Device1 ,Enable it, restart it.

3. Add Device1 to a Network  Say "DeviceNetwork".

Now if the DeviceNetwork is deleted or deactivated before the service reaches the third step, does any automatic roll back take place?

Will Device1 still exist?

Will the updated value in the DeviceMaster change to earlier value?

Please provide your inputs. If it does not happen automatically, Can you suggest a better way for doing the same?

Thanks in advance.

4 REPLIES 4
ttielebein
14-Alexandrite
(To:rkandasamy)

Hello,

The Thing Device1 should be created properly and the property in DeviceMaster should be updated, even if the service fails at a later step. If this is not the behavior you want, I would recommend verifying that the DeviceNetwork exists before creating any Things meant for that Network or updating any properties. A single if statement outside of all your current logic should suffice. Hopefully this helps.

Thanks!

Tori

Aanjan
12-Amethyst
(To:rkandasamy)

Rdhakrishnan, using Try-catch statements would help as well. When you have create Things on a script and it fails, it will lead to creation of ephemeral Things or 'ghost' entities. The only way at the moment to clear them would be to restart Tomcat. Here's an article that expands more on this topic.

Thanks for the reply. So when the third step fails and it is caught on catch statement, Do you mean to manually undo the steps like by

Deleting the created thing and updating the property to earlier value?

Yes that's what you should do.

Announcements


Top Tags