Server Event

  • 1 December 2008
  • 2 replies
  • 0 views

Badge +2

Hello Johnny!


This is Klaus... using Ton's Username.  Regarding the .NET Trigger thing.  I have the following Scenario:


In a DNA Deparment, Exhibits (Blood,Tissue,Hair) have to be examined with 4 different tests.  Every DNA Order is a separate instance of the same K2 Workflow.  But the testing procedure isn't possible to represent in a workflow.  A DNA Order could have many Exhibits... maybe up to 10.  And when they do the test the do many Exhibits of many DNA Orders at the same time.  So i have the following situation.


1.- Every Exhibit has 4 Flags... (when each of the 4 tests are completed).


2.- The Workflow should check maybe once every 6 hours if all the Exhibits contained in the DNA Order have all 4 Flags set to true.


I don't want to work with Database Triggers.  I prefer to have the logic inside the Workflow.  Is it possible to do something like this in the Server Event.



 connection.Open(serverName)



serverItem = connection.OpenServerItem(serialNumber);


Boolean flgChecking = true;



int intCounter = 0;



while (flgChecking)



{




Thread.Sleep(10000);




intCounter++;




if (intCounter > 10)




{





flgChecking = false;





serverItem.Finish()




}



}


Now this code isn't doing anything.  But i mean you can program the logic instead of intCounter > 10.  Is there a problem with this way of doing this.  Does this produce a Performance Problem.  Is K2 waiting for the answer of the Server Event.  Maybe the Server Event will have a Sleep(36000000).


Best Regards


Klaus.


2 replies

Badge +11

I don't know your business process, but you definitely don't want to use this approach.  Opening a server event item from within same process should never be done.  By using Thread.Sleep, you are not allowing the workflow engine to schedule its own work and will likely quickly exhaust your threadpool.


 David

Badge +9

I agree with DavidL's concerns around using the Workflow.Client.Connection within the process definition on the current process instance as well as the potential performance implications of using Sleep() a lot.

While not fully understanding your specific requirements, if you want to build this into the process definition I would consider using an activity Start Rule or activity Destination Rule to achieving the database check.  Both Start and Destination Rules cause this "check" to be scheduled within K2, which will dehydrate the process instance from memory (and thus not consuming a thread like Sleep() does). 

Additionally for general concepts, I'd recommend you review the K2 Best Practices KB 352 (http://kb.k2workflow.com/Articles/KB000352.aspx).

HTH.

Reply