DefaultPropertiesToSend DefaultPropertiesToSend DefaultPropertiesToSend DefaultPropertiesToSend Class

定義

指定傳送 Message 執行個體 (Instance) 以外的物件至訊息佇列時將使用的預設屬性值。Specifies the default property values that will be used when sending objects other than Message instances to a message queue.

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

範例

下列程式碼範例會使用訊息的優先順序來決定要為訊息傳送的預設屬性。The following code example uses the priority of a message to determine default properties to send for the message.

#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 'MyNewQueue

備註

您可以針對傳送至的MessageQueue訊息, 在選取的屬性上設定預設值。You can set default values on selected properties for messages sent to a MessageQueue. DefaultPropertiesToSend這是用來指定當Message實例以外的物件傳送至佇列時所傳送之訊息的預設屬性值, 例如, 在程式碼片段myMessageQueue.Send("hello")中傳遞Send至方法的字串引數。DefaultPropertiesToSend is used to specify default property values of the message being sent when objects other than Message instances are sent to a queue, for example, the string argument passed into the Send method in the code fragment, myMessageQueue.Send("hello"). 類別具有對應、名稱相同的屬性, 可在DefaultPropertiesToSend中提供值 (特別是傳送Message實例時)。 MessageThe Message class has corresponding, identically named properties to those in DefaultPropertiesToSend that provide the values when sending a Message instance specifically. 即使您已針對佇列MessageQueue.DefaultPropertiesToSend指定, Message將物件傳送至該佇列會導致相同名稱Message屬性的值覆寫佇列的DefaultPropertiesToSend值。Even if you have specified MessageQueue.DefaultPropertiesToSend for a queue, sending a Message object to that queue will cause the values for the identically named Message properties to override the queue's DefaultPropertiesToSend values.

您未明確設定的屬性會預設為此函數DefaultPropertiesToSend所指定的值。Properties that you do not set explicitly default to the values specified by the constructor, DefaultPropertiesToSend.

如需實例的DefaultPropertiesToSend初始屬性值清單, DefaultPropertiesToSend請參閱函數。For a list of initial property values for an instance of DefaultPropertiesToSend, see the DefaultPropertiesToSend constructor.

建構函式

DefaultPropertiesToSend() DefaultPropertiesToSend() DefaultPropertiesToSend() DefaultPropertiesToSend()

初始化 DefaultPropertiesToSend 類別的新執行個體。Initializes a new instance of the DefaultPropertiesToSend class.

屬性

AcknowledgeType AcknowledgeType AcknowledgeType AcknowledgeType

取得或設定要傳回至傳送的應用程式的認可訊息類型。Gets or sets the type of acknowledgement message to be returned to the sending application.

AdministrationQueue AdministrationQueue AdministrationQueue AdministrationQueue

取得或設定接收由訊息佇列所產生的認可訊息的佇列。Gets or sets the queue that receives acknowledgement messages generated by Message Queuing.

AppSpecific AppSpecific AppSpecific AppSpecific

取得或設定額外的應用程式特定資訊。Gets or sets additional, application-specific information.

AttachSenderId AttachSenderId AttachSenderId AttachSenderId

取得或設定值,指出是否應該將傳送者識別碼附加至訊息。Gets or sets a value that indicates whether the sender ID should be attached to the message.

EncryptionAlgorithm EncryptionAlgorithm EncryptionAlgorithm EncryptionAlgorithm

取得或設定用來加密私用訊息主體的加密演算法。Gets or sets the encryption algorithm used to encrypt the body of a private message.

Extension Extension Extension Extension

取得或設定與訊息關聯的其他資訊。Gets or sets additional information associated with the message.

HashAlgorithm HashAlgorithm HashAlgorithm HashAlgorithm

取得或設定當驗證訊息或建立訊息的數位簽章時所使用的雜湊演算法。Gets or sets the hashing algorithm used when authenticating messages or creating a digital signature for a message.

Label Label Label Label

取得或設定描述訊息的應用程式定義字串。Gets or sets an application-defined string that describes the message.

Priority Priority Priority Priority

取得或設定訊息的優先權,用來決定訊息放置在佇列中的位置。Gets or sets the message priority, which is used to determine where the message is placed in the queue.

Recoverable Recoverable Recoverable Recoverable

取得或設定值,指出當發生電腦故障或網路問題時是否保證傳遞訊息。Gets or sets a value that indicates whether the message is guaranteed to be delivered in the event of a computer failure or network problem.

ResponseQueue ResponseQueue ResponseQueue ResponseQueue

取得或設定接收應用程式產生的回應訊息的佇列。Gets or sets the queue that receives application-generated response messages.

TimeToBeReceived TimeToBeReceived TimeToBeReceived TimeToBeReceived

取得或設定從目的端佇列擷取訊息的時間限制。Gets or sets the time limit for the message to be retrieved from the destination queue.

TimeToReachQueue TimeToReachQueue TimeToReachQueue TimeToReachQueue

取得或設定訊息到達佇列的時間限制。Gets or sets the time limit for the message to reach the queue.

TransactionStatusQueue TransactionStatusQueue TransactionStatusQueue TransactionStatusQueue

取得來源電腦上的異動狀態佇列。Gets the transaction status queue on the source computer.

UseAuthentication UseAuthentication UseAuthentication UseAuthentication

取得或設定值,指出訊息在傳送之前是否必須通過驗證。Gets or sets a value that indicates whether the message must be authenticated before being sent.

UseDeadLetterQueue UseDeadLetterQueue UseDeadLetterQueue UseDeadLetterQueue

取得或設定值,指出是否應該將無法傳遞的訊息複本傳送至無法投遞的信件佇列。Gets or sets a value that indicates whether a copy of the message that could not be delivered should be sent to a dead-letter queue.

UseEncryption UseEncryption UseEncryption UseEncryption

取得或設定值,指出是否將訊息設成私用。Gets or sets a value that indicates whether to make the message private.

UseJournalQueue UseJournalQueue UseJournalQueue UseJournalQueue

取得或設定值,指出訊息複本是否應保留在原始電腦上的電腦日誌中。Gets or sets a value that indicates whether a copy of the message should be kept in a machine journal on the originating computer.

UseTracing UseTracing UseTracing UseTracing

取得或設定值,指出當訊息向其目的佇列移動時是否要追蹤訊息。Gets or sets a value that indicates whether to trace a message as it moves toward its destination queue.

方法

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

判斷指定的物件是否等於目前的物件。Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

做為預設雜湊函式。Serves as the default hash function.

(Inherited from Object)
GetType() GetType() GetType() GetType()

取得目前執行個體的 TypeGets the Type of the current instance.

(Inherited from Object)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

建立目前 Object 的淺層複本 (Shallow Copy)。Creates a shallow copy of the current Object.

(Inherited from Object)
ToString() ToString() ToString() ToString()

傳回代表目前物件的字串。Returns a string that represents the current object.

(Inherited from Object)

適用於

另請參閱