English 中文(简体)
WCF 用户轴心、客户/伙伴关系中的Channel Caching。 净额——法典审查
原标题:WCF Client Proxies, Client/Channel Caching in ASP.Net - Code Review

长期伙伴关系。 要求网络接口开发商学习世界文化基金,在更多与结构相关的方面寻找一些教育,因为这个平台不是我的强项,而是我必须处理的。

在我们目前的ASMX世界中,我们采用了一种模式,为我们与网络服务的互动创建服务管理阶层的固定班级。 我们重新开始移徙到妇联,试图遵循同样的模式。 首先,我处理业绩问题,但我敲响了一点,现在我们顺利运作,但我对我的策略表示怀疑。 这里简要地介绍一下我们做些什么(消除错误处理、砍刀、操纵物体等):

public static class ContentManager
{
    private static StoryManagerClient _clientProxy = null;
    const string _contentServiceResourceCode = "StorySvc";

    // FOR CACHING
    const int _getStoriesTTL = 300;
    private static Dictionary<string, GetStoriesCacheItem> _getStoriesCache = new Dictionary<string, GetStoriesCacheItem>();
    private static ReaderWriterLockSlim _cacheLockStories = new ReaderWriterLockSlim();

    public static Story[] GetStories(string categoryGuid)
    {
        // OMITTED - if category is cached and not expired, return from cache

        // get endpoint address from FinderClient (ResourceManagement SVC)
        UrlResource ur = FinderClient.GetUrlResource(_contentServiceResourceCode);

        // Get proxy
        StoryManagerClient svc = GetStoryServiceClient(ur.Url);

        // create request params
        GetStoriesRequest request = new GetStoriesRequest{}; // SIMPLIFIED
        Manifest manifest = new Manifest{}; // SIMPLIFIED

        // execute GetStories at WCF service
        try
        {
            GetStoriesResponse response = svc.GetStories(manifest, request);
        }
        catch (Exception)
        {
            if (svc.State == CommunicationState.Faulted)
            {
                svc.Abort();
            }

            throw;
        }

        // OMITTED - do stuff with response, cache if needed
        // return....
    }

    internal static StoryManagerClient GetStoryServiceClient(string endpointAddress)
    {
        if (_clientProxy == null)
            _clientProxy = new StoryManagerClient(GetServiceBinding(_contentServiceResourceCode), new EndpointAddress(endpointAddress));

        return _clientProxy;
    }

    public static Binding GetServiceBinding(string bindingSettingName)
    {
        // uses Finder service to load a binding object - our alternative to definition in web.config
    }

    public static void PreloadContentServiceClient()
    {
        // get finder location
        UrlResource ur = FinderClient.GetUrlResource(_contentServiceResourceCode);

        // preload proxy
        GetStoryServiceClient(ur.Url);
    }    
}

我们现在顺利运行,在100米范围内完成了三轮驱动电话。 创建“先期服务”方法,并给我们全球增添。 顺便说一句,“第一点”的性能降至同一水平。 你们可能要知道我们重新使用数据用户和“服务参考”方法。

我在静态班级、单一州、共享数据合同组、如何使用频道功能模式以及我能对我们使用模式做的其他事情的整个编织方面做了许多读。 正如我所说的那样,我们似乎进展顺利。 我知道我不见大局。 难道有人告诉我,我在这里最后谈到的是,如何引导集合、代理失败等等? 我为什么要走“海峡通车”的道路? 我的格言只是说这样做了,但我的领导人可以理解为什么......。

感谢!

最佳回答
问题回答

暂无回答




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!