DefaultPropertiesToSend 類別

定義

指定傳送 Message 執行個體 (Instance) 以外的物件至訊息佇列時將使用的預設屬性值。

public ref class DefaultPropertiesToSend
[System.ComponentModel.TypeConverter(typeof(System.ComponentModel.ExpandableObjectConverter))]
public class DefaultPropertiesToSend
[<System.ComponentModel.TypeConverter(typeof(System.ComponentModel.ExpandableObjectConverter))>]
type DefaultPropertiesToSend = class
Public Class DefaultPropertiesToSend
繼承
DefaultPropertiesToSend
屬性

範例

下列程式代碼範例會使用訊息的優先順序來判斷訊息要傳送的預設屬性。

#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;
}
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;
        }
    }
}
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



        ' 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



        ' 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

End Class

備註

您可以為傳送至 的 MessageQueue訊息設定所選屬性的預設值。 DefaultPropertiesToSend用來指定當實體以外的Message物件傳送至佇列時所傳送訊息的預設屬性值,例如,傳入Send代碼段 中 方法的字串自變數。 myMessageQueue.Send("hello") 類別 Message 的對應、具名屬性與 中 DefaultPropertiesToSend 提供特定實例時 Message 提供值的屬性相同。 即使您已指定 MessageQueue.DefaultPropertiesToSend 佇列,將對象傳送 Message 至該佇列,會導致相同具名 Message 屬性的值覆寫佇列 DefaultPropertiesToSend 的值。

您沒有明確設定的屬性預設為建構函式所指定的值。 DefaultPropertiesToSend

如需 實例 DefaultPropertiesToSend的初始屬性值清單,請參閱 建 DefaultPropertiesToSend 構函式。

建構函式

DefaultPropertiesToSend()

初始化 DefaultPropertiesToSend 類別的新執行個體。

屬性

AcknowledgeType

取得或設定要傳回至傳送的應用程式的認可訊息類型。

AdministrationQueue

取得或設定接收由訊息佇列所產生的認可訊息的佇列。

AppSpecific

取得或設定額外的應用程式特定資訊。

AttachSenderId

取得或設定值,指出是否應該將傳送者識別碼附加至訊息。

EncryptionAlgorithm

取得或設定用來加密私用訊息主體的加密演算法。

Extension

取得或設定與訊息關聯的其他資訊。

HashAlgorithm

取得或設定當驗證訊息或建立訊息的數位簽章時所使用的雜湊演算法。

Label

取得或設定描述訊息的應用程式定義字串。

Priority

取得或設定訊息的優先權,用來決定訊息放置在佇列中的位置。

Recoverable

取得或設定值,指出當發生電腦故障或網路問題時是否保證傳遞訊息。

ResponseQueue

取得或設定接收應用程式產生的回應訊息的佇列。

TimeToBeReceived

取得或設定從目的端佇列擷取訊息的時間限制。

TimeToReachQueue

取得或設定訊息到達佇列的時間限制。

TransactionStatusQueue

取得來源電腦上的異動狀態佇列。

UseAuthentication

取得或設定值,指出訊息在傳送之前是否必須通過驗證。

UseDeadLetterQueue

取得或設定值,指出是否應該將無法傳遞的訊息複本傳送至無法投遞的信件佇列。

UseEncryption

取得或設定值,指出是否將訊息設成私用。

UseJournalQueue

取得或設定值,指出訊息複本是否應保留在原始電腦上的電腦日誌中。

UseTracing

取得或設定值,指出當訊息向其目的佇列移動時是否要追蹤訊息。

方法

Equals(Object)

判斷指定的物件是否等於目前的物件。

(繼承來源 Object)
GetHashCode()

做為預設雜湊函式。

(繼承來源 Object)
GetType()

取得目前執行個體的 Type

(繼承來源 Object)
MemberwiseClone()

建立目前 Object 的淺層複製。

(繼承來源 Object)
ToString()

傳回代表目前物件的字串。

(繼承來源 Object)

適用於

另請參閱