MessageQueue.DefaultPropertiesToSend Proprietà

Definizione

Ottiene o imposta i valori di proprietà dei messaggi da utilizzare per impostazione predefinita quando vengono inviati messaggi alla coda dall'applicazione.Gets or sets the message property values to be used by default when the application sends messages to the queue.

public:
 property System::Messaging::DefaultPropertiesToSend ^ DefaultPropertiesToSend { System::Messaging::DefaultPropertiesToSend ^ get(); void set(System::Messaging::DefaultPropertiesToSend ^ value); };
[System.ComponentModel.Browsable(false)]
[System.Messaging.MessagingDescription("MQ_DefaultPropertiesToSend")]
public System.Messaging.DefaultPropertiesToSend DefaultPropertiesToSend { get; set; }
member this.DefaultPropertiesToSend : System.Messaging.DefaultPropertiesToSend with get, set
Public Property DefaultPropertiesToSend As DefaultPropertiesToSend

Valore della proprietà

Oggetto DefaultPropertiesToSend contenente i valori predefiniti delle proprietà dei messaggi di Accodamento messaggi utilizzati quando l'applicazione invia alla coda oggetti diversi dalle istanze di Message.A DefaultPropertiesToSend that contains the default Message Queuing message property values used when the application sends objects other than Message instances to the queue.

Attributi

Eccezioni

Non è possibile impostare le proprietà predefinite per la coda, probabilmente perché una proprietà non è valida.The default properties could not be set for the queue, possibly because one of the properties is not valid.

Esempi

Nell'esempio di codice seguente viene utilizzata la priorità di un messaggio per determinare le proprietà predefinite da inviare per il messaggio.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

Commenti

Quando si invia un oggetto che non è di tipo Message alla coda, il MessageQueue inserisce l'oggetto in un messaggio di Accodamento messaggi.When you send any object that is not of type Message to the queue, the MessageQueue inserts the object into a Message Queuing message. In quel momento, il MessageQueue si applica al messaggio i valori di proprietà specificati nella proprietà DefaultPropertiesToSend.At that time, the MessageQueue applies to the message the property values you specify in the DefaultPropertiesToSend property. Viceversa, se si invia un Message alla coda, queste proprietà sono già specificate per l'istanza stessa, quindi DefaultPropertiesToSend viene ignorato per il Message.Conversely, if you send a Message to the queue, these properties are already specified for the instance itself, so DefaultPropertiesToSend is ignored for the Message.

Sebbene le proprietà vengano impostate tramite l'oggetto MessageQueue, il DefaultPropertiesToSend fa riferimento alle proprietà dei messaggi inviati alla coda, non alla coda stessa.Although you set the properties through the MessageQueue object, the DefaultPropertiesToSend refers to the properties of the messages that are sent to the queue, not the queue itself.

Nella tabella seguente sono riportati i valori predefiniti per le proprietà.The default values for the properties are shown in the following table.

ProprietàProperty Valore predefinitoDefault value
AcknowledgeType AcknowledgeType.None
AdministrationQueue null
AppSpecific Zero (0)Zero (0)
AttachSenderId true
EncryptionAlgorithm EncryptionAlgorithm.RC2
Extension Matrice di byte di lunghezza zeroA zero-length array of bytes
HashAlgorithm HashAlgorithm.MD5
Label stringa vuota ("")Empty string ("")
Priority MessagePriority.Normal
Recoverable false
ResponseQueue null
TimeToBeReceived Message.InfiniteTimeout
TimeToReachQueue Message.InfiniteTimeout
TransactionStatusQueue null
UseAuthentication false
UseDeadLetterQueue false
UseEncryption false
UseJournalQueue false
UseTracing false

Nella tabella seguente viene illustrato se questa proprietà è disponibile in varie modalità del gruppo di lavoro.The following table shows whether this property is available in various Workgroup modes.

Modalità gruppo di lavoroWorkgroup mode DisponibileAvailable
Computer localeLocal computer Yes
Nome del computer locale e del formato direttoLocal computer and direct format name Yes
Computer remotoRemote computer Yes
Nome del computer remoto e del formato direttoRemote computer and direct format name Yes

Si applica a

Vedi anche