Queue function calls?

Posts   
 
    
Valdar
User
Posts: 24
Joined: 07-Oct-2005
# Posted on: 02-May-2006 22:24:19   

I have been struggling with this issue in our software for a while and we have a kludge that works, but it hard to add new functions to.

I would like something where I can store up a function call in a db then later retrieve that function call and simply run it.

Right now we have a Queue table that stores an identifier for which method to call and then has a field called ARguments that sends the arguments separated by "|" characters. Other info such as priority exists too.

Then when the system is not busy is goes through the Queue table and knocks off each item by an algorithm based on priority, insertion time, and required run date.

Ideally I would like to serialize a method call with all the arguments in place store that in the db to be retrieved at a later time (this is basically wha tI am doing, but it's a pain to hand write all the code for it).

I would think something like MSMQ would work, but we can't use that because we can't gaurantee it will exist on the systems where our software will be installed.

Thanks for any insight into this.

jeffreygg
User
Posts: 805
Joined: 26-Oct-2003
# Posted on: 02-May-2006 23:05:11   

If read/write access performance isn't important you could use the .NET Queue in code, then serialize the queue to a field in the DB. Then, when needed, you could retrieve the serialized object, deserialize it, then execute the methods and parameters using Reflection. Though, technically it's not a queue if you're not executing it in the order it was inserted. wink

Something like:



<Serializable()> _
Public Class QueueItem
   Public Property FullyQualifiedMethodName as String
   Public Property Params() as Object
   Public Property Priority as Integer
   Public Property InsertionTime as DateTime
   Public Property RequiredRunDate as DateTime
End Class


Jeff...

Valdar
User
Posts: 24
Joined: 07-Oct-2005
# Posted on: 02-May-2006 23:10:06   

Read/Write performance isn't important. That is an excellent idea thank you for the help.

I was thinking I could use reflection somehow, but I wasn't sure how I would pass the parameters, but I think I can get it now.