NetMsmqBinding クラス
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
マシン間通信に適したキューに登録されたバインドを表します。
public ref class NetMsmqBinding : System::ServiceModel::MsmqBindingBase
public class NetMsmqBinding : System.ServiceModel.MsmqBindingBase
type NetMsmqBinding = class
inherit MsmqBindingBase
Public Class NetMsmqBinding
Inherits MsmqBindingBase
- 継承
例
次の例は、 NetMsmqBinding バインディングを使用するようにサービスを構成する方法を示しています。
最初に、構成ファイルを指定します。
次に、実際のサービス コードです。
// Define a service contract.
[ServiceContract(Namespace="http://Microsoft.ServiceModel.Samples")]
public interface IQueueCalculator
{
[OperationContract(IsOneWay=true)]
void Add(double n1, double n2);
[OperationContract(IsOneWay = true)]
void Subtract(double n1, double n2);
[OperationContract(IsOneWay = true)]
void Multiply(double n1, double n2);
[OperationContract(IsOneWay = true)]
void Divide(double n1, double n2);
}
' Define a service contract.
<ServiceContract(Namespace:="http://Microsoft.ServiceModel.Samples")> _
Public Interface IQueueCalculator
<OperationContract(IsOneWay:=True)> _
Sub Add(ByVal n1 As Double, ByVal n2 As Double)
<OperationContract(IsOneWay := True)> _
Sub Subtract(ByVal n1 As Double, ByVal n2 As Double)
<OperationContract(IsOneWay := True)> _
Sub Multiply(ByVal n1 As Double, ByVal n2 As Double)
<OperationContract(IsOneWay := True)> _
Sub Divide(ByVal n1 As Double, ByVal n2 As Double)
End Interface
// Service class that implements the service contract.
// Added code to write output to the console window
public class CalculatorService : IQueueCalculator
{
[OperationBehavior]
public void Add(double n1, double n2)
{
double result = n1 + n2;
Console.WriteLine("Received Add({0},{1}) - result: {2}", n1, n2, result);
}
[OperationBehavior]
public void Subtract(double n1, double n2)
{
double result = n1 - n2;
Console.WriteLine("Received Subtract({0},{1}) - result: {2}", n1, n2, result);
}
[OperationBehavior]
public void Multiply(double n1, double n2)
{
double result = n1 * n2;
Console.WriteLine("Received Multiply({0},{1}) - result: {2}", n1, n2, result);
}
[OperationBehavior]
public void Divide(double n1, double n2)
{
double result = n1 / n2;
Console.WriteLine("Received Divide({0},{1}) - result: {2}", n1, n2, result);
}
}
' Service class that implements the service contract.
' Added code to write output to the console window
Public Class CalculatorService
Implements IQueueCalculator
<OperationBehavior> _
Public Sub Add(ByVal n1 As Double, ByVal n2 As Double) Implements IQueueCalculator.Add
Dim result As Double = n1 + n2
Console.WriteLine("Received Add({0},{1}) - result: {2}", n1, n2, result)
End Sub
<OperationBehavior> _
Public Sub Subtract(ByVal n1 As Double, ByVal n2 As Double) Implements IQueueCalculator.Subtract
Dim result As Double = n1 - n2
Console.WriteLine("Received Subtract({0},{1}) - result: {2}", n1, n2, result)
End Sub
<OperationBehavior> _
Public Sub Multiply(ByVal n1 As Double, ByVal n2 As Double) Implements IQueueCalculator.Multiply
Dim result As Double = n1 * n2
Console.WriteLine("Received Multiply({0},{1}) - result: {2}", n1, n2, result)
End Sub
<OperationBehavior> _
Public Sub Divide(ByVal n1 As Double, ByVal n2 As Double) Implements IQueueCalculator.Divide
Dim result As Double = n1 / n2
Console.WriteLine("Received Divide({0},{1}) - result: {2}", n1, n2, result)
End Sub
End Class
// This is the hosting application. This code can appear directly in the service class as well.
class HostApp
{
// Host the service within this EXE console application.
public static void Main()
{
// Get MSMQ queue name from appsettings in configuration.
string queueName = ConfigurationManager.AppSettings["queueName"];
// Create the transacted MSMQ queue if necessary.
if (!MessageQueue.Exists(queueName))
MessageQueue.Create(queueName, true);
// Get the base address that is used to listen for WS-MetaDataExchange requests.
// This is useful to generate a proxy for the client.
string baseAddress = ConfigurationManager.AppSettings["baseAddress"];
// Create a ServiceHost for the CalculatorService type.
using (ServiceHost serviceHost = new ServiceHost(typeof(CalculatorService), new Uri(baseAddress)))
{
// Open the ServiceHostBase to create listeners and start listening for messages.
serviceHost.Open();
// The service can now be accessed.
Console.WriteLine("The service is ready.");
Console.WriteLine("Press <ENTER> to terminate service.");
Console.WriteLine();
Console.ReadLine();
// Close the ServiceHostBase to shutdown the service.
serviceHost.Close();
}
}
}
' This is the hosting application. This code can appear directly in the service class as well.
Friend Class HostApp
' Host the service within this EXE console application.
Public Shared Sub Main()
' Get MSMQ queue name from appsettings in configuration.
Dim queueName As String = ConfigurationManager.AppSettings("queueName")
' Create the transacted MSMQ queue if necessary.
If (Not MessageQueue.Exists(queueName)) Then
MessageQueue.Create(queueName, True)
End If
' Get the base address that is used to listen for WS-MetaDataExchange requests.
' This is useful to generate a proxy for the client.
Dim baseAddress As String = ConfigurationManager.AppSettings("baseAddress")
' Create a ServiceHost for the CalculatorService type.
Using serviceHost As New ServiceHost(GetType(CalculatorService), New Uri(baseAddress))
' Open the ServiceHostBase to create listeners and start listening for messages.
serviceHost.Open()
' The service can now be accessed.
Console.WriteLine("The service is ready.")
Console.WriteLine("Press <ENTER> to terminate service.")
Console.WriteLine()
Console.ReadLine()
' Close the ServiceHostBase to shutdown the service.
serviceHost.Close()
End Using
End Sub
End Class
注釈
NetMsmqBinding バインディングは、メッセージ キュー (MSMQ) をトランスポートとして使用してキューをサポートし、疎結合アプリケーション、障害分離、負荷平準化、切断操作のサポートを可能にします。 これらの機能の詳細については、「 キューの概要」を参照してください。
これは、Windows Communication Foundation (WCF) によって提供されるシステム提供のバインディングの 1 つです。 推奨される手順は、構成値を使用してバインディングを定義し、コードベースのアプローチを使用しないようにすることです。ただし、サービスとして構成値を設定する必要がある特定の高度なシナリオを除きます。
コンストラクター
| 名前 | 説明 |
|---|---|
| NetMsmqBinding() |
NetMsmqBinding クラスの新しいインスタンスを初期化します。 |
| NetMsmqBinding(NetMsmqSecurityMode) |
指定したセキュリティ モードを使用して、 NetMsmqBinding クラスの新しいインスタンスを初期化します。 |
| NetMsmqBinding(String) |
指定した構成バインド要素の設定から、 NetMsmqBinding クラスの新しいインスタンスを初期化します。 |
プロパティ
| 名前 | 説明 |
|---|---|
| CloseTimeout |
トランスポートが例外を発生させる前に、接続が閉じるまでに指定された時間の間隔を取得または設定します。 (継承元 Binding) |
| CustomDeadLetterQueue |
有効期限が切れている、または転送または配信に失敗したメッセージが配置される、各アプリケーションの配信不能キューの場所を含む URI を取得または設定します。 (継承元 MsmqBindingBase) |
| DeadLetterQueue |
使用する配信不能キューの種類を示す列挙値を取得または設定します。 (継承元 MsmqBindingBase) |
| Durable |
このバインディングによって処理されるメッセージが永続的か揮発性かを示す値を取得または設定します。 (継承元 MsmqBindingBase) |
| EnvelopeVersion |
このバインディングによって処理されるメッセージに使用される SOAP のバージョンを取得します。 |
| ExactlyOnce |
このバインディングによって処理されたメッセージを 1 回だけ受信するかどうかを示す値を取得または設定します。 (継承元 MsmqBindingBase) |
| MaxBufferPoolSize |
チャネルからメッセージを受信するメッセージ バッファー マネージャーによって使用するために割り当てられるメモリの最大量を取得または設定します。 |
| MaxReceivedMessageSize |
このバインディングによって処理されるメッセージの最大サイズ (バイト単位) を取得または設定します。 (継承元 MsmqBindingBase) |
| MaxRetryCycles |
受信アプリケーションへのメッセージの配信を試行する再試行サイクルの最大数を取得または設定します。 (継承元 MsmqBindingBase) |
| MessageVersion |
バインディングで構成されたクライアントとサービスによって使用されるメッセージ のバージョンを取得します。 (継承元 Binding) |
| Name |
バインディングの名前を取得または設定します。 (継承元 Binding) |
| Namespace |
バインディングの XML 名前空間を取得または設定します。 (継承元 Binding) |
| OpenTimeout |
トランスポートが例外を発生させる前に、接続を開くために指定された時間の間隔を取得または設定します。 (継承元 Binding) |
| QueueTransferProtocol |
このバインディングで使用されるキューに登録された通信チャネル トランスポートを示す列挙値を取得または設定します。 |
| ReaderQuotas |
このバインディングに関連付けられている XmlDictionaryReaderQuotas を取得または設定します。 |
| ReceiveContextEnabled |
受信コンテキストの動作が要求されるかどうかを示す値を取得または設定します。 (継承元 MsmqBindingBase) |
| ReceiveErrorHandling |
有害メッセージの処理方法を指定する列挙値を取得または設定します。 (継承元 MsmqBindingBase) |
| ReceiveRetryCount |
アプリケーション キューから読み取られたメッセージに対する即時配信試行の最大数を取得または設定します。 (継承元 MsmqBindingBase) |
| ReceiveTimeout |
接続が非アクティブのままで、アプリケーション メッセージを受信しない間に切断されるまでの時間を取得または設定します。 (継承元 Binding) |
| RetryCycleDelay |
すぐに配信できないメッセージを配信しようとしたときの再試行サイクル間の遅延時間を示す値を取得または設定します。 (継承元 MsmqBindingBase) |
| Scheme |
このバインディングのスキームを返します。 (継承元 MsmqBindingBase) |
| Security |
このバインディングに関連付けられている NetMsmqSecurity を取得または設定します。 |
| SendTimeout |
トランスポートで例外が発生するまでの書き込み操作が完了するまでの指定時間を取得または設定します。 (継承元 Binding) |
| TimeToLive |
このバインドによって処理されるメッセージがキューに格納されてから有効期限が切れるまでの期間を示す時間間隔を取得または設定します。 (継承元 MsmqBindingBase) |
| UseActiveDirectory |
Active Directory を使用してキュー アドレスを変換するかどうかを示す値を取得または設定します。 |
| UseMsmqTracing |
このバインディングによって処理されるメッセージをトレースするかどうかを示す値を取得または設定します。 (継承元 MsmqBindingBase) |
| UseSourceJournal |
このバインディングによって処理されるメッセージのコピーをソース ジャーナル キューに格納するかどうかを示す値を取得または設定します。 (継承元 MsmqBindingBase) |
| ValidityDuration |
メッセージが受信コンテキスト機能によってロックされる期間を指定する値を取得または設定します。 (継承元 MsmqBindingBase) |
メソッド
| 名前 | 説明 |
|---|---|
| BuildChannelFactory<TChannel>(BindingParameterCollection) |
指定した種類のチャネルを作成し、バインド パラメーターのコレクションで指定された機能を満たすチャネル ファクトリ スタックをクライアント上に構築します。 (継承元 Binding) |
| BuildChannelFactory<TChannel>(Object[]) |
指定した種類のチャネルを作成し、オブジェクト配列で指定された機能を満たすチャネル ファクトリ スタックをクライアント上に構築します。 (継承元 Binding) |
| BuildChannelListener<TChannel>(BindingParameterCollection) |
指定した種類のチャネルを受け入れ、バインド パラメーターのコレクションで指定された機能を満たすチャネル リスナーをサービスに構築します。 (継承元 Binding) |
| BuildChannelListener<TChannel>(Object[]) |
指定した種類のチャネルを受け入れ、指定された機能を満たすチャネル リスナーをサービスに構築します。 (継承元 Binding) |
| BuildChannelListener<TChannel>(Uri, BindingParameterCollection) |
指定した種類のチャネルを受け入れ、指定された機能を満たすチャネル リスナーをサービスに構築します。 (継承元 Binding) |
| BuildChannelListener<TChannel>(Uri, Object[]) |
指定した種類のチャネルを受け入れ、指定された機能を満たすチャネル リスナーをサービスに構築します。 (継承元 Binding) |
| BuildChannelListener<TChannel>(Uri, String, BindingParameterCollection) |
指定した種類のチャネルを受け入れ、指定された機能を満たすチャネル リスナーをサービスに構築します。 (継承元 Binding) |
| BuildChannelListener<TChannel>(Uri, String, ListenUriMode, BindingParameterCollection) |
指定した種類のチャネルを受け入れ、指定された機能を満たすチャネル リスナーをサービスに構築します。 (継承元 Binding) |
| BuildChannelListener<TChannel>(Uri, String, ListenUriMode, Object[]) |
指定した種類のチャネルを受け入れ、指定された機能を満たすチャネル リスナーをサービスに構築します。 (継承元 Binding) |
| BuildChannelListener<TChannel>(Uri, String, Object[]) |
指定した種類のチャネルを受け入れ、指定された機能を満たすチャネル リスナーをサービスに構築します。 (継承元 Binding) |
| CanBuildChannelFactory<TChannel>(BindingParameterCollection) |
現在のバインディングが、指定されたバインド パラメーターのコレクションを満たすチャネル ファクトリ スタックをクライアント上に構築できるかどうかを示す値を返します。 (継承元 Binding) |
| CanBuildChannelFactory<TChannel>(Object[]) |
現在のバインディングが、オブジェクト配列で指定された要件を満たすチャネル ファクトリ スタックをクライアント上に構築できるかどうかを示す値を返します。 (継承元 Binding) |
| CanBuildChannelListener<TChannel>(BindingParameterCollection) |
現在のバインディングが、指定されたバインド パラメーターのコレクションを満たすチャネル リスナー スタックをサービス上に構築できるかどうかを示す値を返します。 (継承元 Binding) |
| CanBuildChannelListener<TChannel>(Object[]) |
現在のバインディングが、オブジェクトの配列で指定された条件を満たすチャネル リスナー スタックをサービス上に構築できるかどうかを示す値を返します。 (継承元 Binding) |
| CreateBindingElements() |
現在のバインディングに含まれるバインド要素の順序付けられたコレクションを返します。 |
| Equals(Object) |
指定したオブジェクトが現在のオブジェクトと等しいかどうかを判断します。 (継承元 Object) |
| GetHashCode() |
既定のハッシュ関数として機能します。 (継承元 Object) |
| GetProperty<T>(BindingParameterCollection) |
バインディング スタック内の適切なレイヤーから、要求された型指定されたオブジェクト (存在する場合) を返します。 (継承元 Binding) |
| GetType() |
現在のインスタンスの Type を取得します。 (継承元 Object) |
| MemberwiseClone() |
現在の Objectの簡易コピーを作成します。 (継承元 Object) |
| ShouldSerializeName() |
バインディングの名前をシリアル化する必要があるかどうかを返します。 (継承元 Binding) |
| ShouldSerializeNamespace() |
バインディングの名前空間をシリアル化する必要があるかどうかを返します。 (継承元 Binding) |
| ShouldSerializeReaderQuotas() |
ReaderQuotas プロパティが既定値から変更され、シリアル化する必要があるかどうかを示す値を返します。 |
| ShouldSerializeSecurity() |
Security プロパティが既定値から変更され、シリアル化する必要があるかどうかを示す値を返します。 |
| ToString() |
現在のオブジェクトを表す文字列を返します。 (継承元 Object) |
明示的なインターフェイスの実装
| 名前 | 説明 |
|---|---|
| IBindingRuntimePreferences.ReceiveSynchronously |
受信要求をより効率的に同期的または非同期的に処理できるかどうかを示す値を取得します。 (継承元 MsmqBindingBase) |