DefaultPropertiesToSend 类
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
指定在向消息队列发送 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
注解
可以为发送到 a MessageQueue的消息设置所选属性的默认值。 DefaultPropertiesToSend 用于指定在将实例以外的 Message 对象发送到队列时要发送的消息的默认属性值,例如,传递到 Send 代码片段 myMessageQueue.Send("hello")
中方法的字符串参数。 该Message类具有与专门发送Message实例时提供值的相应、同名属性DefaultPropertiesToSend。 即使为队列指定 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) |