mercoledì, gennaio 12, 2011

Programmatically persisting an Orchestration

Sometimes ago I had the necessity to persist an orchestration just before entering an atomic shape (you’ll see in the next post why…)

Unfortunately, as any good biztalker knows, persistence point are decided by Engine when one of the following conditions happen:

  • Start Orchestration Shape
  • Suspend Shape
  • At the end of transactional scope (Atomic and LongRunning)
  • When Orchestration terminates
  • When the engine determines that the instance should be dehydrated.
  • When the Orchestration engine is asked to shutdown.
  • When a Debugger breakpoint is reached.
  • Send Shape (at the end of)

So it seems there’s no way to persist the state just before entering an atomic scope(the closest thing is to put another transactional scope just before the atomic one but you’ll agree that’s a bad & ugly workaround).

Anyway, looking a bit inside the Service Class, I noticed the following method:

   1: public void Persist (
   2:     bool dehydrate,
   3:     Context ctx,
   4:     bool idleRequired,
   5:     bool finalPersist,
   6:     bool bypassCommit,
   7:     bool terminate
   8: )

Parameter names seems self-explanatory to me and therefore I tried to invoke it from an expression shape placed just before the atomic scope:

   1: Microsoft.XLANGs.Core.Service.RootService.Persist(
   2: false, // dehydrate.
   3: Microsoft.XLANGs.Core.Service.RootService.RootContext, // ctx: The actual service instance context.
   4: false, // idleRequired.
   5: false, // finalPersist.
   6: false, // bypassCommit.
   7: false // terminate.
   8: );

The result was that Orchestration Service Instance persisted as soon as it reached the expression shape instead of waiting the end of the atomic scope.

Nessun commento: