Your database can talk and xTuple can listen

We're excited to present a new feature in which the database can tell the xTuple client to do things. Up until now, this was a one-directional channel of communication from the client to the database. However, we've utilized Postgres' "NOTIFY/LISTEN" functionality to send push notifications to xTuple. xTuple hears the notification and does something based on the notification's name.

You're probably wondering what this means for you.

Well, it's pretty neat. Previously, if your coworker edited the database in some way, you would have no idea until you requeried that table. Now, the table can say all across the network, "Hey! I just changed somehow. xTuple, you need to reload me." And if the xTuple client is listening, it'll update for everyone using the database. You'll see how this works with user privileges in our next release. Say you're the CEO and you take away an intern's ability to create administrative users. Before this update, you'd have to get up, walk down the hall, and tell him, "you better reload those privileges." Now, when you make the change, a notification is sent to everyone logged in to xTuple that the system is going to need to update their privileges. And the next time the user does something that requires a privilege check, their privileges will be automatically updated.

This also removes the need to poll the database for changes at clock tick intervals. We're working on an instant messaging system built into the xTuple client. New messages get added to the database. Before, every user was requerying the database every 60 seconds to see if they had a new message. Not-so-instant messaging. Now, the database tells xTuple that a new message has been posted, and to reload immediately.

When Qt5 is released, this feature will be even better, because the database will be able to pass extra information (called a payload) along with the notification, and Qt applications will be able to process it. The payload can be something like a user name, so we can make sure that only the affected user requeries the database. This improves performance and enables us to do even more things with the feature.

We're still searching for places to implement this in our software. Database notifications will greatly improve many different pieces of the xTuple application. Expect to see this functionality to appear all over xTuple in the near future. Thanks for reading!

Mike O'Donnell

Software Development at xTuple, July 2012 – August 2013

Graduated from James Madison University in May 2012 with a bachelor's degree in computer science and minor in music industry studies, focusing on production and recording.