How to develop with Synchronized Transactions
This howto gives insight in how to write functionality which works correctly also in case of synchronized transactions. In synchronized mode the WebPOS user interface remains blocked while the transaction is being processed on the server. Any results are shown (or can be used) directly to the user.
Synchronized transactions need special handling in both client as well as server side code:
- client side code needs to be able to restore the original pre-user-action-state after the server reports an error
- with synchronized mode the developer can return server side process results directly to the front end. So on the server the code can create results which are send back to the client.
- synchronized mode and multi-server have special features which need to be considered when developing store as well as central server code.
Before starting this howto make sure to read the howto setup a dev environment. It also makes sense to have a clear understanding of the states of an Openbravo Commerce server (offline, online, transitioning etc.).
Also the howto assumes that the reader is familiar with the main concepts/information provided by the retail developers guide.
For the topic of synchronized transactions make sure to read special wiki page.
Installing the how to module
The examples provided in this howto can be found in the Store Server Howto module. The howto module can be downloaded using the hg clone command in the modules directory:
hg clone https://code.openbravo.com/erp/mods/org.openbravo.retail.storeserver.howto
After this execute the 'ant smartbuild -Dlocal=no' command in the main project directory.
Synchronized Transactions - Enabling
Synchronized mode is enabled by setting the preference: WebPOS Synchronized Mode to Y.
Synchronized Transactions - Client Side
Synchronized transactions use the WebSQL tables which are present in
Synchronized Transactions - Server Side
The main thing
The result is shown in the screenshot below: