複数のシステムからデータを受信し、データベースに追加し、最新の受信データで別のアプリケーション(クライアント)を更新するサーバーがあります。このクライアント(両方とも同じコンピュータで実行)は、データを組織化された形式で提示し、その上で何らかの処理を行います。さらに、サーバーを使用してデータベース内の照会を実行することもできます。したがって、サーバーの機能を使用して履歴データを取得します。WCFサービスでの自動再接続
<system.serviceModel>
<bindings>
<netTcpBinding>
<binding name="NetTcpBinding_IService" closeTimeout="00:02:00" openTimeout="00:02:00" receiveTimeout="00:10:00" sendTimeout="00:02:00" transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions" hostNameComparisonMode="StrongWildcard" listenBacklog="10" maxConnections="10" maxBufferSize="2147483647" maxBufferPoolSize="2147483647">
<reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false"/>
<security mode="Transport">
<transport clientCredentialType="Windows" protectionLevel="EncryptAndSign"/>
<message clientCredentialType="Windows"/>
</security>
</binding>
</netTcpBinding>
</bindings>
<client>
<endpoint address="net.tcp://localhost:5050/msservice" binding="netTcpBinding" bindingConfiguration="NetTcpBinding_IService" contract="Server.IService" name="NetTcpBinding_IService">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
</client>
</system.serviceModel>
は、クライアントが作成されます。
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service name="ServiceName">
<endpoint binding="netTcpBinding" contract="IServiceName">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange"/>
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:5050/msservice"/>
</baseAddresses>
</host>
</service>
</services>
</system.serviceModel>
クライアントは、以下の構成が使用しています:.configファイルに次のように私は、WCFを使用しています。この通信、およびサーバーの場合
が宣言されていますサービス(サーバーに接続)では、Subscribeと呼ばれるサービス機能を使用します。これには、サーバーに接続されたクライアントのリストにクライアントが含まれます。新しいデータが到着すると、すべてのクライアントでイベントが発生します。しかし、クライアントが何らかの非アクティブになった場合(非常に高い頻度でその逆が発生しても、定期的にサーバーにメッセージを送信しないため)、フォールト状態になります。これが発生すると、サーバー関数のすべてのクライアント呼び出しは例外を発生させます。
私は、クライアントがクライアントからメッセージを受信することを保証するために、チャネルがダウンすると自動的に再接続し、クライアントからの関数呼び出しはサーバ。
ありがとうございました!