MessagePropertyFilter 類別
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
控制並選取當由訊息佇列窺視或接收訊息時所擷取的屬性。
public ref class MessagePropertyFilter
public ref class MessagePropertyFilter : ICloneable
[System.ComponentModel.TypeConverter(typeof(System.ComponentModel.ExpandableObjectConverter))]
public class MessagePropertyFilter
[System.ComponentModel.TypeConverter(typeof(System.ComponentModel.ExpandableObjectConverter))]
public class MessagePropertyFilter : ICloneable
[<System.ComponentModel.TypeConverter(typeof(System.ComponentModel.ExpandableObjectConverter))>]
type MessagePropertyFilter = class
[<System.ComponentModel.TypeConverter(typeof(System.ComponentModel.ExpandableObjectConverter))>]
type MessagePropertyFilter = class
interface ICloneable
Public Class MessagePropertyFilter
Public Class MessagePropertyFilter
Implements ICloneable
- 繼承
-
MessagePropertyFilter
- 屬性
- 實作
範例
下列程式代碼範例會將兩個不同優先順序的訊息傳送至佇列,然後擷取這些訊息。
#using <system.dll>
#using <system.messaging.dll>
using namespace System;
using namespace System::Messaging;
/// <summary>
/// Provides a container class for the example.
/// </summary>
ref class MyNewQueue
{
//**************************************************
// Sends a string message to a queue.
//**************************************************
public:
void SendMessage( MessagePriority priority, String^ messageBody )
{
// Connect to a queue on the local computer.
MessageQueue^ myQueue = gcnew MessageQueue( ".\\myQueue" );
// Create a new message.
Message^ myMessage = gcnew Message;
if ( priority > MessagePriority::Normal )
{
myMessage->Body = "High Priority: {0}",messageBody;
}
else
{
myMessage->Body = messageBody;
}
// Set the priority of the message.
myMessage->Priority = priority;
// Send the Order to the queue.
myQueue->Send( myMessage );
return;
}
//**************************************************
// Receives a message.
//**************************************************
void ReceiveMessage()
{
// Connect to the a queue on the local computer.
MessageQueue^ myQueue = gcnew MessageQueue( ".\\myQueue" );
// Set the queue to read the priority. By default, it
// is not read.
myQueue->MessageReadPropertyFilter->Priority = true;
// Set the formatter to indicate body contains a String^.
array<Type^>^ p = gcnew array<Type^>(1);
p[ 0 ] = String::typeid;
myQueue->Formatter = gcnew XmlMessageFormatter( p );
try
{
// Receive and format the message.
Message^ myMessage = myQueue->Receive();
// Display message information.
Console::WriteLine( "Priority: {0}",
myMessage->Priority );
Console::WriteLine( "Body: {0}",
myMessage->Body );
}
catch ( MessageQueueException^ )
{
// Handle Message Queuing exceptions.
}
// Handle invalid serialization format.
catch ( InvalidOperationException^ e )
{
Console::WriteLine( e->Message );
}
// Catch other exceptions as necessary.
return;
}
};
//**************************************************
// Provides an entry point into the application.
//
// This example sends and receives a message from
// a queue.
//**************************************************
int main()
{
// Create a new instance of the class.
MyNewQueue^ myNewQueue = gcnew MyNewQueue;
// Send messages to a queue.
myNewQueue->SendMessage( MessagePriority::Normal, "First Message Body." );
myNewQueue->SendMessage( MessagePriority::Highest, "Second Message Body." );
// Receive messages from a queue.
myNewQueue->ReceiveMessage();
myNewQueue->ReceiveMessage();
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 sends and receives a message from
// a queue.
//**************************************************
public static void Main()
{
// Create a new instance of the class.
MyNewQueue myNewQueue = new MyNewQueue();
// Send messages to a queue.
myNewQueue.SendMessage(MessagePriority.Normal, "First Message Body.");
myNewQueue.SendMessage(MessagePriority.Highest, "Second Message Body.");
// Receive messages from a queue.
myNewQueue.ReceiveMessage();
myNewQueue.ReceiveMessage();
return;
}
//**************************************************
// Sends a string message to a queue.
//**************************************************
public void SendMessage(MessagePriority priority, string messageBody)
{
// Connect to a queue on the local computer.
MessageQueue myQueue = new MessageQueue(".\\myQueue");
// Create a new message.
Message myMessage = new Message();
if(priority > MessagePriority.Normal)
{
myMessage.Body = "High Priority: " + messageBody;
}
else
{
myMessage.Body = messageBody;
}
// Set the priority of the message.
myMessage.Priority = priority;
// Send the Order to the queue.
myQueue.Send(myMessage);
return;
}
//**************************************************
// Receives a message.
//**************************************************
public void ReceiveMessage()
{
// Connect to the a queue on the local computer.
MessageQueue myQueue = new MessageQueue(".\\myQueue");
// Set the queue to read the priority. By default, it
// is not read.
myQueue.MessageReadPropertyFilter.Priority = true;
// Set the formatter to indicate body contains a string.
myQueue.Formatter = new XmlMessageFormatter(new Type[]
{typeof(string)});
try
{
// Receive and format the message.
Message myMessage = myQueue.Receive();
// Display message information.
Console.WriteLine("Priority: " +
myMessage.Priority.ToString());
Console.WriteLine("Body: " +
myMessage.Body.ToString());
}
catch (MessageQueueException)
{
// Handle Message Queuing exceptions.
}
// Handle invalid serialization format.
catch (InvalidOperationException e)
{
Console.WriteLine(e.Message);
}
// Catch other exceptions as necessary.
return;
}
}
}
Imports System.Messaging
'Provides a container class for the example.
Public Class MyNewQueue
' Provides an entry point into the application.
'
' This example sends and receives a message from
' a queue.
Public Shared Sub Main()
' Create a new instance of the class.
Dim myNewQueue As New MyNewQueue()
' Send messages to a queue.
myNewQueue.SendMessage(MessagePriority.Normal, "First Message Body.")
myNewQueue.SendMessage(MessagePriority.Highest, "Second Message Body.")
' Receive messages from a queue.
myNewQueue.ReceiveMessage()
myNewQueue.ReceiveMessage()
Return
End Sub
' Sends a string message to a queue.
Public Sub SendMessage(priority As MessagePriority, messageBody As String)
' Connect to a queue on the local computer.
Dim myQueue As New MessageQueue(".\myQueue")
' Create a new message.
Dim myMessage As New Message()
If priority > MessagePriority.Normal Then
myMessage.Body = "High Priority: " + messageBody
Else
myMessage.Body = messageBody
End If
' Set the priority of the message.
myMessage.Priority = priority
' Send the Order to the queue.
myQueue.Send(myMessage)
Return
End Sub
' Receives a message.
Public Sub ReceiveMessage()
' Connect to the a queue on the local computer.
Dim myQueue As New MessageQueue(".\myQueue")
' Set the queue to read the priority. By default, it
' is not read.
myQueue.MessageReadPropertyFilter.Priority = True
' Set the formatter to indicate body contains a string.
myQueue.Formatter = New XmlMessageFormatter(New Type() {GetType(String)})
Try
' Receive and format the message.
Dim myMessage As Message = myQueue.Receive()
' Display message information.
Console.WriteLine(("Priority: " + myMessage.Priority.ToString()))
Console.WriteLine(("Body: " + myMessage.Body.ToString()))
' Handle invalid serialization format.
Catch e As InvalidOperationException
Console.WriteLine(e.Message)
End Try
' Catch other exceptions as necessary.
Return
End Sub
End Class
備註
MessagePropertyFilter在實例上MessageQueue設定 ,可控制在查看或接收訊息時所擷取的屬性集。 篩選條件是在擷取訊息資訊的 實例 MessageQueue 上設定。 當您將MessagePropertyFilter布爾值成員設定為 false時,會防止 擷MessageQueue取相關聯Message屬性的資訊。
有數個篩選屬性不是布爾值。 它們是整數值,可取得或設定、 Message.Extension或Message.Label的預設大小Message.Body。
擷取一組有限的屬性有助於改善效能,因為會從佇列傳輸較小的數據量。
在 上 MessagePropertyFilter設定屬性時,您只會指出接收或查看訊息時,是否擷取該屬性。 您不會變更的 Message相關聯屬性值。
建構函式 MessagePropertyFilter 會將所有篩選屬性設定為其預設值,而布爾值則 false為 。 如需指派給整數值屬性的預設值,請參閱建構函式主題。
建構函式
| MessagePropertyFilter() |
初始化 MessagePropertyFilter 類別的新執行個體,並設定所有屬性的預設值。 |
屬性
| AcknowledgeType |
取得或設定值,指出在接收或窺視訊息時是否要擷取 AcknowledgeType 屬性資訊。 |
| Acknowledgment |
取得或設定值,指出在接收或窺視訊息時是否要擷取 Acknowledgment 屬性資訊。 |
| AdministrationQueue |
取得或設定值,指出在接收或窺視訊息時是否要擷取 AdministrationQueue 屬性資訊。 |
| AppSpecific |
取得或設定值,指出在接收或窺視訊息時是否要擷取 AppSpecific 屬性資訊。 |
| ArrivedTime |
取得或設定值,指出在接收或窺視訊息時是否要擷取 ArrivedTime 屬性資訊。 |
| AttachSenderId |
取得或設定值,指出在接收或窺視訊息時是否要擷取 AttachSenderId 屬性資訊。 |
| Authenticated |
取得或設定值,指出在接收或窺視訊息時是否要擷取 Authenticated 屬性資訊。 |
| AuthenticationProviderName |
取得或設定值,指出在接收或窺視訊息時是否要擷取 AuthenticationProviderName 屬性資訊。 |
| AuthenticationProviderType |
取得或設定值,指出在接收或窺視訊息時是否要擷取 AuthenticationProviderType 屬性資訊。 |
| Body |
取得或設定值,指出在接收或窺視訊息時是否要擷取 Body 屬性資訊。 |
| ConnectorType |
取得或設定值,指出在接收或窺視訊息時是否要擷取 ConnectorType 屬性資訊。 |
| CorrelationId |
取得或設定值,指出在接收或窺視訊息時是否要擷取 CorrelationId 屬性資訊。 |
| DefaultBodySize |
取得或設定預設主體緩衝區的大小 (以位元組為單位)。 |
| DefaultExtensionSize |
取得或設定預設擴充緩衝區的大小 (以位元組為單位)。 |
| DefaultLabelSize |
取得或設定預設標籤緩衝區的大小 (以位元組為單位)。 |
| DestinationQueue |
取得或設定值,指出在接收或窺視訊息時是否要擷取 DestinationQueue 屬性資訊。 |
| DestinationSymmetricKey |
取得或設定值,指出在接收或窺視訊息時是否要擷取 DestinationSymmetricKey 屬性資訊。 |
| DigitalSignature |
取得或設定值,指出在接收或窺視訊息時是否要擷取 DigitalSignature 屬性資訊。 |
| EncryptionAlgorithm |
取得或設定值,指出在接收或窺視訊息時是否要擷取 EncryptionAlgorithm 屬性資訊。 |
| Extension |
取得或設定值,指出在接收或窺視訊息時是否要擷取 Extension 屬性資訊。 |
| HashAlgorithm |
取得或設定值,指出在接收或窺視訊息時是否要擷取 HashAlgorithm 屬性資訊。 |
| Id |
取得或設定值,指出在接收或窺視訊息時是否要擷取 Id 屬性資訊。 |
| IsFirstInTransaction |
取得或設定值,指出在接收或窺視訊息時是否要擷取 IsFirstInTransaction 屬性資訊。 |
| IsLastInTransaction |
取得或設定值,指出在接收或窺視訊息時是否要擷取 IsLastInTransaction 屬性資訊。 |
| Label |
取得或設定值,指出在接收或窺視訊息時是否要擷取 Label 屬性資訊。 |
| LookupId |
取得或設定值,指出在接收或窺視訊息時是否要擷取 LookupId 屬性資訊。 |
| MessageType |
取得或設定值,指出在接收或窺視訊息時是否要擷取 MessageType 屬性資訊。 |
| Priority |
取得或設定值,指出在接收或窺視訊息時是否要擷取 Priority 屬性資訊。 |
| Recoverable |
取得或設定值,指出在接收或窺視訊息時是否要擷取 Recoverable 屬性資訊。 |
| ResponseQueue |
取得或設定值,指出在接收或窺視訊息時是否要擷取 ResponseQueue 屬性資訊。 |
| SenderCertificate |
取得或設定值,指出在接收或窺視訊息時是否要擷取 SenderCertificate 屬性資訊。 |
| SenderId |
取得或設定值,指出在接收或窺視訊息時是否要擷取 SenderId 屬性資訊。 |
| SenderVersion |
取得或設定值,指出在接收或窺視訊息時是否要擷取 SenderVersion 屬性資訊。 |
| SentTime |
取得或設定值,指出在接收或窺視訊息時是否要擷取 SentTime 屬性資訊。 |
| SourceMachine |
取得或設定值,指出在接收或窺視訊息時是否要擷取 SourceMachine 屬性資訊。 |
| TimeToBeReceived |
取得或設定值,指出在接收或窺視訊息時是否要擷取 TimeToBeReceived 屬性資訊。 |
| TimeToReachQueue |
取得或設定值,指出在接收或窺視訊息時是否要擷取 TimeToReachQueue 屬性資訊。 |
| TransactionId |
取得或設定值,指出在接收或窺視訊息時是否要擷取 TransactionId 屬性資訊。 |
| TransactionStatusQueue |
取得或設定值,指出在接收或窺視訊息時是否要擷取 TransactionStatusQueue 屬性資訊。 |
| UseAuthentication |
取得或設定值,指出在接收或窺視訊息時是否要擷取 UseAuthentication 屬性資訊。 |
| UseDeadLetterQueue |
取得或設定值,指出在接收或窺視訊息時是否要擷取 UseDeadLetterQueue 屬性資訊。 |
| UseEncryption |
取得或設定值,指出在接收或窺視訊息時是否要擷取 UseEncryption 屬性資訊。 |
| UseJournalQueue |
取得或設定值,指出在接收或窺視訊息時是否要擷取 UseJournalQueue 屬性資訊。 |
| UseTracing |
取得或設定值,指出在接收或窺視訊息時是否要擷取 UseTracing 屬性資訊。 |
方法
| ClearAll() |
設定所有布林篩選值為 |
| Clone() |
建立物件的淺層複本 (Shallow Copy)。 |
| Equals(Object) |
判斷指定的物件是否等於目前的物件。 (繼承來源 Object) |
| GetHashCode() |
做為預設雜湊函式。 (繼承來源 Object) |
| GetType() |
取得目前執行個體的 Type。 (繼承來源 Object) |
| MemberwiseClone() |
建立目前 Object 的淺層複製。 (繼承來源 Object) |
| SetAll() |
指定在接收訊息時擷取所有訊息屬性。 |
| SetDefaults() |
將一般訊息佇列屬性的篩選條件值設定為 |
| ToString() |
傳回代表目前物件的字串。 (繼承來源 Object) |