次の方法で共有


MessageQueue.DefaultPropertiesToSend プロパティ

アプリケーションがメッセージをキューに送信するときに既定で使用されるメッセージ プロパティ値を取得または設定します。

Public Property DefaultPropertiesToSend As DefaultPropertiesToSend
[C#]
public DefaultPropertiesToSend DefaultPropertiesToSend {get; set;}
[C++]
public: __property DefaultPropertiesToSend* get_DefaultPropertiesToSend();public: __property void set_DefaultPropertiesToSend(DefaultPropertiesToSend*);
[JScript]
public function get DefaultPropertiesToSend() : DefaultPropertiesToSend;public function set DefaultPropertiesToSend(DefaultPropertiesToSend);

プロパティ値

アプリケーションが Message インスタンス以外のオブジェクトをキューに送信するときに使用する既定のメッセージ キューメッセージ プロパティ値を含む DefaultPropertiesToSend

例外

例外の種類 条件
ArgumentException 既定のプロパティをキューに設定できませんでした。いずれかのプロパティが無効である可能性があります。

解説

型が Message ではないオブジェクトをキューに送信する場合、 MessageQueue はそのオブジェクトをメッセージ キューのメッセージに挿入します。そのときに、 DefaultPropertiesToSend プロパティで指定したプロパティ値が MessageQueue によってメッセージに適用されます。これに対して、 Message をキューに送信する場合、これらのプロパティは既にインスタンスそのものに指定されているため、 Message では DefaultPropertiesToSend は無視されます。

プロパティは MessageQueue オブジェクトで設定しますが、 DefaultPropertiesToSend はキューそのものではなく、キューに送信されるメッセージのプロパティを参照します。

プロパティの既定値を次の表に示します。

プロパティ 既定値
AcknowledgeType AcknowledgeType.None.
AdministrationQueue null 参照 (Visual Basic では Nothing).
AppSpecific 0。
AttachSenderId true.
EncryptionAlgorithm EncryptionAlgorithm.RC2.
Extension 長さ 0 のバイト配列。
HashAlgorithm HashAlgorithm.MD5.
Label 空の文字列 ("")。
Priority MessagePriority.Normal.
Recoverable false.
ResponseQueue null 参照 (Nothing).
TimeToBeReceived Message.InfiniteTimeout.
TimeToReachQueue Message.InfiniteTimeout.
TransactionStatusQueue null 参照 (Nothing).
UseAuthentication false.
UseDeadLetterQueue false.
UseEncryption false.
UseJournalQueue false.
UseTracing false.

このプロパティが各種のワークグループ モードで使用できるかどうかを次の表に示します。

ワークグループ モード 使用可否
ローカル コンピュータ はい
ローカル コンピュータ + 直接書式名 はい
リモート コンピュータ はい
リモート コンピュータ + 直接書式名 はい

使用例

[Visual Basic, C#, C++] メッセージの優先順位を使用して、メッセージを送信するときの既定のプロパティを決定する例を次に示します。

 
Imports System
Imports 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 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
End Namespace 'MyProject

[C#] 
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;
        }
    }
}

[C++] 
#using <mscorlib.dll>
#using <system.dll>
#using <system.messaging.dll>

using namespace System;
using namespace System::Messaging;

__gc class MyNewQueue 
{
public:
    // Associates selected message property values
    // with high priority messages.
    void SendHighPriorityMessages() 
    {
        // Connect to a message queue.
        MessageQueue* myQueue = new MessageQueue(S".\\myQueue");

        // Associate selected default property values with high
        // priority messages.
        myQueue->DefaultPropertiesToSend->Priority = MessagePriority::High;
        myQueue->DefaultPropertiesToSend->Label = S"High Priority Message";
        myQueue->DefaultPropertiesToSend->Recoverable = true;
        myQueue->DefaultPropertiesToSend->TimeToReachQueue = TimeSpan(0, 0, 30);

        // Send messages using these defaults.
        myQueue->Send(S"High priority message data 1.");
        myQueue->Send(S"High priority message data 2.");
        myQueue->Send(S"High priority message data 3.");

        return;
    }

    // Associates selected message property values
    // with normal priority messages.
    void SendNormalPriorityMessages() 
    {
        // Connect to a message queue.
        MessageQueue* myQueue = new MessageQueue(S".\\myQueue");

        // Associate selected default property values with normal
        // priority messages.
        myQueue->DefaultPropertiesToSend->Priority = MessagePriority::Normal;
        myQueue->DefaultPropertiesToSend->Label = S"Normal Priority Message";
        myQueue->DefaultPropertiesToSend->Recoverable = false;
        myQueue->DefaultPropertiesToSend->TimeToReachQueue = TimeSpan(0, 2, 0);

        // Send messages using these defaults.
        myQueue->Send(S"Normal priority message data 1.");
        myQueue->Send(S"Normal priority message data 2.");
        myQueue->Send(S"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 = new MyNewQueue();

    // Send normal and high priority messages.
    myNewQueue->SendNormalPriorityMessages();
    myNewQueue->SendHighPriorityMessages();

    return 0;
}

[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン 言語のフィルタ をクリックします。

必要条件

プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ

.NET Framework セキュリティ:

参照

MessageQueue クラス | MessageQueue メンバ | System.Messaging 名前空間 | Message | AcknowledgeTypes | EncryptionAlgorithm | HashAlgorithm | InfiniteTimeout