Skip to main content

Executing transactions

In Altogic, you can execute database transactions to commit or rollback multiple data update operations to keep your database consistent even in cases of errors. To add transaction support to your services, you need to follow the following 3 steps.

Step #1 - Create a transaction

You can easily create as many transactions as you like in start nodes of endpoint, messaging, or task services. Just open the service flow that you would like to add the transaction, select the start node and at the bottom of the start node properties panel, select add transaction and give your transaction a name.

Step #2 - Update database nodes with transaction info

The next step is to define the scope of the transaction. For example, if multiple nodes make updates on the database, it makes sense to update these nodes to use the created transaction. Depending on your business needs, select the nodes that will be executed within the transaction context.

In the below example, we have two nodes making updates to two different models, salesOrder and product. If we change the sales quantity, we might also need to update the salesOrder with the new quantity and update the product inventory amount to reflect the changes. In this case, we update these two nodes to run within the context of our newly created transaction to ensure data integrity.

Step #2 - Commit or rollback the transaction

The final step is to commit the transaction if all database operations complete successfully or rollback it in case of errors. Altogic uses Commit Transaction and Abort Transaction nodes to perform these operations.

In the below example, we add a Commit Transaction node to the end of the service to permanently apply our data changes to the database.


Usually, you do not need to add a Commit Transaction or Abort Transaction node to your service flow unless you would like to perform additional activities in case of success or errors. Any uncommitted transactions are either automatically committed or aborted at the end of service execution. If the service completed its processing successfully then uncommitted transactions are committed. Similarly, if the service completed its processing with errors then uncommitted transactions are aborted.