POC: Upgrade EPiCommerce without losing orders?

So you want to update your EPiServer Commerce site, but you don’t want to lose orders. That’s still not really possible, a little downtime is still needed, or I missed something. So I did a little POC.

I created a “messaging” service. You can send a cart to it. The cart will be put into the message queue of your service bus in Azure (your website can be on premise, you can just use a service bus). There is also a scheduled job that reads the carts from the queue and converts them to a purchase order.

You could use it in case you want to update your EPiServer Commerce site on a different slot and swap when the update is successful.

Disable the scheduled job. Orders will stay in the queue. Enable the scheduled job when you have updated/upgraded and swapped. Your orders will be created in the updated store. No downtime. No orders lost.

If you take Quicksilver as a reference, in your checkout controller you would call _checkoutService.SaveCartAsPurchaseOrder, delete the cart, send an email, redirect to confirmation page. When using this POC you could add something like this to your checkout service:

public void SendCartToQueue()
{
    if (this._iMessagingService.MessagingEnabled && this._iMessagingService.SendMessage(this.CartHelper.Cart))
    {
      return;
    }

    this.CartHelper.Cart.SaveAsPurchaseOrder();
}

If the cart has not been put in the queue successfully it will do the “usual” thing and saves it as a purchase order. After putting it in the queue, you can delete your cart as if you would have created your purchase order already. Of course you will have to change around some things, sending the email, your confirmation page, as your purchase order will/could be delayed a bit.

I will not put and explain the entire code here. It’s quite self explaining, I think/hope, but if something is unclear, just ask me. I have created a Gist with all the code from this POC.

Remember: this is a POC. It works “on my machine”, and it has only been tested locally and with a “manual” load.

One thought on “POC: Upgrade EPiCommerce without losing orders?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s