Hi,
I am using MSMQ as a way to provide asynchronous SOA. Please refer to the code below as it's quite hard to explain. I am trying to figure out the best way to do it.
//another method reads off MSMQ and passes the Message into this method
public void ReadMSMQAndAction(Message m)
{
var e = m.Entity;
/* this is really bad, but i some how still need some
* kind of traffic cop to direct action */
switch typeof(m.Entity)
case Order.GetType()
switch e.Action
case "SAVE"
//todo OrderRepo Save
}
//Message gets searlized and put into MSMQ
public class Message<T>
{
public T Entity { get;set; }
/* should this be string?
* or some kind of rule i.e. "ClassName:MethodName" etc? */
public string Action { get;set; }
}
public class OrderRepo
{
public void Save(Order o) { /* todo */ }
public void Delete(Order o) { /* todo */ }
public void Update(Order o) { /* todo */ }
}
As the code gets more complex it'll be really hard to manage. Any suggestions are welcome! Thanks!