2013-05-01 7 views
6

JTOpenのKeyedDataQueueクラスで提供されているread()メソッドを使用すると、異常な動作が検出されました。JTOpen KeyedDataQueue read()timeout

私は90秒のタイムアウトを設定しており、タイムアウトに達すると99%の読み取り実行がコールされ、呼び出しメソッドの実行が再開されます。

他の1%については、タイムアウトを考慮していない/達し、私の呼び出し方法は...

を掛けたままビットを検索した後、私はこの記事を見つけた:基本的に

http://archive.midrange.com/java400-l/201112/msg00056.html

それは私が疑われるものを確認:

「私もDataQueue.read()タイムアウト機能が サーバ側であることがわかったTCP/IP CONNので、もしectionが静かに引き落とされます(私は がこれの根底にある原因と考えています)。私はJTOpenのバージョン7.2を使用していると私は私が安定している7.2を使用して、重要なアプリケーションの多くを持っているし、本当にこれがあるので、私は7.9に更新されませんでした。バージョン7.9がそこにすでにあることを認識し、「

私はその決定を助けるために、特にこの状況に遭遇し、最終的にJTOpenをアップグレードすることによってあなたのフィードバックをお待ちしております。

具体的には、この問題の回避策がありますか?JTOpenをアップグレードするにはJTOpenを7.9にアップグレードしますか? 7.2で働いていたことは何ですか?

+0

@JamesA:私は自分自身のスペルを忠実に綴っていますが、すべてをアメリカ人にする必要はありません。 ;)(それ以外の点では良い編集でした。) –

+1

[Java400 list on Midrange.com](http://lists.midrange.com/mailman/listinfo/java400-l)へのリンクが見つかりました。そのメーリングリストにサインアップしてそこに質問を投稿したいかもしれません。これまでのところ、IBMミッドレンジコミュニティは、Midrange.comと比較してスタックオーバーフローに非常に薄い参加しかしていないようです。 –

+0

たぶんそれは彼らの貧しいスペルの能力のためです:P私はそこに私の運を試してみます – RedEagle

答えて

1

上記のように、データキューの読み取りタイムアウトはサーバー側です。 iSeriesとクライアントの間のTCP接続がストールしたり停止したりすると、クライアントはソケットがタイムアウトするまで待機します。私の解決策は、ストールした読書を止めるためのフェールセーフ・インタラプタを設置することです。これはどのように行うことができるかの簡単なコードサンプルです。

public class DataQueueListenerExample { 
    //This executes our Interrupter after the specified delay. 
    public final ScheduledThreadPoolExecutor interruptExecuter = new ScheduledThreadPoolExecutor(1); 
    //the dataqueue object. 
    protected DataQueue dataqueue; 

    public DataQueueEntry read(int wait) 
    { 
     ScheduledFuture<?> future = null; 
     try { 
      //create our fail safe interrupter. We only want it to 
      //interrupt when we are sure the read has stalled. My wait time is 15 seconds 
      future = createInterrupter(wait * 2, TimeUnit.SECONDS); 
      //read the dataqueue 
      return this.dataqueue.read(wait); 
     } catch (AS400SecurityException e) { 
     } catch (ErrorCompletingRequestException e) { 
     } catch (IOException e) { 
     } catch (IllegalObjectTypeException e) { 
     } catch (InterruptedException e) { 
      //The read was interrupted by our Interrupter 
      return null; 
     } catch (ObjectDoesNotExistException e) { 
     } finally{ 
      //Cancel our interrupter 
      if(future != null && !future.isDone()) 
       future.cancel(true); 
      Thread.interrupted();//clear the interrupted flag 

      interruptExecuter.shutdown(); 
     } 
     return null; 
    } 


    public ScheduledFuture<?> createInterrupter(long timeout,TimeUnit timeunit) 
    { 
     return interruptExecuter.schedule(new Interrupter(),timeout,timeunit); 
    } 

    class Interrupter implements Runnable 
    { 
     final Thread parent; 
     Interrupter() 
     { 
      this.parent = Thread.currentThread(); 
     } 

     @Override 
     public void run() { 
      parent.interrupt(); 
     } 
    } 
    } 

InterruptedExceptionの後に新しいAS400接続でDataQueueオブジェクトを再作成することを強くお勧めします。 AS400接続がストールしている可能性があります。 Thread.interruptは非常に便利ですが、注意して使用してください。

+0

これはほぼ正しいです...このコードはInterruptedExceptionに正常に到達しましたが、VisualVMを使用してスレッドがハングアップしていることに気付きました...これはDataQueの読み込みメソッドがまだアクティブなためです。それを読み取りとして設定する方法はありますか? – RedEagle

+0

interruptExecuter.shutdown()を追加するだけです。 Zig158ありがとう – RedEagle