2

アーリーバウンドを使用してXRM2011を使用するMVC3WebAppを作成しています。これは、DynamicsIISとは別のマシンでホストされるインターネット向けアプリケーションです。

もちろん、これにより、OrganizationServiceProxyが非常に頻繁に呼び出され、最初のヒットごとに応答が遅くなります。

毎回新しいインスタンスを作成するのではなく、OrganizationServiceProxy接続を再利用することをお勧めしますか?

そうであれば、

  1. 次のような接続を管理するものはありますか
    • 接続プールアプリ-MSまたはサードパーティ/オープンソース
    • またはWCFのようなフレームワーク(まだWCFを使用したことはありません)
  2. 接続を管理するために独自のコードを作成する必要がある場合、どのデザインパターンが推奨されますか?

MSのウェブサイトからの重複した投稿でごめんなさい。うまくいけば、このフォーラムはもっと活発です。

4

3 に答える 3

2

数回のテストサイクルの後、CrmConectionを使用するのが最速の方法であることがわかりました。上記のキャッシング実装と比較して、CrmConnectionは少なくとも5倍高速に実行されます。

CrmConnection connection = new CrmConnection("XrmConnectionString");   // Todo: Replace magic connection string
using (XrmVRC.XrmVrcServiceContext context = new XrmVRC.XrmVrcServiceContext(connection)) {
    // Processing...
}
于 2011-07-07T04:33:59.967 に答える
1

これはかなり古い質問ですが、まだ探している人は、Microsoft DynamicsCRM2011およびMicrosoftDynamicsCRMOnline用のこのSDK拡張機能を読んでください。拡張機能がリソースのキャッシュ/プーリングを処理してくれると思います。

OPの元の質問の解決策については、ここここを参照してください。以下は、上記のリンク先のCRMSDKドキュメントからの引用です。

Microsoft DynamicsCRMのDeveloperExtensionsは、次の機能を提供します。

  • CrmConnectionクラス(Microsoft.Xrm.Client)によって提供されるMicrosoftDynamicsCRMサーバーへの簡略化された接続

  • コード生成ツール(CrmSvcUtil.exe)のカスタマイズによって提供される強力な型のコード生成

  • CrmConfigurationManagerクラス(Microsoft.Xrm.Client)によって提供されるカスタム拡張機能を有効にするためのApp.configおよびWeb.configの構成可能性

  • CachedOrganizationServiceクラス(Microsoft.Xrm.Client)によって提供されるサービス結果のキャッシュによるパフォーマンスの向上

ポータル開発者ガイドを使用すると、MicrosoftDynamicsCRMと緊密に統合されたWebポータルを構築できます。詳細については、Microsoft DynamicsCRM2011およびMicrosoftDynamicsCRMOnlineのポータル開発者ガイドを参照してください。このガイドは、次の機能を証明します。

  • セキュリティ管理(Microsoft.Xrm.Portal)

  • キャッシュ管理(Microsoft.Xrm.Portal)

  • コンテンツ管理(Microsoft.Xrm.Portal、Microsoft.Xrm.Portal.Files、WebSiteCopy.exe)

于 2012-05-09T07:51:55.020 に答える
0

また、この質問をMSフォーラムに投稿し、Patからの返信を受け取りました。

While it is somewhat limited, there is some direction regarding the caching of service connectivity in the SDK:

Performance Best Practises - Caching

The two primary suggestions being to:

    1. Cache the IServiceConfiguration class
    2. Monitor your WCF security token and refresh it before it expires 

そのアドバイスに基づいて、APIサンプルコードの次のクラスを使用することになりました。誰かがこれについてフィードバックまたは正しい/間違った/より良いアドバイスを持っているかどうか私に知らせてください。

AppPoolの管理に関する限り、私はまだ情報を探しています。


1. ManagedTokenOrganizationServiceProxy
2. AutoRefreshSecurityToken
3. DeviceIdManager

次の接続文字列をweb.configに追加しました

<add name="XrmConnectionString" connectionString="ServiceUri=http://<MACHINE>:<PORTt>/<ORG>/XRMServices/2011/Organization.svc; Domain=<DOMAIN>; Username=<USERNAME>; Password=<PASSWORD>" />

次に、接続を作成するために次のクラスを作成しました。

/// <summary>Provides server connection information.</summary>
public class ServerConnection
{
    private static readonly ILog log = LogManager.GetLogger(typeof(ServerConnection));

    #region Public methods
    /// <summary>
    /// Obtains the OrganizationServiceProxy connection for the target organization's
    /// Uri and user login credentials from theconfiguration.
    /// </summary>
    public static OrganizationServiceProxy getServiceProxy() {
        ManagedTokenOrganizationServiceProxy serviceProxy = null;
        log.Debug("in getServiceProxy");
        try {
            CrmConnection crmConnection = new CrmConnection("XrmConnectionString");
            serviceProxy = new ManagedTokenOrganizationServiceProxy(crmConnection.ServiceUri, crmConnection.ClientCredentials);
            log.Debug("ManagedTokenOrganizationServiceProxy created = " + serviceProxy);
            serviceProxy.EnableProxyTypes();
        } catch (Exception e) {
            log.Fatal(e, e);
            throw;
        }
        log.Debug("Returning serviceProxy");
        return serviceProxy;
    }

    #endregion
}

次のMVCコードは接続を消費します:

public ActionResult Index() {
    XrmVrcServiceContext context = null;
    try {
        context = new XrmVrcServiceContext(ServerConnection.getServiceProxy());
    } catch (Exception e) {
        log.Error(e, e);
        throw;
    }
    return View(context.new_XYZEntitySet.ToList());
}
于 2011-06-24T14:28:52.070 に答える