Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Alexey Badyl 33 posts 205 karma points
    Nov 19, 2013 @ 16:22
    Alexey Badyl
    0

    Empty Properties under Load Balancer

    Hi, we have installed TC (2.1.3) on 2 servers. They are accessible via Load Balancer.

    To Save Custom Properties we use TC.AddOrUpdateOrderProperties.

    We are manually finalize order at one server (redaction), so all confirmation flow are at the same server.

    To finalize order and change custom properties on confirmation step we use the following code

    Order order = TC.GetOrder();

    order.FinalizeOrder();

    Then we add some information into properties and then via order.Save() save it.

    Source of problem:  Sometimes properties we saved are gone. So they not present in database (and under admin page), but was before Confirmation page was called.

    How should I work with order (api) in this case.

    I think this is somethig with cache when order was created at first server but finalized on second(redaction)?

    Can you suggest how to fix it?

    Thanks.

     


     

     

  • Anders Burla 2560 posts 8256 karma points
    Nov 19, 2013 @ 17:31
    Anders Burla
    0

    Hi Alexey

    I have never worked with load balancers so im not an expert in this thing :)

    What might happen it that the order is cached at one server but not the other - but TC is using a session variable to save the current order number in. So if the order number is the same for the entire session that it should be the same order that is loaded.

    Why do you finalize the order your self? Why not use the build in stuff for Tea Commerce to handle this? What payment gateway do you use?

    Kind regards
    Anders

  • Anders Burla 2560 posts 8256 karma points
    Nov 19, 2013 @ 17:32
    Anders Burla
    0

    What might happen as well is that the order is in state 1 in one cache and in state 2 in another case. But if its finalized in state 1 then all info from state 2 will be missing. How would you normally work with caching spread on different serverers?

    Kind regards
    Anders

  • Alexey Badyl 33 posts 205 karma points
    Nov 19, 2013 @ 19:43
    Alexey Badyl
    0

    Hi, Thanks for fast response.

    We are finalize order, because we did't use default payment providers. We are using Buckaroo Payment service, so we just send all data via HTTP POST, then Bucaroo responsible for payment via Visa, iDeal, Paypal. So when payment are done, Buckaroo call our confirmation page. As soon it called we load order via TC.GetOrder, cange status to 'completed' and finalize it. After it is finalized we add some technical infomation into properties and save it via Order.Save.

    It is work stable with one server, but work strange with multiply. 

    Also we set "use cookies" as true. So, order id is stored in cookies.

    About cache - Umbraco have distributedcall settings under umbracosetting.config. So  after publich umbraco clear cache automatically at all servers.

    Can you explain more detailed what you mean by state 1 and state 2?

    I expect that after I call TC.AddOrUpdateOrderProperties  properties will be added into database. So after all data should be available at other servers.

    Maybe enstead of using TC.GetOrder we should use OrderRepository.Get?

    I found that when Order.Save happen, TeaCommerce first delete all properties of order and then create it again. And on our redaction server by some reason order comes without properties => after save properties will be deleted and NOT added again.

    Any ideas how to solve this issue? When TC renew cache? Will be order added to a cache in one server if they was created at second server?

    Thanks.

     

  • Anders Burla 2560 posts 8256 karma points
    Nov 21, 2013 @ 10:44
    Anders Burla
    0

    Yes Umbraco has that functionality of clearing cache on different server - but it is not programmed into Tea Commerce - so it wont work automatic just because Umbraco has the setting :)

    If you use the Order repository then you will get the order from DB and the order will never be cached.

    TC only renews cache when the application pool is recycled so when an order is added to the cache it lives there for 10 min until it is killed from cache - using a sliding window.

  • Alexey Badyl 33 posts 205 karma points
    Nov 21, 2013 @ 11:52
    Alexey Badyl
    0

    You was correct. Both serves have different state (cached objects) for the same order. This is why at one server it was with properties, but not at second. And after Save at second server properties was removed and NOT added.

    To solve this issue we will to the following.

    1. Sometimes will use OrderRepository to direct access to Order in DB
    2. Will redirect all shoping process to one server
    3. Will try to override cache using possibilities of IoC.

    Can I override logic of ICacheService like it done for Shipping calculator? http://documentation.teacommerce.net/net-api/override-default-providers/

    If yes, then I think we can implemend destributed cached for it.

     

    Thanks for help.

  • Anders Burla 2560 posts 8256 karma points
    Nov 21, 2013 @ 14:36
    Anders Burla
    0

    Yes you can override anything in Tea Commerce - we are using AutoFac. So you can just override it.

  • Alexey Badyl 33 posts 205 karma points
    Nov 21, 2013 @ 22:33
    Alexey Badyl
    100

    Thanks. Finaly we desided  that more easy will be allow only to one server process all POST from TC. 

    So pages where adding to cart happen we show only from one server like shop.mysite.com

    All frow of TC was moved to one server just via link management. Usual pages we load via mysite.com(load balancer), other where functionality of TC presend via shop.myserver.com (direct access to server - NOT via Load balancer)


Please Sign in or register to post replies

Write your reply to:

Draft