2016-08-04 7 views
0

ドキュメントのダウンロード/アップロードのための私のプロジェクトの安らかなサービスのためのcamel-jetty httpプロキシブリッジを作成しました。これらのサービスは、さまざまな種類のドキュメントを取得/アップロードするために呼び出されます。ほとんどの場合、ファイルサイズは100MBを超えます。大きなリクエストストリーム(ファイルアップロード)のためにcamel-jetty httpプロキシに時間がかかりすぎる

100MBのドキュメントをアップロードするためにアップロード・レスト・サービス(HTTP POST)を直接呼び出すと(camel-jetty httpプロキシ経由でルーティングされない)、アップロードを完了して応答を返すのに約2-3分かかりますしかし、私がラクダルート経由でリクエストをルーティングするときは、ラクダルートがHTTPプロキシに過ぎないので、奇妙なものである15分以上かかる。続き

は、いくつかの情報です:

キャメルバージョン2.15.1

キャメルルート定義

<route> 
     <from uri="jetty:http://0.0.0.0:8383/sqidds/document?disableStreamCache=true&amp;matchOnUriPrefix=true&amp;enableMultipartFilter=false&amp;continuationTimeout=-1" /> 
     <log id="incomingMessage" message="incomingMessage - \n[id = ${id}]\n [headers = ${headers}]" /> 
     <to uri="jetty:http://somehost:8080/sqidds/document?bridgeEndpoint=true&amp;throwExceptionOnFailure=false&amp;httpClient.timeout=3200000" /> 
     <log id="outgoingMessage" message="outgoingMessage - \n[id = ${id}]\n [headers = ${headers}]" /> 
    </route> 

キャメルプロジェクトPOM抜粋:

. 
    . 
    . 
    <dependency> 
     <groupId>org.apache.camel</groupId> 
     <artifactId>camel-core</artifactId> 
     <version>2.15.1.redhat-621084</version> 
    </dependency> 
    <dependency> 
     <groupId>org.apache.camel</groupId> 
     <artifactId>camel-spring</artifactId> 
     <version>2.15.1.redhat-621084</version> 
    </dependency> 
    . 
    . 
    . 
    <dependency> 
     <groupId>org.apache.camel</groupId> 
     <artifactId>camel-jetty</artifactId> 
     <version>2.15.1.redhat-621084</version> 
    </dependency> 
    <dependency> 
     <groupId>org.apache.camel</groupId> 
     <artifactId>camel-http</artifactId> 
     <version>2.15.1.redhat-621084</version> 
     <!-- use the same version as your Camel core version --> 
    </dependency> 
    . 
    . 
    . 

休憩サービス(Spring MVCの)コード

@RequestMapping(method = RequestMethod.POST, consumes = MediaType.MULTIPART_FORM_DATA_VALUE) 
public @ResponseBody String saveFile(@RequestPart("file") MultipartFile file) throws IOException, DocumentNotSavedException { 

    String targetPath = null; 
    if (file != null) { 
     String repoDirectoryPath = "SOME_REPO_PATH";   
     String uniqueFileName = FileUtil.getUniqueFileName(repoDirectoryPath, file.getOriginalFilename()); 
     File targetFile = new File(repoDirectoryPath, uniqueFileName); 
     targetPath = targetFile.getCanonicalPath(); 

     FileUtils.copyInputStreamToFile(file.getInputStream(), targetFile); 

    } else { 
     log.error("File is null"); 
     throw new DocumentNotSavedException("File data could not be saved"); 
    } 

    return targetPath; 
} 

RestClientコード

public String putDocument(File file,String fileName) throws RestClientException{ 
     ResponseEntity<String> response = null; 
     try { 
      File file = new File("SOME_100MB_FILE.pdf"); 
      byte[] fileBytes = new byte[(int)file.length()]; 
      LinkedMultiValueMap<String, Object> map = new LinkedMultiValueMap(); 
      ByteArrayResource contentsAsResource = new ByteArrayResource(fileBytes, fileName) { 
       @Override 
       public String getFilename() { 
        return this.getDescription(); 
       } 
      }; 
      map.add("file", contentsAsResource); 
      httpHeaders.setContentType(MediaType.MULTIPART_FORM_DATA); 

      HttpEntity<LinkedMultiValueMap<String, Object>> requestEntity = new HttpEntity<LinkedMultiValueMap<String, Object>>(map, httpHeaders); 

      response = restTemplate.exchange(serverUri, HttpMethod.POST, requestEntity, String.class); 
     } catch (Exception e) { 
      logger.error("Exception in put document service", e); 
      throw new RestClientException("Exception in put document service :",e); 
     } 
     return response.getBody(); 
} 

注:100MBのファイルについては、受信メッセージのためのラクダのルートログサービスが起動されてから1秒以内にログに記録されますが、約15分後に送信ログが表示されます。私はプロデューサーのラクダのルートに何か問題があるかもしれないと思います。

答えて

関連する問題