note 82465 deleted from class.com by nlopess
| From: | nlopess@php.net | Date: | Sat, 12 Apr 2008 10:24:24 +0000 |
| Subject: | note 82465 deleted from class.com by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-138211@lists.php.net to get a copy of this message | ||
Note Submitter: joaopauloln7 at gmail dot com
Reason: non-english
----
Sample collection of messages service queue of Windows.
(Exemplo de Recebimento das mensagens do serviço de fila do Windows)
Developed by : João Paulo Leite Nascimento, Hangel Rodrigues.
Email: joaopauloln7@gmail.com , hangedicastro@gmail.com;
<?php
try{
// define constantes (define constants)
define(MQ_RECEIVE_MESSAGE , 1);
define(MQ_DENY_NONE , 0);
// Instancia o objeto COM (Place the object COM)
$msgQueue = new COM("MSMQ.MSMQQueue") or die("can not create MSMQ
object");
$msgQueueInfo = new COM("MSMQ.MSMQQueueInfo") or die("can not create MSMQ
Info object");
$MSMQQueueMsg = new COM("MSMQ.MSMQMessage") or die("can not create MSMQ
message object");
// define o nome do caminho onde se encontra a fila (Defines the name of the road where the
queue)
$msgQueueInfo->FormatName = "path name";
// abre a fila (Open the queue)
$rcv = $msgQueueInfo->Open(MQ_RECEIVE_MESSAGE, MQ_DENY_NONE);
// se a fila não for aberta (if the queue not opened)
if (!$rcv->IsOpen) {
die("Falha na abertura da fila");
}
// seta o valor de timeout (set the value of timeout)
$ReceiveTimeout = 100;
// recebe a primeira mensagem da lista (Receive the first message from the list)
$msg = $rcv->PeekCurrent(FALSE, TRUE, $ReceiveTimeout);
do {
if(substr($msg->Body,0,4)!= "ERRO" ){
echo $msg->Label;
echo $msg->Body;
}
// recebe o próximo mensagem da lista (Receive the next message from the list)
$msg = $rcv->PeekNext(FALSE, TRUE, $ReceiveTimeout);
} while ($msg);
// limpa as variáveis (Clean the variables)
unset($msgQueue);
unset($msgQueueInfo);
} catch (Exception $e){
echo $e->getMessage();
echo $e->getLine();
}
?>