MessageQueue.EncryptionRequired 属性

定义

获取或设置一个指示队列是否只接受非私有(非加密)消息的值。Gets or sets a value that indicates whether the queue accepts only non-private (non-encrypted) messages.

public:
 property System::Messaging::EncryptionRequired EncryptionRequired { System::Messaging::EncryptionRequired get(); void set(System::Messaging::EncryptionRequired value); };
[System.Messaging.MessagingDescription("MQ_EncryptionRequired")]
public System.Messaging.EncryptionRequired EncryptionRequired { get; set; }
member this.EncryptionRequired : System.Messaging.EncryptionRequired with get, set
Public Property EncryptionRequired As EncryptionRequired

属性值

EncryptionRequired 值之一。One of the EncryptionRequired values. 默认值为 NoneThe default is None.

属性

异常

访问“消息队列”方法时出错。An error occurred when accessing a Message Queuing method.

示例

下面的代码示例获取并设置消息队列EncryptionRequired属性的值。The following code example gets and sets the value of a message queue's EncryptionRequired property.

// Set the queue's EncryptionRequired property value.
queue.EncryptionRequired = System.Messaging.EncryptionRequired.Optional;

// Display the new value of the queue's EncryptionRequired property.
Console.WriteLine("MessageQueue.EncryptionRequired: {0}",
    queue.EncryptionRequired);

注解

当你指定发送到队列的消息需要加密时, 只会加密消息正文。When you specify that encryption is required for the messages sent to a queue, only the message bodies are encrypted. 不能对其他成员 (例如, LabelSenderId属性) 进行加密。The other members (for example, the Label and SenderId properties) cannot be encrypted.

设置此属性将修改 "消息队列" 队列。Setting this property modifies the Message Queuing queue. 因此, 此更改MessageQueue会影响任何其他实例。Therefore, any other MessageQueue instances are affected by the change.

加密消息会使消息成为私有消息。Encrypting a message makes the message private. 您可以None通过适当地设置Body EncryptionRequired属性, 将队列的加密要求Optional指定为、或。You can specify the queue's encryption requirement to be None, Body, or Optional by setting the EncryptionRequired property appropriately. 消息UseEncryption的设置必须与队列的加密要求相对应。The UseEncryption setting of the message must correspond to the encryption requirement of the queue. 如果未对消息进行加密, 但队列指定Body了, 或者如果消息已加密但队列指定None了该消息, 则队列将拒绝该消息。If the message is not encrypted but the queue specifies Body, or if the message is encrypted but the queue specifies None, the message is rejected by the queue. 如果发送应用程序在此事件中请求否定确认消息, 则消息队列将指示消息对发送应用程序的拒绝。If the sending application requests a negative acknowledgment message in this event, Message Queuing indicates the message's rejection to the sending application. 如果属性为true, 则会将加密失败的消息发送到死信队列。 UseDeadLetterQueueIf the UseDeadLetterQueue property is true, a message that fails encryption is sent to the dead-letter queue. 否则, 消息将丢失。Otherwise, the message is lost.

下表显示了此属性在各种工作组模式下是否可用。The following table shows whether this property is available in various Workgroup modes.

工作组模式Workgroup mode 可用Available
本地计算机Local computer Yes
本地计算机和直接格式名称Local computer and direct format name Yes
远程计算机Remote computer NoNo
远程计算机和直接格式名称Remote computer and direct format name NoNo

适用于

另请参阅