FTP Polling using FTP JCA adapter in OSB 12c

We can poll files at regular intervals from a remote ftp/sftp server location using Oracle JCA adapter for FTP, with help of GET operation. We can integrate oracle JCA FTP adapter with BPEL, mediator, or OSB 12c. In this article, we will be creating one OSB project that will demonstrate polling of files from remote FTP location using FTP adapter and writing the files to our local server location

Note: Using JDeveloper 12c (12.2.1.4).

Pre-requisites:

  • Connection factory configured in Weblogic server.
  • User, configured in connection factory has the access to read and write files to target/from ftp location

Steps:

Let's start by creating a new project with the name "FTP_Polling".

1. Open "servicebus.sboverview" and drag FTP adapter from components palette to proxy services side.

2. Enter the adapter name and click on next.
3. In the next step, select Define from operation and schema (specified later).
4. Specify the JNDI of the connection factory(e.g. eis/Ftp/testFtpAdapter) for the remote SFTP server, from which we want to poll the files. Click on Next.
5. Specify the file type - Binary or ASCII. Select Operation type as Get File. Click Next.
6. Specify the input directory, from where we want to poll files. For e.g. "/inbound/input". Uncheck, if you don't want to process files recursively. If you want to delete the file from a remote location, then check "Delete files after successful retrieval".
If you want to archive after reading, then check archive processed files. Provide the directory that is located at your server, not on the remote FTP location. If you want to archive at the same remote location, then add the below property in .jca file of the adapter.
<property name="UseRemoteArchive" value="true"/>
7. Specify the file pattern and click on Next.
8. Specify the polling frequency(Here we have kept 1 minute or 60 seconds. The adapter will check every 60 seconds if there is any file available) and click on Next.
9. Specify the schema, if you don't have any schema and want to read data as opaque then select "Native format translation not required". In this example, we will be using an opaque schema and will not convert the data to XML by providing any schema. Click on Next. Then click on Finish.
10. Adapter files along with proxy service will be created and the adapter will appear on the proxy services side.
11. Drag and Drop pipeline on Pipeline/Split joins area. A popup window will appear. Specify the service name and click on Next.
12. Uncheck the "Expose as proxy service". Select the concrete wsdl(i.e. containing ports and bindings), which got created while creating the FTP adapter.
13. Click on Finish. A pipeline will be created. Now link the adapter and connect the arrow from proxy to pipeline as shown below.
Note: If proxy service is showing error. Just save all files in the project.

Let's create a file adapter to write the polled file to some local directory.

14. Drag file adapter from components palette. Enter the adapter name and click Next.
15. Select Define from operation and schema (specified later). Click on Next.
16. Provide the name of JNDI and click on Next.
17. Select the Write File as operation type. Click on Next
18. Provide the physical or logical directory and file naming convention(e.g. test_%yyMMddHHmmssSS%). Click on Next.
19. Specify the schema, if you don't have any schema and want to read data as opaque then select "Native format translation not required". In this example, we will be using an opaque schema and will not convert the data to XML by providing any schema. Click on Next. Then click on Finish.
20. Business service and adapter files will be created. Join the wire from the pipeline to the newly created file adapter.
21. Double click on the pipeline. The pipeline window will open. You will see, the route node is already created and configured with the file write business service. Click on routing to check for properties.
22. Under properties select operation as write.
23. Since we are using opaque schema to read and write, we need not do any transformation. Opaque/ base64 data coming as input to service will go to file write business service as output. In this case, the namespace of the body variable will also remain the same.

24. Save and deploy the project to the service bus console. Check for the whole operation to execute.

Files will be picked from the source location and will be written to the target location. Sample file name: test_21011512001300

Note: Since this is an OSB composite, you need to enable trace to see the complete flow from the em console.
 


Comments

  1. Thanks for the informative blog. can you help me with 2 things - 1.get the filename which is getting picked up by the FTP service. 2. I am using SFTP and have configured the username and password in the Connection factory configured in Weblogic server. do I need to use additional security in the FTP proxy.

    ReplyDelete

Post a Comment

Popular posts from this blog

DateTime formatting using xp20:format-dateTime ()

Create Delimited String from XML Nodes and Vice Versa in SOA 12c

Import and Export MDS artifacts in SOA 12c