1

EJB 3 タイマーを作成し、weblogic クラスターにデプロイしました。createTimer パラメータは createTimer(1000, 20000, null); です。これにより、20 秒ごとに繰り返しタイマーが作成されます。ただし、タイマーは常に 30 秒ごとに作成されます。intervalDuration を 40 秒と 50 秒に変更しましたが、タイムアウト メソッドは常に 30 秒ごとにトリガーされます。

以下は、WEBLOGIC_TIMERS テーブル 1@@OSBNode2_1355845459844 (BLOB) 1355846770914 1000 のエントリです。

Below are the entry from ACTIVE table timer.1@@OSBNode2_1355843156331 -96726833478167425/OSBNode2 OSBDomain OSBCluster 18-DEC-12 service.TimerMaster 8866906753834651127/OSBNode1 OSBDomain OSBCluster 18-DEC-12 service.SINGLETON_MASTER 8866906753834651127/OSBNode1 OSBDomain OSBCluster 18-DEC-12

intervalDuration 値ではなく、タイマーが常に 30 秒ごとにトリガーされる理由を調査するのを手伝ってくれる人はいますか?

以下はEJBです----->>

    package com.timertest;
import java.util.*;
import javax.annotation.Resource;
import javax.ejb.*;

@Stateless(mappedName = "TimerTest")
public class TimerTest implements TimerTestRemote
{
    @Resource
    private SessionContext ctx;

  @Override
  public void createMyTimer()
    throws EJBException
  {
        ctx.getTimerService().createTimer(1000, 20000, null);
  }

    @Timeout
    public void timeout(Timer timer) 
    {
        System.out.println("-> Timed Out ..."+ new Date());

    }
}


Below is the and weblogic descripor-------->>
    <?xml version="1.0" encoding="UTF-8"?>
<wls:weblogic-ejb-jar
    xmlns:wls="http://xmlns.oracle.com/weblogic/weblogic-ejb-jar"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd http://xmlns.oracle.com/weblogic/weblogic-ejb-jar http://xmlns.oracle.com/weblogic/weblogic-ejb-jar/1.2/weblogic-ejb-jar.xsd">
    <wls:weblogic-enterprise-bean>
        <wls:ejb-name>TimerTest</wls:ejb-name>
        <wls:stateless-session-descriptor>

            <wls:stateless-clustering>
                <wls:home-is-clusterable>true</wls:home-is-clusterable>
                <wls:home-load-algorithm>round-robin</wls:home-load-algorithm>
                <wls:stateless-bean-is-clusterable>true</wls:stateless-bean-is-clusterable>
                <wls:stateless-bean-load-algorithm>round-robin
                </wls:stateless-bean-load-algorithm>
            </wls:stateless-clustering>
            <wls:business-interface-jndi-name-map>
                <wls:business-remote>TimerTestRemote</wls:business-remote>
                <wls:jndi-name>TimerTest</wls:jndi-name>
            </wls:business-interface-jndi-name-map>
        </wls:stateless-session-descriptor>
        <wls:enable-call-by-reference>false</wls:enable-call-by-reference>
        <wls:jndi-name>TimerTest</wls:jndi-name>
    </wls:weblogic-enterprise-bean>
    <wls:timer-implementation>Clustered</wls:timer-implementation>
</wls:weblogic-ejb-jar>

前もって感謝します

4

2 に答える 2

0

これは直接的な答えではないかもしれませんが、そのような状態を回避するのに役立つかもしれません.


タイマーはデフォルトで永続的であるため、新しいタイマーを開始する前に以前のタイマーをキャンセルする必要があります。

また、文字列識別子infoを渡す代わりにタイマーオブジェクトを作成しながら提供することもできます。null後でどのタイマーがタイムアウトしたかを特定したり、システムに複数のタイマーがある場合にキャンセルしたりするのに役立ちます。

タイマーの作成とアプリケーションの再起動を複数回行うと、そのようなタイマーは同じinfoですが、異なるものを持っていますhashCode。したがって、それらは重複せず、毎回新しく作成されます。

タイマーを取得するには、タイマーをctx.getTimerService().getTimers()繰り返し処理してキャンセルします。

編集:シナリオを複製し、同様の問題に直面しました。デバッグしましたが、キャンセルされていない同じ間隔でアクティブな以前のタイマーが複数ある場合に発生します。

以下のコードを試してみてください。試してみましたが、問題は解決しました。

for(Timer t : timerService.getTimers())
    t.cancel();  //-- Cancel timers before creatimng new one
ctx.getTimerService().createTimer(1000, 20000, null);

ドキュメントからの抜粋:

intervalDuration - 有効期限が遅れた場合 (たとえば、Bean での他のメソッド呼び出しのインターリーブが原因で)、「追いつく」ために 2 つ以上の有効期限通知が連続して発生する可能性があります。

于 2012-12-19T10:30:33.510 に答える
0

別のスタイル (注釈) を使用できます。下記参照:

    @Schedule(hour = "*", minute = "*",second = "*/40")
    @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
    @Lock(LockType.WRITE)
    @AccessTimeout(1000 * 60 * 60)//1 Hour...//Concurrent Access is not permitted...
于 2013-02-21T18:43:15.017 に答える