MessageQueue.GetAllMessages Método

Definição

Retorna todas as mensagens na fila.Returns all the messages that are in the queue.

public:
 cli::array <System::Messaging::Message ^> ^ GetAllMessages();
public System.Messaging.Message[] GetAllMessages ();
member this.GetAllMessages : unit -> System.Messaging.Message[]
Public Function GetAllMessages () As Message()

Retornos

Message[]

Uma matriz do tipo Message que representa todas as mensagens na fila, na mesma ordem em que são exibidas na fila do serviço de Enfileiramento de Mensagens.An array of type Message that represents all the messages in the queue, in the same order as they appear in the Message Queuing queue.

Exceções

Erro ao acessar um método do serviço de Enfileiramento de Mensagens.An error occurred when accessing a Message Queuing method.

Exemplos

O exemplo de código a seguir demonstra o uso de GetAllMessages.The following code example demonstrates the use of GetAllMessages.


// Connect to a queue on the local computer.
MessageQueue^ queue = gcnew MessageQueue(".\\exampleQueue");

// Populate an array with copies of all the messages in the queue.
array<Message^>^ msgs = queue->GetAllMessages();

// Loop through the messages.
for each(Message^ msg in msgs)
{
    // Display the label of each message.
    Console::WriteLine(msg->Label);
}

queue->Close();


// Connect to a queue on the local computer.
MessageQueue queue = new MessageQueue(".\\exampleQueue");

// Populate an array with copies of all the messages in the queue.
Message[] msgs = queue.GetAllMessages();

// Loop through the messages.
foreach(Message msg in msgs)
{
    // Display the label of each message.
    Console.WriteLine(msg.Label);
}

Comentários

GetAllMessages Retorna um instantâneo estático das mensagens na fila, não links dinâmicos para essas mensagens.GetAllMessages returns a static snapshot of the messages in the queue, not dynamic links to those messages. Portanto, você não pode usar a matriz para modificar as mensagens na fila.Therefore, you cannot use the array to modify the messages in the queue. Se você quiser uma interação dinâmica em tempo real com a fila (como a capacidade de excluir mensagens), chame o GetMessageEnumerator2 método, que retorna uma lista dinâmica das mensagens na fila.If you want real-time, dynamic interaction with the queue (such as the ability to delete messages), call the GetMessageEnumerator2 method, which returns a dynamic list of the messages in the queue.

Como o GetAllMessages retorna uma cópia das mensagens na fila no momento em que o método foi chamado, a matriz não reflete as novas mensagens que chegam na fila ou mensagens que são removidas da fila.Because GetAllMessages returns a copy of the messages in the queue at the time the method was called, the array does not reflect new messages that arrive in the queue or messages that are removed from the queue.

GetAllMessages Recupera somente as propriedades não filtradas pela MessageReadPropertyFilter propriedade.GetAllMessages retrieves only those properties not filtered out by the MessageReadPropertyFilter property.

A tabela a seguir mostra se esse método está disponível em vários modos de grupo de trabalho.The following table shows whether this method is available in various Workgroup modes.

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

Aplica-se a

Confira também