(picture)

July 05, 2002

Dynamics, rollback and rollforward

An ugly hack has been preying on my mind since I wrote, about the tour,

If a transaction "from the past" arrives, the database will unwind, then roll forward again after applying the new transaction... To catch any "futurity", I wrap a GUID inside each event, and maintain a reasonably-sized table of already-handled events.
I knew that was ugly (and stupid and wasteful) when I wrote the code, too. There really had to be a way to ask Dynamics whether it's currently rolling back or forward, or processing commands for the first time.

There is, of course. It's in Dynamics, and I only stumbled across it this morning whilst debugging something else, so now I applied it onto the tourcode too. This improves performance, reduces the memory footprint (no need for a stupid hashtable now), reduces network traffic (no need for a GUID on the event elements), and improves reliability too. Whenever you want to track state dynamically in a Groove tool, you should know about this.

The interface to look at is IGrooveCommandContext2; this is accessible by a property on IGrooveDynamicsManager. So you can get this in Script by

	var pDynMgr = PropertyList.OpenProperty(PROPERTY_DYNAMICS_MANAGER);
var pContext = pDynMgr.CommandContext;

then look at the properties on this interface, which tell you more than you ever needed to know. The RollbackRollforward property is true if this is part of a rollback or rollforward.