DefaultPropertiesToSend クラス
アセンブリ: System.Messaging (system.messaging.dll 内)


MessageQueue に送信されるメッセージ用に選択されるプロパティの既定値を設定できます。DefaultPropertiesToSend は、Message インスタンス以外のオブジェクトがキューに送信されるときに、送信されるメッセージのプロパティの既定値を指定するために使用されます。たとえば、コード片 myMessageQueue.Send("hello") で Send メソッドに渡される文字列引数などです。Message クラスには、DefaultPropertiesToSend 内のプロパティに対応する同じ名前のプロパティがあります。前者のプロパティは Message インスタンスを送信するときに値を提供します。キューの MessageQueue.DefaultPropertiesToSend を指定していても、そのキューに Message オブジェクトを送信すると、キューの DefaultPropertiesToSend の値は、同じ名前の Message プロパティの値によってオーバーライドされます。
明示的に設定しないプロパティは、コントラクタ DefaultPropertiesToSend によって指定される既定値に設定されます。
DefaultPropertiesToSend のインスタンスの初期プロパティ値の一覧については、DefaultPropertiesToSend コンストラクタのトピックを参照してください。

メッセージの優先順位を使用して、メッセージを送信するときの既定のプロパティを決定するコード例を次に示します。
Imports System Imports System.Messaging Public Class MyNewQueue ' Provides an entry point into the application. ' ' This example specifies different types of default ' properties for messages. Public Shared Sub Main() ' Create a new instance of the class. Dim myNewQueue As New MyNewQueue() ' Send normal and high priority messages. myNewQueue.SendNormalPriorityMessages() myNewQueue.SendHighPriorityMessages() Return End Sub 'Main ' Associates selected message property values ' with high priority messages. Public Sub SendHighPriorityMessages() ' Connect to a message queue. Dim myQueue As New MessageQueue(".\myQueue") ' Associate selected default property values with high ' priority messages. myQueue.DefaultPropertiesToSend.Priority = _ MessagePriority.High myQueue.DefaultPropertiesToSend.Label = _ "High Priority Message" myQueue.DefaultPropertiesToSend.Recoverable = True myQueue.DefaultPropertiesToSend.TimeToReachQueue = _ New TimeSpan(0, 0, 30) ' Send messages using these defaults. myQueue.Send("High priority message data 1.") myQueue.Send("High priority message data 2.") myQueue.Send("High priority message data 3.") Return End Sub 'SendHighPriorityMessages ' Associates selected message property values ' with normal priority messages. Public Sub SendNormalPriorityMessages() ' Connect to a message queue. Dim myQueue As New MessageQueue(".\myQueue") ' Associate selected default property values with normal ' priority messages. myQueue.DefaultPropertiesToSend.Priority = _ MessagePriority.Normal myQueue.DefaultPropertiesToSend.Label = _ "Normal Priority Message" myQueue.DefaultPropertiesToSend.Recoverable = False myQueue.DefaultPropertiesToSend.TimeToReachQueue = _ New TimeSpan(0, 2, 0) ' Send messages using these defaults. myQueue.Send("Normal priority message data 1.") myQueue.Send("Normal priority message data 2.") myQueue.Send("Normal priority message data 3.") Return End Sub 'SendNormalPriorityMessages End Class 'MyNewQueue
using System; using System.Messaging; namespace MyProject { /// <summary> /// Provides a container class for the example. /// </summary> public class MyNewQueue { //************************************************** // Provides an entry point into the application. // // This example specifies different types of default // properties for messages. //************************************************** public static void Main() { // Create a new instance of the class. MyNewQueue myNewQueue = new MyNewQueue(); // Send normal and high priority messages. myNewQueue.SendNormalPriorityMessages(); myNewQueue.SendHighPriorityMessages(); return; } //************************************************** // Associates selected message property values // with high priority messages. //************************************************** public void SendHighPriorityMessages() { // Connect to a message queue. MessageQueue myQueue = new MessageQueue(".\\myQueue"); // Associate selected default property values with high // priority messages. myQueue.DefaultPropertiesToSend.Priority = MessagePriority.High; myQueue.DefaultPropertiesToSend.Label = "High Priority Message"; myQueue.DefaultPropertiesToSend.Recoverable = true; myQueue.DefaultPropertiesToSend.TimeToReachQueue = new TimeSpan(0,0,30); // Send messages using these defaults. myQueue.Send("High priority message data 1."); myQueue.Send("High priority message data 2."); myQueue.Send("High priority message data 3."); return; } //************************************************** // Associates selected message property values // with normal priority messages. //************************************************** public void SendNormalPriorityMessages() { // Connect to a message queue. MessageQueue myQueue = new MessageQueue(".\\myQueue"); // Associate selected default property values with normal // priority messages. myQueue.DefaultPropertiesToSend.Priority = MessagePriority.Normal; myQueue.DefaultPropertiesToSend.Label = "Normal Priority Message"; myQueue.DefaultPropertiesToSend.Recoverable = false; myQueue.DefaultPropertiesToSend.TimeToReachQueue = new TimeSpan(0,2,0); // Send messages using these defaults. myQueue.Send("Normal priority message data 1."); myQueue.Send("Normal priority message data 2."); myQueue.Send("Normal priority message data 3."); return; } } }
#using <system.dll> #using <system.messaging.dll> using namespace System; using namespace System::Messaging; ref class MyNewQueue { public: // Associates selected message property values // with high priority messages. void SendHighPriorityMessages() { // Connect to a message queue. MessageQueue^ myQueue = gcnew MessageQueue( ".\\myQueue" ); // Associate selected default property values with high // priority messages. myQueue->DefaultPropertiesToSend->Priority = MessagePriority::High; myQueue->DefaultPropertiesToSend->Label = "High Priority Message"; myQueue->DefaultPropertiesToSend->Recoverable = true; myQueue->DefaultPropertiesToSend->TimeToReachQueue = TimeSpan(0,0,30); // Send messages using these defaults. myQueue->Send( "High priority message data 1." ); myQueue->Send( "High priority message data 2." ); myQueue->Send( "High priority message data 3." ); return; } // Associates selected message property values // with normal priority messages. void SendNormalPriorityMessages() { // Connect to a message queue. MessageQueue^ myQueue = gcnew MessageQueue( ".\\myQueue" ); // Associate selected default property values with normal // priority messages. myQueue->DefaultPropertiesToSend->Priority = MessagePriority::Normal; myQueue->DefaultPropertiesToSend->Label = "Normal Priority Message"; myQueue->DefaultPropertiesToSend->Recoverable = false; myQueue->DefaultPropertiesToSend->TimeToReachQueue = TimeSpan(0,2,0); // Send messages using these defaults. myQueue->Send( "Normal priority message data 1." ); myQueue->Send( "Normal priority message data 2." ); myQueue->Send( "Normal priority message data 3." ); return; } }; // Provides an entry point into the application. // This example specifies different types of default // properties for messages. int main() { // Create a new instance of the class. MyNewQueue^ myNewQueue = gcnew MyNewQueue; // Send normal and high priority messages. myNewQueue->SendNormalPriorityMessages(); myNewQueue->SendHighPriorityMessages(); return 0; }
package MyProject; import System.*; import System.Messaging.*; /// <summary> /// Provides a container class for the example. /// </summary> public class MyNewQueue { //************************************************** // Provides an entry point into the application. // // This example specifies different types of default // properties for messages. //************************************************** public static void main(String[] args) { // Create a new instance of the class. MyNewQueue myNewQueue = new MyNewQueue(); // Send normal and high priority messages. myNewQueue.SendNormalPriorityMessages(); myNewQueue.SendHighPriorityMessages(); return; } //main //************************************************** // Associates selected message property values // with high priority messages. //************************************************** public void SendHighPriorityMessages() { // Connect to a message queue. MessageQueue myQueue = new MessageQueue(".\\myQueue"); // Associate selected default property values with high // priority messages. myQueue.get_DefaultPropertiesToSend(). set_Priority(MessagePriority.High); myQueue.get_DefaultPropertiesToSend(). set_Label("High Priority Message"); myQueue.get_DefaultPropertiesToSend(). set_Recoverable(true); myQueue.get_DefaultPropertiesToSend(). set_TimeToReachQueue(new TimeSpan(0, 0, 30)); // Send messages using these defaults. myQueue.Send("High priority message data 1."); myQueue.Send("High priority message data 2."); myQueue.Send("High priority message data 3."); return; } //SendHighPriorityMessages //************************************************** // Associates selected message property values // with normal priority messages. //************************************************** public void SendNormalPriorityMessages() { // Connect to a message queue. MessageQueue myQueue = new MessageQueue(".\\myQueue"); // Associate selected default property values with normal // priority messages. myQueue.get_DefaultPropertiesToSend(). set_Priority(MessagePriority.Normal); myQueue.get_DefaultPropertiesToSend(). set_Label("Normal Priority Message"); myQueue.get_DefaultPropertiesToSend(). set_Recoverable(false); myQueue.get_DefaultPropertiesToSend(). set_TimeToReachQueue(new TimeSpan(0, 2, 0)); // Send messages using these defaults. myQueue.Send("Normal priority message data 1."); myQueue.Send("Normal priority message data 2."); myQueue.Send("Normal priority message data 3."); return; } //SendNormalPriorityMessages } //MyNewQueue

System.Messaging.DefaultPropertiesToSend


Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


DefaultPropertiesToSend コンストラクタ
アセンブリ: System.Messaging (system.messaging.dll 内)


DefaultPropertiesToSend の新しいインスタンスを作成することで、キューに送信される Message 型以外のオブジェクトに関連付けるプロパティの既定値を定義できます。MessageQueue オブジェクトを使うときには、DefaultPropertiesToSend インスタンスが作成され、MessageQueue の MessageQueue.DefaultPropertiesToSend メンバに関連付けられます。
オブジェクトを送信するキューのプロパティの既定値を定義する方法は、次の C# のコードに示ように 2 とおりあります。1 つ目の方法として、DefaultPropertiesToSend のインスタンスの値を設定し、それをキューの MessageQueue.DefaultPropertiesToSend プロパティに関連付けることができます。
DefaultPropertiesToSend myDefaultProperties = new DefaultPropertiesToSend(); // Set default values for the properties. myDefaultProperties.Label = "myLabel"; myDefaultProperties.Recoverable = false; ... myMessageQueue.DefaultPropertiesToSend = myDefaultProperties; myMessageQueue.Send("hello");
もう 1 つの方法として、MessageQueue インスタンスの DefaultPropertiesToSend プロパティに値を個別に直接割り当てることもできます。
myMessageQueue.DefaultPropertiesToSend.Label = "myLabel"; myMessageQueue.DefaultPropertiesToSend.Recoverable = false; ... myMessageQueue.Send("hello");
2 つ目の方法を使う場合は、DefaultPropertiesToSend コンストラクタを明示的に呼び出す必要はありません。DefaultPropertiesToSend のインスタンスを作成する必要がある場合があります。たとえば、送信するメッセージの条件に応じてプロパティの既定値が変化する場合です。このような場合は、複数の DefaultPropertiesToSend インスタンスを作成して、キューにメッセージを送信する前に、キューの MessageQueue.DefaultPropertiesToSend プロパティにインスタンスの 1 つを割り当てることができます。
DefaultPropertiesToSend のインスタンスの初期プロパティ値を次の表に示します。
AcknowledgeType | AcknowledgeTypes.None |
AdministrationQueue | null 参照 (Visual Basic では Nothing) |
AppSpecific | 0 |
AttachSenderId | |
EncryptionAlgorithm | EncryptionAlgorithm.RC2 |
HashAlgorithm | HashAlgorithm.MD5 |
空の文字列 ("")。 | |
MessagePriority.Normal | |
Recoverable | |
ResponseQueue | null 参照 (Visual Basic では Nothing) |
TimeToBeReceived | Message.InfiniteTimeout |
TimeToReachQueue | Message.InfiniteTimeout |
TransactionStatusQueue | null 参照 (Visual Basic では Nothing) |
UseAuthentication | |
UseDeadLetterQueue | |
UseEncryption | |
UseJournalQueue | |
UseTracing |


Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


DefaultPropertiesToSend プロパティ
DefaultPropertiesToSend メソッド

名前 | 説明 | |
---|---|---|
![]() | Equals | オーバーロードされます。 2 つの Object インスタンスが等しいかどうかを判断します。 ( Object から継承されます。) |
![]() | GetHashCode | 特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用に適しています。 ( Object から継承されます。) |
![]() | GetType | 現在のインスタンスの Type を取得します。 ( Object から継承されます。) |
![]() | ReferenceEquals | 指定した複数の Object インスタンスが同一かどうかを判断します。 ( Object から継承されます。) |
![]() | ToString | 現在の Object を表す String を返します。 ( Object から継承されます。) |

名前 | 説明 | |
---|---|---|
![]() | Finalize | Object がガベージ コレクションにより収集される前に、その Object がリソースを解放し、その他のクリーンアップ操作を実行できるようにします。 ( Object から継承されます。) |
![]() | MemberwiseClone | 現在の Object の簡易コピーを作成します。 ( Object から継承されます。) |

DefaultPropertiesToSend メンバ
Message インスタンス以外のオブジェクトをメッセージ キューに送信するときに使われるプロパティの既定値を指定します。
DefaultPropertiesToSend データ型で公開されるメンバを以下の表に示します。



名前 | 説明 | |
---|---|---|
![]() | Equals | オーバーロードされます。 2 つの Object インスタンスが等しいかどうかを判断します。 (Object から継承されます。) |
![]() | GetHashCode | 特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用に適しています。 (Object から継承されます。) |
![]() | GetType | 現在のインスタンスの Type を取得します。 (Object から継承されます。) |
![]() | ReferenceEquals | 指定した複数の Object インスタンスが同一かどうかを判断します。 (Object から継承されます。) |
![]() | ToString | 現在の Object を表す String を返します。 (Object から継承されます。) |

名前 | 説明 | |
---|---|---|
![]() | Finalize | Object がガベージ コレクションにより収集される前に、その Object がリソースを解放し、その他のクリーンアップ操作を実行できるようにします。 (Object から継承されます。) |
![]() | MemberwiseClone | 現在の Object の簡易コピーを作成します。 (Object から継承されます。) |

- DefaultPropertiesToSendのページへのリンク