2016-03-30 23 views
0

私はいくつかの特定の問題に直面しました: 休憩コントローラが何時間か働いています。それは応答しません。ブラウザの読み込みプロセスは、しばらくの間、応答を待っています。もし私がPOSTerでリクエストを送ると、そのリクエストはコントローラに送られたが、レスポンスは受信されていないことがわかります。私はアプリをデバッグしようとしました、私はいくつかの処理がスケジュールされている - 彼らは働いています。しかし、コントローラではありません。リクエストがコントローラに届かない。それは前に立ち往生した。これがどこで起こっているのか、私はどのように知ることができますか?ありがとうございました。Spring MVCコントローラが固まって応答していない

@RestController 
@RequestMapping("/quotes") 
public class QuotesController { 

private final QuotesService quotesService; 

@Autowired 
public QuotesController(QuotesService quotesService) { 
    this.quotesService = quotesService; 
} 

@RequestMapping(value="", method= RequestMethod.GET, produces = "application/json; charset=utf-8") 
public ResponseEntity<List<LoadedFileInfo>> getLoadedFilesData(){ 
    List<LoadedFileInfo> result = quotesService.getLoadedFilesData(); 
    return new ResponseEntity<List<LoadedFileInfo>>(result, HttpStatus.OK); 
} 

@RequestMapping(value="/currencyPairs", method= RequestMethod.GET, produces = "application/json; charset=utf-8") 
public ResponseEntity<List<CurrencyPair>> getCurrencyPairs(){ 
    return new ResponseEntity<List<CurrencyPair>>(quotesService.getCurrencyPairs(), HttpStatus.OK); 
} 

@RequestMapping(value="/oneMinute", method= RequestMethod.GET, produces = "application/json; charset=utf-8") 
public ResponseEntity<List<Number[]>> getOneMinuteQuotes(@RequestParam @DateTimeFormat(iso= DateTimeFormat.ISO.DATE_TIME) LocalDateTime from, @RequestParam @DateTimeFormat(iso= DateTimeFormat.ISO.DATE_TIME) LocalDateTime to, @RequestParam Integer currencyPair){ 
    return new ResponseEntity<List<Number[]>>(quotesService.getOneMinuteQuotes(from, to, currencyPair), HttpStatus.OK); 
} 

@RequestMapping(value="/fiveMinutes", method= RequestMethod.GET, produces = "application/json; charset=utf-8") 
public ResponseEntity<List<Number[]>> getFiveMinutesQuotes(@RequestParam @DateTimeFormat(iso= DateTimeFormat.ISO.DATE_TIME) LocalDateTime from, @RequestParam @DateTimeFormat(iso= DateTimeFormat.ISO.DATE_TIME) LocalDateTime to, @RequestParam Integer currencyPair){ 
    return new ResponseEntity<List<Number[]>>(quotesService.getFiveMinuteQuotes(from, to, currencyPair), HttpStatus.OK); 
} 

@RequestMapping(value="/fifteenMinutes", method= RequestMethod.GET, produces = "application/json; charset=utf-8") 
public ResponseEntity<List<Number[]>> getFifteenMinutesQuotes(@RequestParam @DateTimeFormat(iso= DateTimeFormat.ISO.DATE_TIME) LocalDateTime from, @RequestParam @DateTimeFormat(iso= DateTimeFormat.ISO.DATE_TIME) LocalDateTime to, @RequestParam Integer currencyPair){ 
    return new ResponseEntity<List<Number[]>>(quotesService.getFifteenMinuteQuotes(from, to, currencyPair), HttpStatus.OK); 
} 

@RequestMapping(value="/thirtyMinutes", method= RequestMethod.GET, produces = "application/json; charset=utf-8") 
public ResponseEntity<List<Number[]>> getThirtyMinutesQuotes(@RequestParam @DateTimeFormat(iso= DateTimeFormat.ISO.DATE_TIME) LocalDateTime from, @RequestParam @DateTimeFormat(iso= DateTimeFormat.ISO.DATE_TIME) LocalDateTime to, @RequestParam Integer currencyPair){ 
    return new ResponseEntity<List<Number[]>>(quotesService.getThirtyMinuteQuotes(from, to, currencyPair), HttpStatus.OK); 
} 

@RequestMapping(value="/oneHour", method= RequestMethod.GET, produces = "application/json; charset=utf-8") 
public ResponseEntity<List<Number[]>> getOneHourQuotes(@RequestParam @DateTimeFormat(iso= DateTimeFormat.ISO.DATE_TIME) LocalDateTime from, @RequestParam @DateTimeFormat(iso= DateTimeFormat.ISO.DATE_TIME) LocalDateTime to, @RequestParam Integer currencyPair){ 
    return new ResponseEntity<List<Number[]>>(quotesService.getOneHourQuotes(from, to, currencyPair), HttpStatus.OK); 
} 

@RequestMapping(value="/fourHours", method= RequestMethod.GET, produces = "application/json; charset=utf-8") 
public ResponseEntity<List<Number[]>> getFourHourQuotes(@RequestParam @DateTimeFormat(iso= DateTimeFormat.ISO.DATE_TIME) LocalDateTime from, @RequestParam @DateTimeFormat(iso= DateTimeFormat.ISO.DATE_TIME) LocalDateTime to, @RequestParam Integer currencyPair){ 
    return new ResponseEntity<List<Number[]>>(quotesService.getFourHourQuotes(from, to, currencyPair), HttpStatus.OK); 
} 

@RequestMapping(value="/oneDay", method= RequestMethod.GET, produces = "application/json; charset=utf-8") 
public ResponseEntity<List<Number[]>> getOneDayQuotes(@RequestParam @DateTimeFormat(iso= DateTimeFormat.ISO.DATE_TIME) LocalDateTime from, @RequestParam @DateTimeFormat(iso= DateTimeFormat.ISO.DATE_TIME) LocalDateTime to, @RequestParam Integer currencyPair){ 
    return new ResponseEntity<List<Number[]>>(quotesService.getOneDayQuotes(from, to, currencyPair), HttpStatus.OK); 
} 

@RequestMapping(value="/oneWeek", method= RequestMethod.GET, produces = "application/json; charset=utf-8") 
public ResponseEntity<List<Number[]>> getOneWeekQuotes(@RequestParam @DateTimeFormat(iso= DateTimeFormat.ISO.DATE_TIME) LocalDateTime from, @RequestParam @DateTimeFormat(iso= DateTimeFormat.ISO.DATE_TIME) LocalDateTime to, @RequestParam Integer currencyPair){ 
    return new ResponseEntity<List<Number[]>>(quotesService.getOneWeekQuotes(from, to, currencyPair), HttpStatus.OK); 
} 

@RequestMapping(value="/oneMonth", method= RequestMethod.GET, produces = "application/json; charset=utf-8") 
public ResponseEntity<List<Number[]>> getOneMonthQuotes(@RequestParam @DateTimeFormat(iso= DateTimeFormat.ISO.DATE_TIME) LocalDateTime from, @RequestParam @DateTimeFormat(iso= DateTimeFormat.ISO.DATE_TIME) LocalDateTime to, @RequestParam Integer currencyPair){ 
    return new ResponseEntity<List<Number[]>>(quotesService.getOneMonthQuotes(from, to, currencyPair), HttpStatus.OK); 
} 

}

+0

ことがあるか、一つだけを助けることができると仮定してきたように、分析のいずれかのタイプを試していないので、?ログにエラーがありますか?あなたはスレッドダンプを試みましたか?あなたはそれにvisualVMを接続しましたか?どのアプリケーションサーバーですか? –

+0

これはSpringBootです。私にはコントローラが1つしかありません。ログにエラーはありません。スレッドダンプを試していないし、visualVMに接続していない – migAlex

+0

REST用に作成したコントローラコードを投稿できますか? – srinivas

答えて

0

私はあなたのコントローラに問題があるとは思わないが、少なくとも提供されたコードでそのための証拠がない:これは私のコントローラクラスです。 少数を示すために、ここで間違って行くことができるか多くの理由があります。

  • HTTP接続プールは、アプリケーションを実行します 完全なWebサーバーは、接続プールを併設しています - 可能なHTTPの数を接続。 非同期のものを使用していない限り(私はそうでないと思います)、プールが多数の接続が並行して実行され、コントローラにアクセスしようとすると圧倒される可能性があります。

    まず、接続プールが正常であることを確認します。通常、接続プールは何らかの管理を公開します。たとえば、TomcatにはJMXがあります)、jconsoleなどでログインし、空き接続が多数あることを確認します。

  • 時折ネットワークに問題があります これは本当に分かりやすいものです。 コントローラの冒頭にいくつかのトレースメッセージを追加してログを記録するだけです。次に、ログをチェックして、それぞれの要求ごとに新しいメッセージが表示されるかどうかを確認します。必要な場合は、コードが正しく呼び出されます。

  • 欠陥は、あなたが助けることができる、それが再び流れを(完了するために、コントローラのメソッドのために年齢を取ることがわかり始めにログを追跡し、コントローラのメソッドの最後でなければならない。この場合、アプリケーション自体 の内側にあります)。 これを証明するには、スレッドダンプを取ることを検討してください。たとえば、Linuxの場合は、Javaプロセスでを殺す-3を実行するか、あるいはjstackを使用することができます。 とにかく、スレッドダンプは、アプリケーションを取った時点でスタックがどこに止まっているかを示すはずです。あなたはラッキー1 :)あなたは、アプリケーションのプロファイリング、どこで理解できることから、

だ - あなたはそれを取るのであれば、コントローラの実行を担当するスレッドが同じ場所に貼り付けられていることがわかり倍とまだ言います正確には時間は費やされますが、これは生産マシンではなく「オフライン」で行うべきです。この答えは、あまりにも基本的に聞こえるが、場合

申し訳ありませんが、あなたは本当に、私は、そのような説明は

すべてのコントローラ用
+0

ありがとうございます。役に立つ情報がたくさんあります。それを分析して使用しようとします。ありがとうございました – migAlex

関連する問題