GetFirst (TStereotypeClassQueue)

De Wiki1000
class function GetFirst(const iTopic:string):TQueueObject;

Cette fonction retourne le premier objet prêt de la file d'attente sans le consommer.

Result Le premier objet non consommée de la file pour le sujet.
iTopic Nom de sujet demandé.
Tip-20px.png Tip : Cette fonction est utile pour
  • Anticiper la valeur du sujet lorsqu'elle est utilisée avec un topic comportant une partie variable
  • Consommer les objets par une boucle First/Next sans être bloqué par un message "poison"

Exemple :

//Procedure TestInQueue;
var sel:TSelector; obj,todo:MyQueue; inst:WFClasseA; S,stag:string;
begin
  sel := WFClasseA.CreateSelector('unEntier>%1','',true,[10]);
  sel.InQueue('MyQueue','wfclassea/@oid');
 
  S := ''; stag := '';
  obj := MyQueue.GetFirst('');
  Repeat
    if Assigned(obj) then
     begin
       // We can do some check on the actual topic of the queue object
       // we keep obj for the GetNext, so we used an other instance
       todo := MyQueue.deQueue(obj.queueTopic);
       // the object may has been consumed by an other process, so we have to check it again.
       if Assigned(todo) then
         begin
           inst := todo.queueRef as WFClasseA;
           if Assigned(inst) then
             try
               // This is a test case for requeue capability
               if inst.unEntier=21 then raise Exception.Create('check error');
               //
               S := S+stag+inst.unCode;
               stag := ',';
               // delete this queue object
               todo.DeleteThisObject;
             except
             // on error requeue the object with the same topic
             // The object will not been retreive in the next loop turn because of the GetNext
             todo.ReQueue('');
             end;
         end;
     end;
    //
    obj := MyQueue.GetNext('',obj);
  Until not Assigned(obj);
 
  showMessage(S);
end;

Voir aussi

Classe_file_d'attente_(stereotype)Développement DSM





Whos here now:   Members 0   Guests 0   Bots & Crawlers 1
 
Outils personnels