discuss_ja@glassfish.java.net

Re: glassfishのTimerServiceについて

From: 石橋 和洋 <ishibashi.kazuhiro_at_ns-sol.co.jp>
Date: Fri, 06 Nov 2009 17:48:45 +0900

荻布さま。こんばんわ。
早速のご返事ありがとうございます。

再現されませんか・・・ということはコードの問題なんでしょうか。

ログにはなにも出力されていないようです。
server.logですが、現象が何時起きるのか監視が難しいのですが取ってみます。


コードは以下のとおりです。不足ありましたらご指摘ください。
(極力元のまま貼り付けます)
(再現するためのプログラムという事は、アプリの部分ではなく、再現するための
最小セットを作らないといけないと言う事ですよね・・・そちらも少しおまちを)

-------------------------------
@Stateless
public class ActionFacadeBean implements ActionFacade{

        @Resource
        private TimerService timerService;

        private Timer timer = null;

        public void startTimer(Date startdate, long interval ){
                Collection<Timer> timers = timerService.getTimers();
                for(Timer t : timers) t.cancel();
                if(interval==0){
                        timer = null;
                        return;
                }
                timer = timerService.createTimer(startdate, interval, null);
                System.out.println("**** TIMER STARTED AT " + new Date());

        }
        public Timer getTimer(){
                return timer;
        }

        /**
         * アクションタイマーが実行されたときに、実行するメソッド。
         *
         * @param timer
         */
        @Timeout
        
        public void handleTimeout(Timer timer){
                try{
                        Collection<TimerAction> actions = em.createNamedQuery("findTimerAction").getResultList();
                        for(TimerAction a : actions){
                                System.out.println("************実行中のタイマーアクション:"+
a.getId());
                                Collection<Apply> applies =
applyfacade.findApplyByStatus(a.getStatus());
                                a.fireAll(applies);
                        }
                }catch(Throwable e){
                        System.out.println("************アクションタイマーの実行中にエラーが
発生しました。");
                        e.printStackTrace();
                }
        }
        /*
        public void handleTimeout(Timer time){
                System.out.println("*************TIMER WORK AT "+new Date());
        }*/
-----------------------------



Shinya Ogino さんは書きました:
> 石橋さん、こんにちは。
>
> 少し試してみたのですが、こちらで再現できていません。
> 下記、連絡頂くことはできますか?
> - エラーなどがログに出力されていたらその内容
> domains/ドメイン/logs/server.log
> - 再現するためのプログラム
>
> 荻布
>
> 石橋 和洋 wrote:
>> お世話になります。石橋といいます。
>>
>> 最近本MLに加入しました。既メンバーの皆様、よろしくお願いします。
>>
>> 早速ですが、glassfishについて質問があります。
>> ご存知の方がおられましたらお教えいただきたいと思います。
>>
>> 製品のバージョン:
>> glassfish v2.1
>>
>> 質問の内容:
>> glassfishのTimerServiceを利用しているのですが、Intervalをきっかり600秒以上に
>> すると、2時間ほどでTimerが落ちてしまいます。600秒だと落ちずにずっと
>> 動き続けています。
>> これは、glassfishの仕様なのでしょうか?
>> 制限を解除するような設定などはないのでしょうか?
>>
>> よろしくお願いします。
>
>