none
Logging + Caching (EntLib 5

    Soru

  • Hi all,

    I’m using Logging + Caching (EntLib 5) in an ASP.NET application in the customer and I’ve some dobuts:
    1. What is the best way to make Logging Asynchronous? I know the best way is MSMQ + MsmqDistributor Service + WCF with MSMQ Integration, but, Any other way easy an simple without to install MSMQ and Service?. In my application, traces will be disabled all the times except for the error level. Only after an error is detected the customer will be enable them in Verbose mode in order to located the incident more easily and quick.
    I’m thinking to use “Task.Factory.StartNew(() => WriteMyMessage(logEntry));  ”  What do you think ?

    2. The other question is about connection time out and when SQL Server is down. In this situation, What is the best way to implement a retry policy mainly for Caching between postbacks in ASP.NET pages? Any idea about how implement a quick check the status connection ?

    Thanks so much in advance

    Regards
    Juanlu


    JuanLu, elGuerre

    01 Mart 2012 Perşembe 21:59

Yanıtlar

  • Hi again Mike,

    Finally, I think the best way to implement this mechanism is using a Cookie with an expiration about 10min.

    1. When a  timeout  ocurred in the Data Access, this retry is stored in a cookie.
    2. After second timeout cookie stores one more retry, and so until a max number of retries, ie: 3, no more I think.
    3. When the cookie expires will be posible to Access to the cache (SQL) in order to check again. If it not posible start the loop again.

    What do you think?

    Regards and thanks so much


    JuanLu, elGuerre

    22 Mart 2012 Perşembe 09:17

Tüm Yanıtlar

  • Hi JuanLu,

    Welcome to the MSDN.

    1. Personally, my suggestion is still MSMQ. But you can also try your way if your application is so simple. For a simple project, your way is very concise.

    2. This article should be helpful to your "retry policy" issue: http://msdn.microsoft.com/en-us/library/ms365783.aspx 

    For a TCP/IP connection, if the client is running Microsoft Windows XP or later, when both partner names are in the cache, the data access provider adheres to a connection retry algorithm. This is true both for making the initial connection to the session and for reconnecting after losing an established connection. Once a connection has been opened, completing the pre-login and login steps takes additional time. 

    >>Any idea about how implement a quick check the status connection ?

    About this issue, my suggestion is, making a flag in your application, when your last sql operation is successful, set it to available, if there is no sql operations during a specific time later, set it to off-line. You may say this is not the exactly connection status. And yes, it is not, but it can be a approximation, and you don't need to connect the real database. If you still insist on the real status, in my opinion, you have to connect to the DB again.

    I hope this will be helpful.

    Best regards,


    Mike Feng
    MSDN Community Support | Feedback to us
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    05 Mart 2012 Pazartesi 10:17
  • Hi Mike,

    As you know the flag idea is a good idea but it's more complicated doubt ASP.NET page life cycle and I should store connection status in Session object or Applicatioin object. Could I do than with a property, exposed by the component? ASP.NET page in a Load_Page event check connection according to the "Connection String" and if its status is Alive, then, the component works in "Online mode" but, in another case the component works in "Offline" mode. Make it sense?

    But, what can I do if the Session mode is "SQL Sever" ?

    Thanks again
    Best Regads
    @JuanluElGuerre


    JuanLu, elGuerre

    06 Mart 2012 Salı 14:35
  • Hi Juanlu,

    >>if its status is Alive, then, the component works in "Online mode" but, in another case the component works in "Offline" mode. Make it sense? 

    Yes, it does.

    >>what can I do if the Session mode is "SQL Sever" ?

    Based on my understanding, you need to store the state in other place, like in View.  And I suggest you try it on asp.net forum, too. 

    Best regards,


    Mike Feng
    MSDN Community Support | Feedback to us
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    07 Mart 2012 Çarşamba 05:35
  • Hi Juanlu,

    I don't hear from you a couple of days.

    How about your issue now?

    Do you have any update?

    Best regards,


    Mike Feng
    MSDN Community Support | Feedback to us
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    14 Mart 2012 Çarşamba 09:19
  • Hi Mike and Sorry,

    Your answer is OK and I understand It very well, however, I need to save my state inside de View State, but probably the best place could be Session, or another mechanism in ordere to treat connection estate more time, event between pages. Cound be an HttpHandler?

    Thanks one more time

    Regards

    Juanlu


    JuanLu, elGuerre

    14 Mart 2012 Çarşamba 15:24
  • Hi Juanlu,

    Here is an documentation about ASP .net states: http://msdn.microsoft.com/en-us/library/75x4ha6s.aspx 

    You can find, every state has its role, so I wouldn't say session is a best place or not.

    You have said you set the session mode to "sql server", that is why I suggest you to store the state in the view state. 

    HttpHandler is also a way to achieve this goal. It is worth to try.

    For more discussion, you can also turn to asp.net forum: http://forums.asp.net  

    Thank you for your understanding and support.

    Best regards,


    Mike Feng
    MSDN Community Support | Feedback to us
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    15 Mart 2012 Perşembe 02:49
  • Hi JuanLu,

    I don't hear from you a couple of days.

    How about your issue now?

    Do you have any update?

    If you have any concerns, please feel free to follow up.

    Best regards,


    Mike Feng
    MSDN Community Support | Feedback to us
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    20 Mart 2012 Salı 06:28
  • Hi again Mike,

    Finally, I think the best way to implement this mechanism is using a Cookie with an expiration about 10min.

    1. When a  timeout  ocurred in the Data Access, this retry is stored in a cookie.
    2. After second timeout cookie stores one more retry, and so until a max number of retries, ie: 3, no more I think.
    3. When the cookie expires will be posible to Access to the cache (SQL) in order to check again. If it not posible start the loop again.

    What do you think?

    Regards and thanks so much


    JuanLu, elGuerre

    22 Mart 2012 Perşembe 09:17
  • Hi JuanLu,

    It is fine, I think.

    Congratulations.

    Best regards,


    Mike Feng
    MSDN Community Support | Feedback to us
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    23 Mart 2012 Cuma 01:55