JavaでCXFで実装されたSOAP Webサービスが動作しています。サーバー側でメソッドの実行を計算するには、どのような方法が良いでしょうか?Webサービスリクエストの除外時間計算
私が今行ったことは、インターセプタを使用したことです。私は、InInterceptor(Phase.RECEIVE)にpublic static long start
を定義しました。そして、私のOutInterceptor(Phase.SEND)では、私はこのような応答時間を計算します:
@Override
public void handleMessage(Message arg0) {
long stop = System.currentTimeMillis();
long executionTime = stop - RequestStartInterceptor.start;
System.out.println("execution time was ~" + executionTime + " ms");
}
もっと良い方法がありますか?メソッドトラフプロキシの実行については読んでいましたが、どうやってそれを行うのかわかりません。
質問更新:
私はプロキシつまりを使用して第二の方法arroundの私の方法を見つけるもう少しググました:
インターセプタをされ使用して、これまでのところこの質問へのコメントに基づいて@Aspect
public class MyServiceProfiler {
@Pointcut("execution(* gov.noaa.nhc.*.*(..))")
public void myServiceMethods() { }
@Around("myServiceMethods()")
public Object profile(ProceedingJoinPoint pjp) throws Throwable {
long start = System.currentTimeMillis();
System.out.println("Going to call the method.");
Object output = pjp.proceed();
System.out.println("Method execution completed.");
long elapsedTime = System.currentTimeMillis() - start;
System.out.println("Method execution time: " + elapsedTime + " milliseconds.");
return output;
}
}
プロキシを使用するよりも優れています。私は可能な限りWebサービスを遅くする(これは確かにそれを遅くする)と同時に、正確なパフォーマンス測定を得るために探しています。
上記のメカニズムは良いと思います。 –
私はインターセプタもお勧めしたいと思いますが、実際には役に立っているので – mtraut