2016-07-11 1 views
1

DB에서 파일 이름 목록을 읽는 일정 작업이 필요하며 파일을 ftp 사이트에 업로드해야합니다. WSO2 ESB에서 어떻게합니까?DB에서 파일 이름 목록을 읽고이를 ftp 사이트에 업로드하는 방법

감사

업데이트 (7/19/16) : 주어진 제안을 바탕으로, 나는 XML 형식으로 모든 파일 이름을 반환하는 저장 프로 시저를 썼다. 이제이 XML 형식의 결과를 구문 분석하는 방법을 알아야하고 fileconnector를 사용하여 ftp가 될 수 있습니다. 제 접근 방식을 실행할 수 있는지 알려주십시오. 도와 주셔서 정말 감사합니다.

<proxy name="FileUpload2CDGPS" startOnLoad="true" trace="disable" transports="https http" xmlns="http://ws.apache.org/ns/synapse"> 
    <target> 
     <inSequence> 
      <sequence key="FileLookupSeq"/> 
      <sequence key="SendFile2VendorSeq"/> 
      <send/> 
     </inSequence> 
     <outSequence/> 
     <faultSequence> 
      <drop/> 
     </faultSequence> 
    </target> 
</proxy> 

<sequence name="FileLookupSeq" trace="disable" xmlns="http://ws.apache.org/ns/synapse"> 
    <log description="LogMessage" level="custom"> 
    <property name="message" value="Find CDR files to upload"/> 
    </log> 
    <dblookup description="Get CDR files to be upload"> 
    <connection> 
     <pool> 
     <password>***</password> 
     <driver>org.postgresql.Driver</driver> 
     <url>jdbc:postgresql://localhost:5432/esbcdrdb</url> 
     <user>***</user> 
     </pool> 
    </connection> 
    <statement> 
     <sql><![CDATA[SELECT * FROM find_cdr_file_to_upload(1)]]></sql> 
     <result name="xml_file" column="find_cdr_file_to_upload"/> 
    </statement> 
    </dblookup> 
</sequence> 

<sequence name="SendFile2VendorSeq" trace="disable" xmlns="http://ws.apache.org/ns/synapse"> 
    <iterate attachPath="//files/files-set" description="" 
    expression="//files/files-set/file" preservePayload="true"> 
    <target> 
     <sequence> 
     <property description="fileName" 
      expression="//files/files-set/file/name" name="fileName" 
      scope="default" type="STRING"/> 
     <property description="fileId" 
      expression="//files/files-set/file/id" name="fileId" 
      scope="default" type="STRING"/> 
     <property description="fileSource" 
      expression="//files/files-set/file/path" name="fileSource" 
      scope="default" type="STRING"/> 
     <property description="vendorId" 
      expression="//files/files-set/file/vendor-id" name="vendorId" 
      scope="default" type="STRING"/> 
     <property description="vendorDest" 
      expression="//files/files-set/file/vendor-dest" 
      name="vendorDest" scope="default" type="STRING"/> 
     <fileconnector.copy> 
      <source>{$ctx:fileSource}</source> 
      <destination>{$ctx:vendorDest}</destination> 
      <filePattern>{$ctx:fileName}</filePattern> 
     </fileconnector.copy> 
     </sequence> 
    </target> 
    </iterate> 
</sequence> 

답변

2

이렇게 할 수있는 방법에는 여러 가지가 있습니다.

  • db 연결을 처리하고 파일을 ftp 사이트에 업로드하는 일정 작업 내에 직접 요구 사항을 작성할 수 있습니다. 방법 write a schedule task
  • 예약 된 작업 sample can be found here을 통해 프록시를 호출 할 수 있습니다. 프록시 내부에서 db에 연결하여 필요한 데이터를 가져와 using vfs에 업로드하거나 custom mediator을 작성하여 프록시 내에서 실행되도록 할 수 있습니다.
+0

저는 예약 된 작업을 통해 프록시를 호출하는 방식을 좋아합니다. 프록시가 DB에 연결하여 필요한 데이터를 가져옵니다. 그러나 DB에서 여러 행이 반환됩니다. dblookup 중재자가 결과 집합에서 한 행의 속성 만 설정할 수 있다고 생각 했었습니다. 맞습니까? 그렇다면 활용할 수있는 다른 중재자가 있습니까? –

+0

@ M.Tai, 여러 행을 얻을 수 없다는 것을 알았습니다. 해결책은 맞춤 중개자를 작성할 수 있습니다. 비슷한 질문과 대답은 http://stackoverflow.com/a/16264739/993892 –

+0

당신의 제안에 감사드립니다. 나는 그것을 시도 할 것이다. –

관련 문제