locked
ResponsePorts and sending notifications to subscribers RRS feed

  • Question

  • Using this code snippet from the DSS docs:

     

    [ServiceHandler(ServiceHandlerBehavior.Exclusive)]
    public
     void
     InsertItem(InsertItem insert)
    {
     _state.List.Add(insert.Body);
     insert.ResponsePort.Post(DefaultInsertResponseType.Instance);
     SendNotification(_subMgrPort, insert);
    }
    
    

     

    I am trying to understand the ResponsePort's usage. I assume the ResponsePort is the "service forwarder" (i.e the representation of the main port of the calling service).  However, is the function of this code:

    ResponsePort.Post(DefaultInsertResponseType.Instance)

    Just to ensure the service who invoked the Insert knows that the Insert handler has been executed ?  Since we are sending a notification with the insert object, would there really be a need for the post on the response port ?

    Thanks in advance.

    Thursday, July 8, 2010 5:09 PM

Answers

  • The response port is usually a PortSet with the response type and "Fault" class. When you send a request to a service, you may want to know if your request has been successful, so you just wait back for a response on the response port. With only the notification, you would have no way to check if your request has been executed correctly :

    - On error, usually a service doesn't send a notification

    - The notifications could be issued by another request sent by another service

    Additionaly, the reponse port pattern is very easy to use when you need to do some coordination

    Regards,

    Vincent


    http://www.simplysim.net/
    • Marked as answer by Rybolt Friday, July 9, 2010 1:25 PM
    Friday, July 9, 2010 6:18 AM