Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
ahanusa committed Jan 12, 2016
1 parent bfa2b8e commit 41f4dad
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -263,16 +263,16 @@ Let's take a look at a sequence diagram that entails a .NET client consuming the
![service-proxies](https://www.dropbox.com/s/47sbyr8kdj0w6il/server-sequence.png?dl=0&raw=1)

In this scenario, the .NET client invokes the ```Execute``` method of the [ShipOrderItemCommand](https://github.com/peasy/Samples/blob/master/Orders.com.BLL/Commands/ShipOrderItemCommand.cs) returned by the ```ShipCommand``` method of [OrderItemService](https://github.com/peasy/Samples/blob/master/Orders.com.BLL/Services/OrderItemService.cs).
The ShipCommand.```Execute``` method then invokes the ```Ship``` method of the injected [OrderItemsHttpDataProxy](https://github.com/peasy/Samples/blob/master/Orders.com.DAL.Http/OrderItemsHttpServiceProxy.cs), which issues an HTTP PUT request to the receiving ```Ship``` method of the [OrderItemsController (Web Api)](https://github.com/peasy/Samples/blob/master/Orders.com.Web.Api/Controllers/OrderItemsController.cs).
The ShipCommand.```Execute``` method then invokes the ```Ship``` method of the injected [OrderItemsHttpServiceProxy](https://github.com/peasy/Samples/blob/master/Orders.com.DAL.Http/OrderItemsHttpServiceProxy.cs), which issues an HTTP PUT request to the receiving ```Ship``` method of the [OrderItemsController](https://github.com/peasy/Samples/blob/master/Orders.com.Web.Api/Controllers/OrderItemsController.cs) (Web Api).

Because the ```Ship``` method of OrderItemsController is also configured to use the ShipOrderItemCommand, this logic will be executed again, thus decrementing the inventory twice (initially done on the client and then in on the server).
Because the ```Ship``` method of OrderItemsController is also configured to use the ShipOrderItemCommand, this logic will be executed again, thus decrementing the inventory twice (initially done on the client then on the server).

To address this issue, the [OrderItemClientService](https://github.com/peasy/Samples/blob/master/Orders.com.BLL/Services/OrderItemClientService.cs) class was created. This class extends [OrderItemService](https://github.com/peasy/Samples/blob/master/Orders.com.BLL/Services/OrderItemService.cs) and overrides the ```ShipCommand``` method to bypass the logic of the OrderItemShipCommand and directly marshal calls to the OrderItemsHttpDataProxy.Ship method, delegating the responsiblility of executing the OrderItemShipCommand logic on the server (Web API Controller).
To address this issue, the [OrderItemClientService](https://github.com/peasy/Samples/blob/master/Orders.com.BLL/Services/OrderItemClientService.cs) class was created. This class extends [OrderItemService](https://github.com/peasy/Samples/blob/master/Orders.com.BLL/Services/OrderItemService.cs) and overrides the ```ShipCommand``` method to bypass the logic of the OrderItemShipCommand and directly marshal calls to the OrderItemsHttpServiceProxy.```Ship``` method, delegating the responsiblility of executing the OrderItemShipCommand logic on the server (Web API Controller).

Here is a sequence diagram illustrating a new configuration using the client version in the .NET client:

![client-proxies](https://www.dropbox.com/s/cq6jiqrvrs1ux46/client-sequence.png?dl=0&raw=1)

In this configuration, the client shares business logic with the server, excepting the shipping functionality which is now handled exclusively on the server.

One final note is that the shipping logic in the OrderItemShipCommand executes atomically within the context of a transaction. As stated previously, it is notoriously difficult to orchestrate transactions against out-of-band HTTP invocations. Creating a client service proxy allows us to delegate that responsibility to the server, where it can orchestrate these transactions directly against the configured database.
One final note is that the shipping logic in the OrderItemShipCommand executes atomically within the context of a transaction. As stated previously, it is notoriously difficult to orchestrate transactions against out-of-band HTTP invocations. Creating a client service proxy allows us to delegate that responsibility to the server, where it can orchestrate these transactions directly against the configured database within a transaction context (DTC, etc.).

0 comments on commit 41f4dad

Please sign in to comment.