DefaultPropertiesToSend 类

定义

指定将实例以外的 Message 对象发送到消息队列时将使用的默认属性值。

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

注解

可以为发送到 /a0> 的消息设置所选属性的默认值。 DefaultPropertiesToSend 用于指定在将实例以外的 Message 对象发送到队列时要发送的消息的默认属性值,例如,传入 Send 代码片段 myMessageQueue.Send("hello")中方法的字符串参数。 该 Message 类具有与在 DefaultPropertiesToSend 专门发送 Message 实例时提供值的相应、同名属性。 即使为队列指定 MessageQueue.DefaultPropertiesToSend 了对象,向该队列发送 Message 对象也会导致相同命名 Message 属性的值重写队列 DefaultPropertiesToSend 的值。

未显式设置为构造函数 DefaultPropertiesToSend指定的值的属性。

有关实例 DefaultPropertiesToSend的初始属性值列表,请参阅 DefaultPropertiesToSend 构造函数。

构造函数

名称 说明
DefaultPropertiesToSend()

初始化 DefaultPropertiesToSend 类的新实例。

属性

名称 说明
AcknowledgeType

获取或设置要返回到发送应用程序的确认消息的类型。

AdministrationQueue

获取或设置接收消息队列生成的确认消息的队列。

AppSpecific

获取或设置其他特定于应用程序的信息。

AttachSenderId

获取或设置一个值,该值指示是否应将发件人 ID 附加到邮件。

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)

适用于

另请参阅