MessageQueue.DefaultPropertiesToSend Property

Definition

Obtém ou define os valores da propriedade da mensagem a serem usados por padrão quando o aplicativo envia mensagens para a fila.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

Property Value

DefaultPropertiesToSend

Um DefaultPropertiesToSend que contém os valores da propriedade da mensagem Enfileiramento de Mensagens usados quando o aplicativo envia objetos diferentes de instâncias Message para a fila.A DefaultPropertiesToSend that contains the default Message Queuing message property values used when the application sends objects other than Message instances to the queue.

Attributes

Exceptions

Não foi possível definir as propriedades padrão para a fila, possivelmente porque uma das propriedades não é válida.The default properties could not be set for the queue, possibly because one of the properties is not valid.

Examples

O exemplo de código a seguir usa a prioridade de uma mensagem para determinar as propriedades padrão a serem enviadas para a mensagem.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

Remarks

Quando você envia qualquer objeto que não seja do tipo Message à fila, o MessageQueue insere o objeto em uma mensagem do serviço de enfileiramento de mensagens.When you send any object that is not of type Message to the queue, the MessageQueue inserts the object into a Message Queuing message. Nesse momento, a MessageQueue se aplica à mensagem os valores de propriedade que você especifica na propriedade DefaultPropertiesToSend.At that time, the MessageQueue applies to the message the property values you specify in the DefaultPropertiesToSend property. Por outro lado, se você enviar um Message à fila, essas propriedades já serão especificadas para a instância em si, portanto DefaultPropertiesToSend será ignorada para o 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.

Embora você defina as propriedades por meio do objeto MessageQueue, o DefaultPropertiesToSend refere-se às propriedades das mensagens que são enviadas para a fila, não a fila em si.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.

Os valores padrão para as propriedades são mostrados na tabela a seguir.The default values for the properties are shown in the following table.

PropriedadeProperty Valor padrãoDefault value
AcknowledgeType AcknowledgeType.None
AdministrationQueue null
AppSpecific Zero (0)Zero (0)
AttachSenderId true
EncryptionAlgorithm EncryptionAlgorithm.RC2
Extension Uma matriz de comprimento zero de bytesA zero-length array of bytes
HashAlgorithm HashAlgorithm.MD5
Label Cadeia de caracteres vazia ("")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

A tabela a seguir mostra se essa propriedade está disponível em vários modos de grupo de trabalho.The following table shows whether this property is available in various Workgroup modes.

Modo de grupo de trabalhoWorkgroup mode DisponívelAvailable
Computador localLocal computer SimYes
Computador local e nome de formato diretoLocal computer and direct format name SimYes
Computador remotoRemote computer SimYes
Computador remoto e nome de formato diretoRemote computer and direct format name SimYes

Applies to

See also