DéveloppeurWeb.Com
    DéveloppeurWeb.Com
    • Agile Zone
    • AI Zone
    • Cloud Zone
    • Database Zone
    • DevOps Zone
    • Integration Zone
    • Web Dev Zone
    DéveloppeurWeb.Com
    Home»Open Source Zone»Supprimer les incidents de Camunda Cockpit
    Open Source Zone

    Supprimer les incidents de Camunda Cockpit

    novembre 8, 2021
    Supprimer les incidents de Camunda Cockpit
    Share
    Facebook Twitter Pinterest Reddit WhatsApp Email

    Aujourd’hui, nous apprenons à supprimer les incidents de Camunda Cockpit.

    • Créez un projet Spring Boot avec le moteur Camunda intégré. Utilisez la version 7.15.0.

    Autres exigences:

    • Botte de printemps 2.4.3
    • Camunda 7.15.0
    • Eclipse ou tout autre IDE
    • Maven

    Pas

    1. Installez les dépendances requises.
    2. Créez maintenant une tâche de service simple dans Camunda Modeler et ajoutez la classe Java en tant qu’expression de délégué.
    3. Utilisez Camunda Modeler pour enregistrer le contenu XML ci-dessous avec l’extension .bpmn pour obtenir le modèle de processus, qui a des tâches de service en tant que composants.
    <?xml version="1.0" encoding="UTF-8"?>
    
    <bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="Definitions_17f2lxv" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="4.5.0">
    
      <bpmn:collaboration id="Collaboration_07k12v5">
    
        <bpmn:participant id="Participant_1x8s9fh" name="Start Process" processRef="StartProcess" />
    
      </bpmn:collaboration>
    
      <bpmn:process id="StartProcess" isExecutable="true">
    
        <bpmn:startEvent id="StartEvent_1" name="start">
    
           <bpmn:outgoing>Flow_1jywq5w</bpmn:outgoing>
    
        </bpmn:startEvent>
    
        <bpmn:endEvent id="Event_03t38ul" name="end">
    
          <bpmn:incoming>Flow_1wvoxke</bpmn:incoming>
    
        </bpmn:endEvent>
    
        <bpmn:sequenceFlow id="Flow_1jywq5w" sourceRef="StartEvent_1" targetRef="Activity_0oy4xym" />
    
        <bpmn:serviceTask id="Activity_0oy4xym" name="Incidents Class" camunda:asyncBefore="true" camunda:delegateExpression="#{checkIncidentsDelegate}">
    
           <bpmn:incoming>Flow_1jywq5w</bpmn:incoming>
    
           <bpmn:outgoing>Flow_1wvoxke</bpmn:outgoing>
    
        </bpmn:serviceTask>
    
        <bpmn:sequenceFlow id="Flow_1wvoxke" sourceRef="Activity_0oy4xym" targetRef="Event_03t38ul" />
    
        <bpmn:endEvent id="Event_07h1zeh">
    
           <bpmn:incoming>Flow_1a8mncl</bpmn:incoming>
    
        </bpmn:endEvent>
    
        <bpmn:sequenceFlow id="Flow_1a8mncl" sourceRef="Event_00wg3ai" targetRef="Event_07h1zeh" />
    
        <bpmn:boundaryEvent id="Event_00wg3ai" attachedToRef="Activity_0oy4xym">
    
           <bpmn:outgoing>Flow_1a8mncl</bpmn:outgoing>
    
          <bpmn:errorEventDefinition id="ErrorEventDefinition_0oqk8gt" errorRef="Error_0jgkptt" />
    
        </bpmn:boundaryEvent>
    
      </bpmn:process>
    
      <bpmn:error id="Error_0jgkptt" name="ERROR_CATCH" errorCode="ERROR_CATCH" />
    
      <bpmndi:BPMNDiagram id="BPMNDiagram_1">
    
        <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Collaboration_07k12v5">
    
          <bpmndi:BPMNShape id="Participant_1x8s9fh_di" bpmnElement="Participant_1x8s9fh" isHorizontal="true">
    
            <dc:Bounds x="129" y="60" width="600" height="290" />
    
          </bpmndi:BPMNShape>
    
          <bpmndi:BPMNEdge id="Flow_1jywq5w_di" bpmnElement="Flow_1jywq5w">
    
            <di:waypoint x="268" y="190" />
    
            <di:waypoint x="330" y="190" />
    
          </bpmndi:BPMNEdge>
    
          <bpmndi:BPMNEdge id="Flow_1wvoxke_di" bpmnElement="Flow_1wvoxke">
    
            <di:waypoint x="430" y="190" />
    
            <di:waypoint x="532" y="190" />
    
          </bpmndi:BPMNEdge>
    
          <bpmndi:BPMNEdge id="Flow_1a8mncl_di" bpmnElement="Flow_1a8mncl">
    
            <di:waypoint x="390" y="248" />
    
            <di:waypoint x="390" y="310" />
    
            <di:waypoint x="462" y="310" />
    
          </bpmndi:BPMNEdge>
    
          <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1">
    
            <dc:Bounds x="232" y="172" width="36" height="36" />
    
            <bpmndi:BPMNLabel>
    
              <dc:Bounds x="239" y="215" width="23" height="14" />
    
            </bpmndi:BPMNLabel>
    
          </bpmndi:BPMNShape>
    
          <bpmndi:BPMNShape id="Event_03t38ul_di" bpmnElement="Event_03t38ul">
    
            <dc:Bounds x="532" y="172" width="36" height="36" />
    
            <bpmndi:BPMNLabel>
    
              <dc:Bounds x="541" y="215" width="19" height="14" />
    
            </bpmndi:BPMNLabel>
    
          </bpmndi:BPMNShape>
    
          <bpmndi:BPMNShape id="Activity_07zt6e5_di" bpmnElement="Activity_0oy4xym">
    
            <dc:Bounds x="330" y="150" width="100" height="80" />
    
          </bpmndi:BPMNShape>
    
          <bpmndi:BPMNShape id="Event_07h1zeh_di" bpmnElement="Event_07h1zeh">
    
            <dc:Bounds x="462" y="292" width="36" height="36" />
    
          </bpmndi:BPMNShape>
    
          <bpmndi:BPMNShape id="Event_0z0tiw2_di" bpmnElement="Event_00wg3ai">
    
            <dc:Bounds x="372" y="212" width="36" height="36" />
    
          </bpmndi:BPMNShape>
    
        </bpmndi:BPMNPlane>
    
      </bpmndi:BPMNDiagram>
    
    </bpmn:definitions>

    4. Maintenant, essayez de créer une exception dans la classe Java afin qu’elle produise un incident dans Camunda Cockpit. Créez un autre fichier BPMN qui contient le planificateur de temps comme dans le fichier XML ci-dessous. Ici, je crée un planificateur de temps pour supprimer les incidents qui sont créés.

    <?xml version="1.0" encoding="UTF-8"?>
    
    <bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="Definitions_0tk5ewe" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="4.5.0">
    
      <bpmn:collaboration id="Collaboration_0140ryf">
    
        <bpmn:participant id="Participant_1dewiyn" name="DeleteIncidents" processRef="DeleteIncidents" />
    
      </bpmn:collaboration>
    
      <bpmn:process id="DeleteIncidents" name="Delete incident" isExecutable="true">
    
        <bpmn:startEvent id="StartEvent_1">
    
           <bpmn:outgoing>Flow_1g7a7p4</bpmn:outgoing>
    
          <bpmn:timerEventDefinition id="TimerEventDefinition_1q5huzh">
    
            <bpmn:timeCycle xsi:type="bpmn:tFormalExpression">R/PT2M</bpmn:timeCycle>
    
          </bpmn:timerEventDefinition>
    
         </bpmn:startEvent>
    
        <bpmn:sequenceFlow id="Flow_1g7a7p4" sourceRef="StartEvent_1" targetRef="Activity_0beg4h9" />
    
        <bpmn:serviceTask id="Activity_0beg4h9" name="Delete incident" camunda:asyncBefore="true" camunda:delegateExpression="#{incidentScheduler}">
    
           <bpmn:incoming>Flow_1g7a7p4</bpmn:incoming>
    
        </bpmn:serviceTask>
    
      </bpmn:process>
    
      <bpmndi:BPMNDiagram id="BPMNDiagram_1">
    
        <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Collaboration_0140ryf">
    
          <bpmndi:BPMNShape id="Participant_1dewiyn_di" bpmnElement="Participant_1dewiyn" isHorizontal="true">
    
            <dc:Bounds x="160" y="52" width="600" height="250" />
    
          </bpmndi:BPMNShape>
    
          <bpmndi:BPMNEdge id="Flow_1g7a7p4_di" bpmnElement="Flow_1g7a7p4">
    
            <di:waypoint x="285" y="177" />
    
            <di:waypoint x="360" y="177" />
    
          </bpmndi:BPMNEdge>
    
          <bpmndi:BPMNShape id="Event_0u4cb2o_di" bpmnElement="StartEvent_1">
    
            <dc:Bounds x="249" y="159" width="36" height="36" />
    
          </bpmndi:BPMNShape>
    
          <bpmndi:BPMNShape id="Activity_124pwoy_di" bpmnElement="Activity_0beg4h9">
    
            <dc:Bounds x="360" y="137" width="100" height="80" />
    
          </bpmndi:BPMNShape>
    
        </bpmndi:BPMNPlane>
    
      </bpmndi:BPMNDiagram>
    
    </bpmn:definitions>

    Ces fichiers BPMN contiennent une minuterie qui effacera les incidents en fonction du cycle que nous avons donné. Dans ce fichier BPMN, la définition du temporisateur est donnée comme R/PT2M. Cela signifie qu’il se répétera à l’infini avec une durée de 2 minutes. Pour une tâche de service, le code Java est donné comme suit :

    try {
    IncidentQuery query = execution.getProcessEngine().getRuntimeService().createIncidentQuery().processDefinitionKeyIn("StartProcess");
    List<Incident> incidents = query.list();
    for (Incident incident : incidents) {
    String incidentProcessId = incident.getProcessInstanceId();
    execution.getProcessEngine().getRuntimeService().deleteProcessInstance(incidentProcessId, "Deleting unattached token");
    }
    
    } catch (Exception e) {
    
    System.out.println("Exception in IncidentScheduler :: "+e.getLocalizedMessage());
    
    }

    Ces codes prendront les incidents de la définition de processus particulière que nous avons donnée et effaceront les incidents.

    Share. Facebook Twitter Pinterest LinkedIn WhatsApp Reddit Email
    Add A Comment

    Leave A Reply Cancel Reply

    Catégories

    • Politique de cookies
    • Politique de confidentialité
    • CONTACT
    • Politique du DMCA
    • CONDITIONS D’UTILISATION
    • Avertissement
    © 2023 DéveloppeurWeb.Com.

    Type above and press Enter to search. Press Esc to cancel.