Concurrency conflicts - Chinook Media Manager

23 views
Skip to first unread message

dezzy

unread,
Mar 3, 2011, 12:48:30 AM3/3/11
to uNhAddIns
Hello all.

I am writing a WPF application following in the same style as Chinook
Media Manager (CMM). Things are working out well and I have come to
point where I need to think about concurrency.

I don't think José has written a blog post about concurrency for CMM
and so I did some research and came across the Effectus application
(José version) which has good examples of concurrency resolution using
Castle interceptors. This make sense and I can see how it all works.

My question relates to the presenter in the Effectus application which
has an OnException method which deals with the concurrency exception.
In CMM this would be handled at the manager level (i.e AlbumManager)
which represents the business use case (or another name such as
application service?). If concurrency is handled at that level what
would be the best way to notify the view model?

I am thinking about removing this application service layer
(AlbumManager) and putting my conversation attributes on my view model
and handle concurrency on the view model, similar to what the
presenter is doing in the Effectus application. Any thoughts about
this? Or indeed how would I signal to the view model from the
application service or manager layer that it needs to handle
concurrency? A simple event maybe?

Best of regards

Mohammad

José F. Romaniello

unread,
Mar 3, 2011, 7:31:08 AM3/3/11
to unha...@googlegroups.com


2011/3/3 dezzy <mohammad.s...@gmail.com>

My question relates to the presenter in the Effectus application which
has an OnException method which deals with the concurrency exception.
In CMM this would be handled at the manager level (i.e AlbumManager)
which represents the business use case (or another name such as
application service?).  If concurrency is handled at that level what
would be the best way to notify the view model?
I think a PersistentConversation with EndMode equals to End (or commit and continue) will throw an exception, 
IIRC this exception is encapsulated in a unhaddins exception. You can put a try/catch in the vm and show the proper information when this occurs.
 

I am thinking about removing this application service layer
(AlbumManager) and putting my conversation attributes on my view model
and handle concurrency on the view model, similar to what the
presenter is doing in the Effectus application.  Any thoughts about
this?

Yes,  I do this. I feel more confortable with the Postsharp adapter (uNhAddins.Postsharp), because it lets me wrap private methods.

What do you think if we add a new interface in uNhAddins.Adapters to handle these scenarios; like 

public interface ICanHandlePersistenceExceptions
{
    void HandleException(MethodInfo method, object[] parameters, Exception exception);
}



dezzy

unread,
Mar 3, 2011, 12:01:56 PM3/3/11
to uNhAddIns
Hi José,

Thanks for getting back to me.

You are correct in saying that all I need is a try catch in the view
model. The conversation will close the session on an exception and I
can start another conservation by calling another method with the
relevant attribute to start a new conversation.

Forgive my ignorance, but I don`t completely understand where the
concrete implementation of the ICanHandlePersistenceExceptions
interface would be used. I am not familiar with PostSharp (but i get
the idea) as I am using Castle Windsor. So would I have to implement
ICanHandlePersistenceExceptions in my project and register it with
Castle for it to be picked up by the Conversation code? Or is it an
attribute which marks a method?

Basically what I am asking is how would it be used?

Kind regards

Mohammad



On Mar 3, 12:31 pm, José F. Romaniello <jfromanie...@gmail.com> wrote:
> 2011/3/3 dezzy <mohammad.shahab.ra...@gmail.com>

José F. Romaniello

unread,
Mar 4, 2011, 5:24:25 PM3/4/11
to unha...@googlegroups.com, dezzy
I mean you will write something like this:

public class EditCustomerVM : ICanHandlePersistenceExtenptions
{
   public class EditCustomerVM(IDao<Customer> daoCustomer){ this.daoCustomer = daoCustomer;: }

   public string Name{get;set;}
   public string Address {get;set;} 

   [PersistenceConversation(EndMode = ConversationEndMode.End)
   public void Save()
   {
      daoCustomer.Save(new Customer{ Name = Name, Address = Adress } );
   }

   public void HandlePersistenceException(MethodInfo method, object[] parameters, Exception exception)
   {
        if(method.Name = "Save" && exception.... = "Stale")
        {
              messagebox.....("There is a new version of the object in the database");
        }
   }
}

It is like the Oren's example effectus.

2011/3/3 dezzy <mohammad.s...@gmail.com>
Reply all
Reply to author
Forward
0 new messages