Offline Capability Openbravo POS 2.30.2

  • dkovacevic

    dkovacevic - 2012-11-27

    In my environment, the only main thing I need Openbravo POS to do is make sales. To make sales, the database is accessed to query items, and to store the sales.

    Storing the sales involves SQL INSERTs and UPDATEs. Might it be possible to cache these in, say, an ArrayList if the database connection is down, then process them when the connection is restored?

    As to the read requests (SELECT statements), it could be possible to implement a distributed database system with a single master for the writes, and multiple slaves (read only).

    Openbravo POS would also need to be modified to support having two databases, but that wouldn't be too difficult, I think.

    Has anyone done anything like this, or have any other suggestions for offline capability of the POS?

  • Redhuan D. Oon

    Redhuan D. Oon - 2012-11-29

    I am not sure if what i tried fit your requirements here
    If it can work in my POC - proof of concept, it should work for any standalone/offline scenario. 

  • dkovacevic

    dkovacevic - 2012-12-06

    I have made the modifications necessary to run Openbravo in a very crude "offline" mode. I allowed many of the source classes to receive an additional "Session" (object?) when initiated.

    Basically, I use one session as the "local" database connection and the other as the "main" database connection.

    This done, a local database is used for handling routine "select" queries. Of particular importance to me was allowing the local database to handle product queries made by the use of the keyboard at the main sales panel.

    The SQL queries for resources, sales/refunds, and close cash use the "main" connection. By using an ArrayList queue, sales made while the connection to the "main" database is down are saved until the connection is restored. (Eventually, I would like to make this record queries to files in the event that the register must be powered down).

    I have absolutely no idea whether this will work well in production; I have a lot more testing to do.

  • Anonymous

    Anonymous - 2012-12-13

    Hi dkovacevic.

    I think your work is very interesting, do share your updates. thanks

  • dkovacevic

    dkovacevic - 2013-02-27

    Hello Jcchua,

    I decided to abandon where I was going with my code in the above description. It became very unwieldy having two database connections (

    HOWEVER, I did successfully solve my problem in another fashion.

    Using another open source tool called "Symmetric DS", I was able to replicate databases for Openbravo, so that each computer register with Openbravo has a database installed on it as well. In this manner, even if the Ethernet cable comes unplugged, the sales will continue, and the data is cached.

    I did have to do a couple small changes to the Openbravo database structure.

    1. Completely disable the modification of the "STOCKCURRENT" table in the source code (namely,
    2. Create a trigger to update STOCKCURRENT based on STOCKDIARY inserts

    Doing these things allowed me to use Symmetric DS to replicate each register database to the main corporate database.

    The reason the STOCKCURRENT trigger is needed is because Symmetric DS, as of the version specified in this post: does not perform additive transforms correctly, which is how this issue might have been resolved using Symmetric alone (


Log in to post a comment.