2016-11-05 9 views
0

私はちょうどcamundaに新しい、私は最初から最後まで私のプロセスの実行時間を測定したいが、私はリスナーのための適切なコーディングの例を見つけることができません。私が思い付くことができるすべては、私が正しいと願って開始と終了イベントのモデラーでクラスを設定Camunda ExecutionListenerのタイムスタンプ付きの実装

public void notify (DelegateExecution execution) throws Exception { 

    // What happens when Start Event is executed 
    long startTime = System.currentTimeMillis(); 

    // What happens when token has reached End Event 
    long stopTime = System.currentTimeMillis(); 
    long elapsedTime = stopTime - startTime; 
    System.out.println(elapsedTime); 
    } 

です。あなたは、プロセスのエンドツーエンドの実行時間に興味がある場合は事前に

感謝:)

+0

ようこそスタックオーバーフローに!良い質問をするのを助けるために私たちの[SO Question Checklist](http://meta.stackoverflow.com/questions/260648/stack-overflow-question-checklist)をよく読んで、良い答えを得てください。 –

答えて

0

あなたのためのエンジン対策。しかし、プロセス・インスタンスがまだ実行中であるため、リスナーを持つプロセス・インスタンスの継続時間をプロセスに出力することはできません。データベーステーブルact_hi_procinstで期間を確認することができます。

また、あなたは、エンジンからHistoryServiceを使用することができます。

public class ProcessInstanceHistory { 

@Inject 
HistoryService historyService; 

public List<HistoricProcessInstance> historicProcessInstances() { 
    return historyService.createHistoricProcessInstanceQuery().list(); 
} 

public void printDurations() { 
    for (HistoricProcessInstance historicProcessInstance : historicProcessInstances()) { 
     System.out.println("elapsedTime :" + historicProcessInstance.getDurationInMillis()); 
    } 
} 
} 
2

、あなただけhistoryService経由HistoricActivityInstanceをチェックし、その開始日と終了日を確認することができます。 カスタム実装は不要です。

関連する問題